示例#1
0
 public function testOutputCache()
 {
     $cache = $this->_cms['cache'];
     $randKey = uniqid('', true);
     $output = 'output-' . $randKey;
     $keyId = 'key-' . $randKey;
     // save to cache
     ob_start();
     if (!$cache->start($keyId, 'default', true)) {
         echo $output;
         // some output
         $cache->end($keyId, 'default');
     }
     $outputBeforeCache = ob_get_contents();
     ob_end_clean();
     // check cached data
     ob_start();
     if (!$cache->start($keyId, 'default', true)) {
         echo 'Some new data';
         // cache mut be valid still
         $cache->end($keyId, 'default');
     }
     $outputAfterCache = ob_get_contents();
     ob_end_clean();
     isSame($outputBeforeCache, $outputAfterCache);
 }
示例#2
0
 public function testNocache()
 {
     $result = $this->helper->request(__METHOD__, array('test-response-nocache' => 1));
     isSame('no-cache', $result->find('headers.pragma'));
     isContain('no-store', $result->find('headers.cache-control'));
     isContain('no-cache', $result->find('headers.cache-control'));
     isContain('must-revalidate', $result->find('headers.cache-control'));
 }
示例#3
0
 public function testEquals()
 {
     is(1, true);
     is(array(1, 2, 3), array(1, 2, 3));
     is(array('a' => 1, 'b' => 2), array('b' => 2, 'a' => 1));
     isNot(1, 2);
     isSame(array(1, 2, 3), array(1, 2, 3));
     isNotSame(array(1, 2, 3), array(3, 2, 1));
     isKey('test', array('test' => true));
     isNotKey('undefined', array('test' => true));
     isAttr('test', (object) array('test' => true));
     isNotAttr('undefined', (object) array('test' => true));
     isBatch(array(array(1, 1), array(2, 2)));
 }
示例#4
0
 public function testHeader()
 {
     $req = $this->_cms['request'];
     isSame('JBZoo PHPUnit Tester', $req->getHeader('user_agent'));
     isSame('jbzoo-phpunit-tester', $req->getHeader('user_agent', 'null', 'alias'));
     isSame('value', $req->getHeader('undefined', 'value'));
     isSame('value123', $req->getHeader('undefined', 'value', function ($value) {
         return $value . '123';
     }));
 }
示例#5
0
 public function testCSSCode()
 {
     $uniq = uniqid('', true);
     $result = $this->helper->request(__METHOD__, array('test-header-csscode' => $uniq));
     isSame(200, $result->code);
     isContain($uniq, $result->body);
 }
/**
 * @param mixed $compare
 * @return \Closure
 */
function isNotSame($compare)
{
    return negate(isSame($compare));
}