public function testResolveHashByUrl() { $url = 'http://www.zurmo.com'; $hash = ShortUrl::resolveHashByUrl($url); $this->assertEquals(ShortUrl::HASH_LENGTH, strlen($hash)); $shortUrls = ShortUrl::getAll(); $this->assertCount(1, $shortUrls); $this->assertEquals($url, $shortUrls[0]->url); //The same url should return the same hash and not create a new one $hash2 = ShortUrl::resolveHashByUrl($url); $this->assertEquals($hash, $hash2); $this->assertCount(1, ShortUrl::getAll()); //New url should have new hash $url2 = 'http://www.zurmo.org'; $hash2 = ShortUrl::resolveHashByUrl($url2); $this->assertNotEquals($hash, $hash2); $this->assertCount(2, ShortUrl::getAll()); ShortUrl::deleteAll(); }