From: Jan Schneider Date: Sun, 2 Jan 2011 22:42:51 +0000 (+0100) Subject: Add Guid test. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4ea50a07b0483925691b7a6a16182a0bebb1006d;p=horde.git Add Guid test. --- diff --git a/framework/Support/test/Horde/Support/GuidTest.php b/framework/Support/test/Horde/Support/GuidTest.php new file mode 100644 index 000000000..b60a06f71 --- /dev/null +++ b/framework/Support/test/Horde/Support/GuidTest.php @@ -0,0 +1,47 @@ +assertEquals(48, strlen(new Horde_Support_Guid())); + $this->assertRegExp('/\d{14}\.\w{23}@localhost/', (string)new Horde_Support_Guid()); + } + + public function testDuplicates() + { + $values = array(); + $cnt = 0; + + for ($i = 0; $i < 10000; ++$i) { + $id = strval(new Horde_Support_Guid()); + if (isset($values[$id])) { + $cnt++; + } else { + $values[$id] = 1; + } + } + + $this->assertEquals(0, $cnt); + } + + public function testOptions() + { + $this->assertStringEndsWith('example.com', (string)new Horde_Support_Guid(array('server' => 'example.com'))); + $this->assertRegExp('/\d{14}\.prefix\.\w{23}@localhost/', (string)new Horde_Support_Guid(array('prefix' => 'prefix'))); + } +} diff --git a/framework/Support/test/Horde/Support/RandomidTest.php b/framework/Support/test/Horde/Support/RandomidTest.php index 7645ba1a7..32084442c 100644 --- a/framework/Support/test/Horde/Support/RandomidTest.php +++ b/framework/Support/test/Horde/Support/RandomidTest.php @@ -8,7 +8,6 @@ */ /** - * @group support * @category Horde * @package Support * @subpackage UnitTests @@ -17,7 +16,12 @@ */ class Horde_Support_RandomidTest extends PHPUnit_Framework_TestCase { - public function testRandomidDuplicates() + public function testLength() + { + $this->assertEquals(23, strlen(new Horde_Support_Randomid())); + } + + public function testDuplicates() { $values = array(); $cnt = 0; @@ -33,5 +37,4 @@ class Horde_Support_RandomidTest extends PHPUnit_Framework_TestCase $this->assertEquals(0, $cnt); } - } diff --git a/framework/Support/test/Horde/Support/UuidTest.php b/framework/Support/test/Horde/Support/UuidTest.php index 5b3d7b05e..721dcb574 100644 --- a/framework/Support/test/Horde/Support/UuidTest.php +++ b/framework/Support/test/Horde/Support/UuidTest.php @@ -3,30 +3,25 @@ * @category Horde * @package Support * @subpackage UnitTests - * @copyright 1999-2009 The Horde Project (http://www.horde.org/) + * @copyright 1999-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php */ /** - * @group support * @category Horde * @package Support * @subpackage UnitTests - * @copyright 1999-2009 The Horde Project (http://www.horde.org/) + * @copyright 1999-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php */ class Horde_Support_UuidTest extends PHPUnit_Framework_TestCase { - /** - * test instantiating a normal timer - */ - public function testUuidLength() + public function testLength() { - $uuid = strval(new Horde_Support_Uuid()); - $this->assertEquals(36, strlen($uuid)); + $this->assertEquals(36, strlen(new Horde_Support_Uuid())); } - public function testUuidDuplicates() + public function testDuplicates() { $values = array(); $cnt = 0; @@ -42,5 +37,4 @@ class Horde_Support_UuidTest extends PHPUnit_Framework_TestCase $this->assertEquals(0, $cnt); } - }