Skip to content

Commit 9fafbff

Browse files
committed
Separate "Valid" and "Invalid" tests
1 parent 7aa5aac commit 9fafbff

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

tests/Unit/ConfigurationTest.php

Lines changed: 34 additions & 29 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,31 +334,32 @@ public static function dataTestConfigurationTree(): iterable
330334
];
331335
}
332336

333-
public static function dataTestSettingsDynamicChecker(): iterable
337+
public static function dataTestSettingsDynamicCheckerInvalid(): iterable
334338
{
335339
yield 'string is not acceptable' => [
336-
'settings' => 'hello',
337-
'passed' => false,
340+
'value' => 'hello'
338341
];
339-
340342
yield 'int is not acceptable' => [
341-
'settings' => 1,
342-
'passed' => false,
343+
'value' => 1
343344
];
344-
345345
yield 'bool is not acceptable' => [
346-
'settings' => true,
347-
'passed' => false,
346+
'value' => true
348347
];
348+
}
349349

350+
public static function dataTestSettingsDynamicCheckerValid(): iterable
351+
{
350352
yield 'array is acceptable' => [
351-
'settings' => [],
352-
'passed' => true,
353+
'value' => []
354+
];
355+
yield 'array with arbitrary key is acceptable' => [
356+
'value' => [
357+
'key' => 'value',
358+
'key2' => 'value2',
359+
]
353360
];
354-
355361
yield 'null is acceptable' => [
356-
'settings' => null,
357-
'passed' => true,
362+
'value' => null
358363
];
359364
}
360365

0 commit comments

Comments
 (0)