]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/StringsTest.php
Merge pull request #7670 from nupplaphil/task/add_router_config
[friendica.git] / tests / src / Util / StringsTest.php
index 666b76e57b1c225bd2c6348e42a530bc3a690075..f926183108c1e71634414bd80397788279d36f11 100644 (file)
@@ -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));
+       }
 }