Skip to content

Commit

Permalink
update dca eval config test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ericges committed Nov 27, 2024
1 parent d715818 commit 87f0625
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/EventListener/DcaField/DateAddedFieldListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,22 @@ public function testOnLoadDataContainer()
public function dateAddedConfig():array
{
return [
[null, false, false, false, false],
[1, true, false, false, false],
[2, false, true, false, false],
[null, false, false, true, false],
[null, false, false, false, true],
[null, false, false, false, false, null],
[1, true, false, false, false, []],
[2, false, true, false, false, ['testProp' => 'testValue']],
[null, false, false, true, false, ['a' => 'x', 'b' => 'y', 'c' => 99]],
[null, false, false, false, true, ['noSubmissionField' => true]],
];
}

/**
* @dataProvider dateAddedConfig
* @runInSeparateProcess
*/
public function testConfig(?int $flag, bool $sorting, bool $exclude, bool $filter, bool $search)
public function testConfig(?int $flag, bool $sorting, bool $exclude, bool $filter, bool $search, ?array $eval)
{
$eval ??= [];

$container = $this->createMock(ContainerInterface::class);

$listener = new DateAddedFieldListener($container);
Expand All @@ -79,6 +81,9 @@ public function testConfig(?int $flag, bool $sorting, bool $exclude, bool $filte
$config->setExclude($exclude);
$config->setFilter($filter);
$config->setSearch($search);
foreach ($eval as $key => $value) {
$config->setEvalValue($key, $value);
}

$listener->onLoadDataContainer($table);

Expand All @@ -104,6 +109,14 @@ public function testConfig(?int $flag, bool $sorting, bool $exclude, bool $filte
$this->assertArrayHasKey('search', $field);
$this->assertTrue($field['search']);
}
if (!empty($eval)) {
$this->assertArrayHasKey('eval', $field);
$this->assertIsArray($field['eval']);
foreach ($eval as $key => $value) {
$this->assertArrayHasKey($key, $field['eval']);
$this->assertEquals($value, $field['eval'][$key]);
}
}
}

public function testOnLoadCallback()
Expand Down

0 comments on commit 87f0625

Please sign in to comment.