Add Arrays::containsEmptyStringsOnly() method

Returns information if given array contains an empty strings only
This commit is contained in:
Meritoo
2019-08-28 15:51:03 +02:00
parent 10992570ad
commit 891411e231
3 changed files with 85 additions and 0 deletions

View File

@@ -1486,6 +1486,17 @@ letsTest[2] = value_2;';
self::assertSame($expected, Arrays::isNotEmptyArray($value), $description);
}
/**
* @param array $array
* @param bool $expected
*
* @dataProvider provideArrayToVerifyIfContainsEmptyStringsOnly
*/
public function testContainsEmptyStringsOnly(array $array, bool $expected): void
{
static::assertSame($expected, Arrays::containsEmptyStringsOnly($array));
}
/**
* Provides simple array to set/replace values with keys
*
@@ -2870,6 +2881,48 @@ letsTest[2] = value_2;';
];
}
public function provideArrayToVerifyIfContainsEmptyStringsOnly(): ?Generator
{
yield[
[],
false,
];
yield[
[
'',
1,
],
false,
];
yield[
[
'',
null,
1,
],
false,
];
yield[
[
'',
null,
],
true,
];
yield[
[
'',
null,
'',
],
true,
];
}
/**
* {@inheritdoc}
*/