]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/StringsTest.php
Merge pull request #7785 from nupplaphil/bug/7676-is_file_warning
[friendica.git] / tests / src / Util / StringsTest.php
index 666b76e57b1c225bd2c6348e42a530bc3a690075..d090b1c5dd3a088f9dad89a5323616c3f0cce2e5 100644 (file)
@@ -12,7 +12,7 @@ use PHPUnit\Framework\TestCase;
  */
 class StringsTest extends TestCase
 {
-    /**
+       /**
         * randomnames should be random, even length
         */
        public function testRandomEven()
@@ -64,9 +64,9 @@ class StringsTest extends TestCase
 
                $randomname2 = Strings::getRandomName(1);
                $this->assertEquals(1, strlen($randomname2));
-    }
-    
-    /**
+       }
+
+       /**
         * test, that tags are escaped
         */
        public function testEscapeHtml()
@@ -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));
+       }
 }