$this->assertTrue(false!==self::$storage->read('backslash'),'->write() accepts backslash in URL');
$profile=newProfile('comma');
$profile->setUrl('127.0.0.1','http://foo.bar/,');
self::$storage->write($profile);
$this->assertTrue(false!==self::$storage->read('comma'),'->write() accepts comma in URL');
}
publicfunctiontestStoreDuplicateToken()
{
$profile=newProfile('token');
$profile->setUrl('http://example.com/');
$this->assertTrue(self::$storage->write($profile),'->write() returns true when the token is unique');
$profile->setUrl('http://example.net/');
$this->assertTrue(self::$storage->write($profile),'->write() returns true when the token is already present in the Memcache');
$this->assertEquals('http://example.net/',self::$storage->read('token')->getUrl(),'->write() overwrites the current profile data');
$this->assertCount(1,self::$storage->find('','',1000,''),'->find() does not return the same profile twice');
}
publicfunctiontestRetrieveByIp()
{
$profile=newProfile('token');
$profile->setIp('127.0.0.1');
$profile->setMethod('GET');
self::$storage->write($profile);
$this->assertEquals(count(self::$storage->find('127.0.0.1','',10,'GET')),1,'->find() retrieve a record by IP');
$this->assertEquals(count(self::$storage->find('127.0.%.1','',10,'GET')),0,'->find() does not interpret a "%" as a wildcard in the IP');
$this->assertEquals(count(self::$storage->find('127.0._.1','',10,'GET')),0,'->find() does not interpret a "_" as a wildcard in the IP');
}
publicfunctiontestRetrieveByUrl()
{
$profile=newProfile('simple_quote');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/\'');
$profile->setMethod('GET');
self::$storage->write($profile);
$profile=newProfile('double_quote');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/"');
$profile->setMethod('GET');
self::$storage->write($profile);
$profile=newProfile('backslash');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo\\bar/');
$profile->setMethod('GET');
self::$storage->write($profile);
$profile=newProfile('percent');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/%');
$profile->setMethod('GET');
self::$storage->write($profile);
$profile=newProfile('underscore');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/_');
$profile->setMethod('GET');
self::$storage->write($profile);
$profile=newProfile('semicolon');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/;');
$profile->setMethod('GET');
self::$storage->write($profile);
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo.bar/\'',10,'GET')),1,'->find() accepts single quotes in URLs');
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo.bar/"',10,'GET')),1,'->find() accepts double quotes in URLs');
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo\\bar/',10,'GET')),1,'->find() accepts backslash in URLs');
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo.bar/;',10,'GET')),1,'->find() accepts semicolon in URLs');
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo.bar/%',10,'GET')),1,'->find() does not interpret a "%" as a wildcard in the URL');
$this->assertEquals(count(self::$storage->find('127.0.0.1','http://foo.bar/_',10,'GET')),1,'->find() does not interpret a "_" as a wildcard in the URL');