mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Fix code pointed by Psalm
This commit is contained in:
@@ -23,7 +23,7 @@ use stdClass;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Miscellaneous
|
||||
* @covers \Meritoo\Common\Utilities\Miscellaneous
|
||||
*/
|
||||
class MiscellaneousTest extends BaseTestCase
|
||||
{
|
||||
@@ -707,22 +707,40 @@ class MiscellaneousTest extends BaseTestCase
|
||||
*
|
||||
* @dataProvider provideNumberToFillMissingZeros
|
||||
*/
|
||||
public function testFillMissingZeros($number, $length, $before, $expected)
|
||||
public function testFillMissingZeros($number, $length, $before, $expected): void
|
||||
{
|
||||
self::assertSame($expected, Miscellaneous::fillMissingZeros($number, $length, $before));
|
||||
}
|
||||
|
||||
public function testGetProjectRootPath()
|
||||
public function testGetProjectRootPath(): void
|
||||
{
|
||||
self::assertNotEmpty(Miscellaneous::getProjectRootPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description Description of test case
|
||||
* @param string $string The string which should be shortened
|
||||
* @param bool $last (optional) If is set to true, last element is removed (default behaviour).
|
||||
* Otherwise - first.
|
||||
* @param null|string $expected Expected result
|
||||
*
|
||||
* @dataProvider provideStringToRemoveMarginalCharacter
|
||||
*/
|
||||
public function testRemoveMarginalCharacter(
|
||||
string $description,
|
||||
string $string,
|
||||
bool $last,
|
||||
?string $expected
|
||||
): void {
|
||||
self::assertEquals($expected, Miscellaneous::removeMarginalCharacter($string, $last), $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides string to convert characters to latin characters and not lower cased and not human-readable
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideStringToLatinNotLowerCaseHuman()
|
||||
public function provideStringToLatinNotLowerCaseHuman(): ?Generator
|
||||
{
|
||||
yield[
|
||||
'asuo',
|
||||
@@ -1443,6 +1461,51 @@ class MiscellaneousTest extends BaseTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function provideStringToRemoveMarginalCharacter(): ?Generator
|
||||
{
|
||||
yield[
|
||||
'An empty string - remove last character',
|
||||
'',
|
||||
true,
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'An empty string - remove first character',
|
||||
'',
|
||||
false,
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'Simple, two words - remove last character',
|
||||
'Lorem ipsum',
|
||||
true,
|
||||
'Lorem ipsu',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Simple, two words - remove first character',
|
||||
'Lorem ipsum',
|
||||
false,
|
||||
'orem ipsum',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Two sentences - remove last character',
|
||||
'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.',
|
||||
true,
|
||||
'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Two sentences - remove first character',
|
||||
'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.',
|
||||
false,
|
||||
'tiam ullamcorper. Suspendisse a pellentesque dui, non felis.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user