mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
Regex - isBinaryValue() method - returns information if given value is a binary value
This commit is contained in:
@@ -344,6 +344,17 @@ class RegexTest extends BaseTestCase
|
||||
self::assertEquals($expected, Regex::areValidHtmlAttributes($htmlAttributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value Value to verify
|
||||
* @param bool $expected Information if value is a binary value
|
||||
*
|
||||
* @dataProvider provideBinaryValue
|
||||
*/
|
||||
public static function testIsBinaryValue($value, $expected)
|
||||
{
|
||||
self::assertEquals($expected, Regex::isBinaryValue($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of bundle and information if it's valid name
|
||||
*
|
||||
@@ -473,6 +484,62 @@ class RegexTest extends BaseTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides value to verify if it is a binary value
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideBinaryValue()
|
||||
{
|
||||
$file1Path = $this->getFilePathForTesting('lorem-ipsum.txt');
|
||||
$file2Path = $this->getFilePathForTesting('minion.jpg');
|
||||
|
||||
yield[
|
||||
null,
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
[],
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'abc',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'1234',
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
1234,
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
12.34,
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
fread(fopen($file1Path, 'r'), 1),
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
fread(fopen($file2Path, 'r'), 1),
|
||||
true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user