Skip to content

Commit 43dc7b3

Browse files
committed
Separate "Valid" and "Invalid" tests
1 parent 7aa5aac commit 43dc7b3

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

tests/Unit/ConfigurationTest.php

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,30 @@ public function testValidConfig(array $inputConfig, array $expectedConfig): void
2626
/**
2727
* @param mixed $value
2828
*
29-
* @dataProvider dataTestSettingsDynamicChecker
29+
* @dataProvider dataTestSettingsDynamicCheckerInvalid
3030
*/
31-
public function testSettingsDynamicChecker($value, bool $passed): void
31+
public function testSettingsDynamicCheckerInvalid($value): void
3232
{
33-
if (!$passed) {
34-
$this->assertConfigurationIsInvalid([
35-
'meilisearch' => [
36-
'indices' => [
37-
[
38-
'name' => 'items',
39-
'class' => 'App\Entity\Post',
40-
'settings' => $value,
41-
],
33+
$this->assertConfigurationIsInvalid([
34+
'meilisearch' => [
35+
'indices' => [
36+
[
37+
'name' => 'items',
38+
'class' => 'App\Entity\Post',
39+
'settings' => $value,
4240
],
4341
],
44-
], 'Settings must be an array.');
45-
46-
return;
47-
}
42+
],
43+
], 'Settings must be an array.');
44+
}
4845

46+
/**
47+
* @param mixed $value
48+
*
49+
* @dataProvider dataTestSettingsDynamicCheckerValid
50+
*/
51+
public function testSettingsDynamicCheckerValid($value): void
52+
{
4953
$this->assertConfigurationIsValid([
5054
'meilisearch' => [
5155
'indices' => [
@@ -330,32 +334,21 @@ public static function dataTestConfigurationTree(): iterable
330334
];
331335
}
332336

333-
public static function dataTestSettingsDynamicChecker(): iterable
337+
public static function dataTestSettingsDynamicCheckerInvalid(): iterable
334338
{
335-
yield 'string is not acceptable' => [
336-
'settings' => 'hello',
337-
'passed' => false,
338-
];
339-
340-
yield 'int is not acceptable' => [
341-
'settings' => 1,
342-
'passed' => false,
343-
];
344-
345-
yield 'bool is not acceptable' => [
346-
'settings' => true,
347-
'passed' => false,
348-
];
349-
350-
yield 'array is acceptable' => [
351-
'settings' => [],
352-
'passed' => true,
353-
];
339+
yield 'string is not acceptable' => ['hello'];
340+
yield 'int is not acceptable' => [1];
341+
yield 'bool is not acceptable' => [true];
342+
}
354343

355-
yield 'null is acceptable' => [
356-
'settings' => null,
357-
'passed' => true,
358-
];
344+
public static function dataTestSettingsDynamicCheckerValid(): iterable
345+
{
346+
yield 'array is acceptable' => [[]];
347+
yield 'array with arbitrary key is acceptable' => [[
348+
'key' => 'value',
349+
'key2' => 'value2',
350+
]];
351+
yield 'null is acceptable' => [null];
359352
}
360353

361354
protected function getConfiguration(): Configuration

0 commit comments

Comments
 (0)