public function testSuperUserAllDefaultControllerActions() { $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $hash = ShortUrl::resolveHashByUrl('http://www.zurmo.com'); $this->setGetArray(array('hash' => $hash)); $url = $this->runControllerWithRedirectExceptionAndGetUrl('zurmo/shortUrl/redirect/'); $this->assertEquals('http://www.zurmo.com', $url); }
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(); }
public static function createShortUrl($url) { assert('is_string($url)'); $hash = ShortUrl::resolveHashByUrl($url); return Yii::app()->createAbsoluteUrl('zurmo/shortUrl/redirect/', array('hash' => $hash)); }