2023-11-02 17:10:50 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Unit;
|
|
|
|
|
|
|
|
use App\Models\SavedReport;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class SavedReportTest extends TestCase
|
|
|
|
{
|
2023-11-30 16:57:21 -08:00
|
|
|
public function testParsingCheckmarkValue()
|
2023-11-02 17:10:50 -07:00
|
|
|
{
|
|
|
|
$savedReport = SavedReport::factory()->create([
|
|
|
|
'options' => [
|
|
|
|
'is_a_checkbox_value' => '1',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals('1', $savedReport->checkmarkValue('is_a_checkbox_value'));
|
|
|
|
$this->assertEquals('0', $savedReport->checkmarkValue('non_existent_key'));
|
|
|
|
|
|
|
|
$this->assertEquals('1', (new SavedReport)->checkmarkValue('is_a_checkbox_value'));
|
|
|
|
}
|
|
|
|
|
2023-11-30 16:57:21 -08:00
|
|
|
public function testParsingTextValue()
|
2023-11-02 17:10:50 -07:00
|
|
|
{
|
|
|
|
$savedReport = SavedReport::factory()->create([
|
|
|
|
'options' => [
|
|
|
|
'is_a_text_value' => 'some text',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals('some text', $savedReport->textValue('is_a_text_value'));
|
|
|
|
$this->assertEquals('', $savedReport->textValue('non_existent_key'));
|
|
|
|
|
|
|
|
$this->assertEquals('', (new SavedReport)->textValue('is_a_text_value'));
|
|
|
|
}
|
2023-11-30 12:12:57 -08:00
|
|
|
|
2023-11-30 16:57:21 -08:00
|
|
|
public function testParsingSelectValue()
|
|
|
|
{
|
|
|
|
$savedReport = SavedReport::factory()->create([
|
|
|
|
'options' => [
|
|
|
|
'is_a_text_value_as_well' => '4',
|
|
|
|
'contains_a_null_value' => null,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals('4', $savedReport->selectValue('is_a_text_value_as_well'));
|
|
|
|
$this->assertEquals('', $savedReport->selectValue('non_existent_key'));
|
|
|
|
$this->assertNull($savedReport->selectValue('contains_a_null_value'));
|
|
|
|
}
|
|
|
|
|
2023-11-30 12:12:57 -08:00
|
|
|
public function testParsingSelectValues()
|
2023-11-30 16:57:21 -08:00
|
|
|
{
|
|
|
|
$savedReport = SavedReport::factory()->create([
|
|
|
|
'options' => [
|
|
|
|
'is_an_array' => ['2', '3', '4'],
|
|
|
|
'is_an_array_containing_null' => [null],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(['2', '3', '4'], $savedReport->selectValues('is_an_array'));
|
|
|
|
$this->assertEquals(null, $savedReport->selectValues('non_existent_key'));
|
|
|
|
$this->assertNull($savedReport->selectValues('is_an_array_containing_null'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSelectValueDoesNotIncludeDeletedOrNonExistentModels()
|
2023-11-30 12:12:57 -08:00
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
2023-11-30 16:57:21 -08:00
|
|
|
|
|
|
|
// @todo: maybe it should optionally include deleted values?
|
2023-11-30 12:12:57 -08:00
|
|
|
}
|
|
|
|
|
2023-11-30 16:57:21 -08:00
|
|
|
public function testSelectValuesDoNotIncludeDeletedOrNonExistentModels()
|
2023-11-30 12:12:57 -08:00
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
|
|
|
|
// report saved with select option for a company (or whatever)
|
|
|
|
// company is deleted
|
|
|
|
// ensure company's id is not returned
|
|
|
|
}
|
2023-11-30 16:57:21 -08:00
|
|
|
|
|
|
|
public function testDeletedCustomFieldsDoNotCauseAnIssue()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
2023-11-02 17:10:50 -07:00
|
|
|
}
|