]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make sure the UUIDs are unique too :)
authorBrion Vibber <brion@pobox.com>
Thu, 30 Dec 2010 21:37:05 +0000 (13:37 -0800)
committerBrion Vibber <brion@pobox.com>
Thu, 30 Dec 2010 21:37:05 +0000 (13:37 -0800)
tests/UUIDTest.php

index de256ffa1ff2423b5ce26b7191376901762322c3..e78d5ce1bce7e71b46f147a23695b6b78ed6c054 100644 (file)
@@ -21,5 +21,17 @@ class UUIDTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(0x4000, hexdec(substr($result, 14, 4)) & 0xF000);
         $this->assertEquals(0x8000, hexdec(substr($result, 19, 4)) & 0xC000);
     }
+
+    public function testUnique()
+    {
+        $reps = 100;
+        $ids = array();
+
+        for ($i = 0; $i < $reps; $i++) {
+            $ids[] = UUID::gen();
+        }
+
+        $this->assertEquals(count($ids), count(array_unique($ids)), "UUIDs must be unique");
+    }
 }