From 0115329dc6a21366905fca494874c77269b507d5 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 30 May 2019 12:26:29 +0200 Subject: [PATCH] Add test for Strings::isHex() --- tests/src/Util/StringsTest.php | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/src/Util/StringsTest.php b/tests/src/Util/StringsTest.php index 666b76e57b..f926183108 100644 --- a/tests/src/Util/StringsTest.php +++ b/tests/src/Util/StringsTest.php @@ -82,4 +82,39 @@ class StringsTest extends TestCase $escapedString ); } + + public function dataIsHex() + { + return [ + 'validHex' => [ + 'input' => '90913473615bf00c122ac78338492980', + 'valid' => true, + ], + 'invalidHex' => [ + 'input' => '90913473615bf00c122ac7833849293', + 'valid' => false, + ], + 'emptyHex' => [ + 'input' => '', + 'valid' => false, + ], + 'nullHex' => [ + 'input' => null, + 'valid' => false, + ], + ]; + } + + /** + * Tests if the string is a valid hexadecimal value + * + * @param string $input + * @param bool $valid + * + * @dataProvider dataIsHex + */ + public function testIsHex($input, $valid) + { + $this->assertEquals($valid, Strings::isHex($input)); + } }