本文整理汇总了PHP中assertTrue函数的典型用法代码示例。如果您正苦于以下问题:PHP assertTrue函数的具体用法?PHP assertTrue怎么用?PHP assertTrue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertTrue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_JSMinPlus
function test_JSMinPlus()
{
global $thisDir;
$src = file_get_contents($thisDir . '/_test_files/js/condcomm.js');
$minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js');
$minOutput = JSMinPlus::minify($src);
$passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
}
return;
$src = file_get_contents($thisDir . '/_test_files/js/before.js');
$minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js');
$minOutput = JSMinPlus::minify($src);
$passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
}
$src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
$minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js');
$minOutput = JSMinPlus::minify($src);
$passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
}
}
示例2: iShouldNotReachMyRateLimit
/**
* @Then /^(?:|I )should not reach my rate limit$/
*/
public function iShouldNotReachMyRateLimit()
{
$remainingCalls = $this->client->getHttpClient()->remainingCalls;
assertNotNull($remainingCalls);
assertTrue(5000 > $remainingCalls);
assertTrue(0 < $remainingCalls);
}
示例3: test_Minify_Cache_File
function test_Minify_Cache_File()
{
global $minifyCachePath;
$data = str_repeat(md5(time()), 160);
$id = 'Minify_test_cache_noLock';
$prefix = 'Minify_Cache_File : ';
$cache = new Minify_Cache_File($minifyCachePath);
assertTrue(true === $cache->store($id, $data), $prefix . 'store');
assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
ob_start();
$cache->display($id);
$displayed = ob_get_contents();
ob_end_clean();
assertTrue($data === $displayed, $prefix . 'display');
assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
// test with locks
$id = 'Minify_test_cache_withLock';
$cache = new Minify_Cache_File($minifyCachePath, true);
assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock');
assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
ob_start();
$cache->display($id);
$displayed = ob_get_contents();
ob_end_clean();
assertTrue($data === $displayed, $prefix . 'display w/ lock');
assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock');
}
示例4: testCanValidatePasswordWithSymbols
public function testCanValidatePasswordWithSymbols()
{
$validator = $this->createValidator();
$validator->setMinSymbols(2);
assertTrue($validator->isValid('!pass.word'));
assertFalse($validator->isValid('1N3RD007'));
}
示例5: test_Minify_HTML_Helper
function test_Minify_HTML_Helper()
{
global $thisDir;
$realDocRoot = $_SERVER['DOCUMENT_ROOT'];
$_SERVER['DOCUMENT_ROOT'] = $thisDir;
$file1 = $thisDir . '/_test_files/css/paths_prepend.css';
$file2 = $thisDir . '/_test_files/css/styles.css';
$maxTime = max(filemtime($file1), filemtime($file2));
$uri1 = '//_test_files/css/paths_prepend.css';
$uri2 = '//_test_files/css/styles.css';
$expected = "/min/b=_test_files/css&f=paths_prepend.css,styles.css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri(array($uri1, $uri2));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given URIs');
$expected = "/min/b=_test_files/css&f=paths_prepend.css,styles.css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri(array($file1, $file2));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given filepaths');
$expected = "/min/g=notRealGroup&debug";
$actual = Minify_HTML_Helper::getUri('notRealGroup', array('debug' => true));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : non-existent group & debug');
$expected = "/myApp/min/?g=css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri('css', array('rewriteWorks' => false, 'minAppUri' => '/myApp/min/', 'groupsConfigFile' => $thisDir . '/_test_files/htmlHelper_groupsConfig.php'));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : existing group');
$utilsFile = dirname(__DIR__) . '/min/utils.php';
if (is_file($utilsFile)) {
require_once $utilsFile;
$fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5;
$obj = new Minify_Source(array('id' => '1', 'content' => '1', 'lastModified' => $fiveSecondsAgo));
$output = Minify_mtime(array($uri1, $uri2, $obj));
$passed = assertTrue($output === $fiveSecondsAgo, 'utils.php : Minify_mtime w/ files & obj');
$obj = new Minify_Source(array('id' => '2', 'content' => '2', 'lastModified' => strtotime('2000-01-01')));
$output = Minify_mtime(array($obj, 'css'), $thisDir . '/_test_files/htmlHelper_groupsConfig.php');
$passed = assertTrue($output === $maxTime, 'utils.php : Minify_mtime w/ obj & group');
}
$_SERVER['DOCUMENT_ROOT'] = $realDocRoot;
}
示例6: test_HTML
function test_HTML()
{
global $thisDir;
$src = file_get_contents($thisDir . '/_test_files/html/before.html');
$minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
$time = microtime(true);
$minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
$time = microtime(true) - $time;
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
if ($passed) {
echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
} else {
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
}
}
$src = file_get_contents($thisDir . '/_test_files/html/before2.html');
$minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
$time = microtime(true);
$minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')));
$time = microtime(true) - $time;
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
if ($passed) {
echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
} else {
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
}
}
}
示例7: test_Minify_YuiCSS
function test_Minify_YuiCSS()
{
if (!is_file(MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE)) {
echo " Minify_YUICompressor : To test this, install the .jar file and customize the constant in:\n";
echo " " . __FILE__ . "\n";
return;
}
Minify_YUICompressor::$jarFile = MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE;
Minify_YUICompressor::$tempDir = sys_get_temp_dir();
$src = "/* stack overflow test */\n div.image {\n width: 100px;\n height: 100px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRD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error output is not caught from yui, so have to guess
try {
$minOutput = Minify_YUICompressor::minifyCss($src);
echo " Minify_YUICompressor : Correctly handles input which caused stack overflow in 2.4.6\n";
} catch (Exception $e) {
assertTrue($e->getMessage() == 'Minify_YUICompressor : YUI compressor execution failed.', 'Minify_YUICompressor : got expected Exception');
}
try {
$options = array('stack-size' => '2m');
$minOutput = Minify_YUICompressor::minifyCss($src, $options);
} catch (Exception $e) {
assertTrue(false, $e->getMessage());
$minOutput = false;
}
$passed = assertTrue($minExpected == $minOutput, 'Minify_YUICompressor : Overall');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
}
}
示例8: testState
public function testState()
{
assertNull($this->objMath->getFirstOperand());
assertNull($this->objMath->getSecondOperand());
assertNull($this->objMath->getFirstOperator());
assertNull($this->objMath->getSecondOperator());
assertFalse( $this->objMath->validate() );
$this->objMath->setFirstOperand('5');
$this->objMath->setFirstOperator('+');
$this->objMath->setSecondOperand('2');
assertNotNull($this->objMath->getFirstOperand());
assertNotNull($this->objMath->getSecondOperand());
assertNotNull($this->objMath->getFirstOperator());
assertNotNull($this->objMath->getSecondOperator());
assertTrue( $this->objMath->validate() );
$this->objMath->clear( );
assertNull($this->objMath->getFirstOperand());
assertNull($this->objMath->getSecondOperand());
assertNull($this->objMath->getFirstOperator());
assertNull($this->objMath->getSecondOperator());
}
示例9: test_Minify_CSS_UriRewriter
function test_Minify_CSS_UriRewriter()
{
global $thisDir;
Minify_CSS_UriRewriter::$debugText = '';
$in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
$expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
$actual = Minify_CSS_UriRewriter::rewrite($in, $thisDir . '/_test_files/css_uriRewriter', $thisDir);
$passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Input:\n\n{$in}\n";
echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
if (!$passed) {
echo "---Expected: " . strlen($expected) . " bytes\n\n{$expected}\n\n\n";
}
// show debugging only when test run directly
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
}
Minify_CSS_UriRewriter::$debugText = '';
$in = '../../../../assets/skins/sam/sprite.png';
$exp = '/yui/assets/skins/sam/sprite.png';
$actual = Minify_CSS_UriRewriter::rewriteRelative($in, 'sf_root_dir\\web\\yui\\menu\\assets\\skins\\sam', 'sf_root_dir\\web');
$passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Input:\n\n{$in}\n";
echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
if (!$passed) {
echo "---Expected: " . strlen($exp) . " bytes\n\n{$exp}\n\n\n";
}
// show debugging only when test run directly
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
}
}
示例10: testParse
/**
* @test
* @profile fork
*/
public function testParse()
{
split_time('Reset');
$annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
$annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
split_time('Invoke Annotations$hasMethodAnnotation(name)');
assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
split_time('Invoke Annotations$hasMethodAnnotation(name)');
assertTrue($annotations->hasTypeAnnotation('package'));
split_time('Invoke Annotations$hasMethodAnnotation(package)');
assertFalse($annotations->hasTypeAnnotation('version'));
split_time('Invoke Annotations$hasMethodAnnotation(version)');
assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
split_time('Invoke Annotations$hasMethodAnnotation(poke)');
assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
split_time('Invoke Annotations$hasMethodAnnotation(poke)');
$pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
split_time('Invoke Annotations$getMethodAnnotation(poke)');
$pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
split_time('Invoke Annotations$getMethodAnnotation(poke)');
$annotations = Annotations::get(__CLASS__);
split_time('Invoke Annotations::get(' . __CLASS__ . ')');
$annotations = Annotations::get(__CLASS__);
split_time('Invoke Annotations::get(' . __CLASS__ . ')');
assertEquals('poke', $pokeName->value);
}
示例11: test_Minify_JS_ClosureCompiler
function test_Minify_JS_ClosureCompiler()
{
global $thisDir;
$src = "\n(function (window, undefined){\n function addOne(input) {\n return 1 + input;\n }\n window.addOne = addOne;\n window.undefined = undefined;\n})(window);\n ";
$minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
$minOutput = Minify_JS_ClosureCompiler::minify($src);
if (false !== strpos($minOutput, 'Error(22): Too many compiles')) {
echo "!NOTE: Too many recent calls to Closure Compiler API to test.\n";
return;
}
$passed = assertTrue($minExpected == $minOutput, 'Minify_JS_ClosureCompiler : Overall');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
}
$src = "function blah({ return 'blah';} ";
$exc = null;
try {
$minOutput = Minify_JS_ClosureCompiler::minify($src);
} catch (Exception $e) {
$exc = $e;
}
$passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n";
}
}
示例12: mockFactory
/**
* @test
* @profile
* @ignore(ignoreUntilFixed)
*/
public function mockFactory()
{
$mockException = Mock_Factory::mock('Components\\Test_Exception', array('test/unit/case/mock', 'Mocked Exception.'));
$mockExceptionDefault = Mock_Factory::mock('Components\\Test_Exception');
$mockRunner = Mock_Factory::mock('Components\\Test_Runner');
$mockListener = Mock_Factory::mock('Components\\Test_Listener');
$mockListener->when('onInitialize')->doReturn(true);
$mockListener->when('onExecute')->doReturn(true);
$mockListener->when('onTerminate')->doNothing();
assertTrue($mockListener->onExecute($mockRunner));
assertTrue($mockListener->onInitialize($mockRunner));
$mockLL->onTerminate($mockRunner);
assertEquals('test/unit/case/mock', $mockException->getNamespace());
assertEquals('Mocked Exception.', $mockException->getMessage());
assertEquals('test/exception', $mockExceptionDefault->getNamespace());
assertEquals('Test exception.', $mockExceptionDefault->getMessage());
$mockBindingModule = Mock_Factory::mock('Components\\Binding_Module');
$mockBindingModule->when('bind')->doAnswer(function (Binding_Module $self_, $type_) {
echo "Bound {$type_}\r\n";
return $self_->bind($type_);
});
$mockBindingModule->when('configure')->doAnswer(function (Binding_Module $self_) {
$self_->bind('Components\\Test_Runner')->toInstance(Test_Runner::get());
$self_->bind(Integer::TYPE)->toInstance(22)->named('boundInteger');
});
$injector = Injector::create($mockBindingModule);
assertSame(Test_Runner::get(), $injector->resolveInstance('Components\\Test_Runner'));
assertEquals(22, $injector->resolveInstance(Integer::TYPE, 'boundInteger'));
}
示例13: testExistingChildren
public function testExistingChildren()
{
// --- test load
$this->createModels(CustomerDetail::class, []);
$this->createModels(Customer::class, [['name' => 'Frank', 'surname' => 'Sinatra']]);
$details = new CustomerDetail();
$source = Datasource::make(new CustomerDetail());
$source['id'] = 1;
$source['biography'] = 'A nice life!';
$source['accepts_cookies'] = 0;
$source['customer_id'] = 1;
$details->id = 1;
$details->biography = 'A nice life!';
$details->accepts_cookies = 0;
$details->customer_id = 1;
$source->save();
assertTrue(isset($source['customer']));
assertInstanceOf(Customer::class, $source['customer']);
assertModelArrayEqual(Customer::all()->toArray(), [$source['customer']->toArray()]);
// compare with how eloquent behaves:
$this->createModels(CustomerDetail::class, []);
$details->save();
assertFalse(isset($details->customer));
// always false!
assertInstanceOf(Customer::class, $details->customer);
}
示例14: test_HTTP_ConditionalGet
function test_HTTP_ConditionalGet()
{
global $thisDir;
$lmTime = time() - 900;
$gmtTime = gmdate('D, d M Y H:i:s \\G\\M\\T', $lmTime);
$tests = array(array('desc' => 'client has valid If-Modified-Since', 'inm' => null, 'ims' => $gmtTime, 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime}\"", 'Cache-Control' => 'max-age=0, private', '_responseCode' => 'HTTP/1.0 304 Not Modified', 'isValid' => true)), array('desc' => 'client has valid If-Modified-Since with trailing semicolon', 'inm' => null, 'ims' => $gmtTime . ';', 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime}\"", 'Cache-Control' => 'max-age=0, private', '_responseCode' => 'HTTP/1.0 304 Not Modified', 'isValid' => true)), array('desc' => 'client has valid ETag (non-encoded version)', 'inm' => "\"badEtagFoo\", \"pri{$lmTime}\"", 'ims' => null, 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime}\"", 'Cache-Control' => 'max-age=0, private', '_responseCode' => 'HTTP/1.0 304 Not Modified', 'isValid' => true)), array('desc' => 'client has valid ETag (gzip version)', 'inm' => "\"badEtagFoo\", \"pri{$lmTime};gz\"", 'ims' => null, 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime};gz\"", 'Cache-Control' => 'max-age=0, private', '_responseCode' => 'HTTP/1.0 304 Not Modified', 'isValid' => true)), array('desc' => 'no conditional get', 'inm' => null, 'ims' => null, 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime};gz\"", 'Cache-Control' => 'max-age=0, private', 'isValid' => false)), array('desc' => 'client has invalid ETag', 'inm' => '"pri' . ($lmTime - 300) . '"', 'ims' => null, 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime};gz\"", 'Cache-Control' => 'max-age=0, private', 'isValid' => false)), array('desc' => 'client has invalid If-Modified-Since', 'inm' => null, 'ims' => gmdate('D, d M Y H:i:s \\G\\M\\T', $lmTime - 300), 'exp' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => $gmtTime, 'ETag' => "\"pri{$lmTime};gz\"", 'Cache-Control' => 'max-age=0, private', 'isValid' => false)));
foreach ($tests as $test) {
// setup env
if (null === $test['inm']) {
unset($_SERVER['HTTP_IF_NONE_MATCH']);
} else {
$_SERVER['HTTP_IF_NONE_MATCH'] = get_magic_quotes_gpc() ? addslashes($test['inm']) : $test['inm'];
}
if (null === $test['ims']) {
unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
} else {
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $test['ims'];
}
$exp = $test['exp'];
$cg = new HTTP_ConditionalGet(array('lastModifiedTime' => $lmTime, 'encoding' => 'x-gzip'));
$ret = $cg->getHeaders();
$ret['isValid'] = $cg->cacheIsValid;
$passed = assertTrue($exp == $ret, 'HTTP_ConditionalGet : ' . $test['desc']);
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n--- INM = {$test['inm']} / IMS = {$test['ims']}\n";
echo "Expected = " . preg_replace('/\\s+/', ' ', var_export($exp, 1)) . "\n";
echo "Returned = " . preg_replace('/\\s+/', ' ', var_export($ret, 1)) . "\n\n";
}
}
}
示例15: test_sanity_check_passes
public function test_sanity_check_passes()
{
$this->MockSanityChecksScaffolding->shouldReceive('checkViewsDirectory')->times(1)->andReturn(true);
$this->MockSanityChecksScaffolding->shouldReceive('checkSrcDirectory')->times(1)->andReturn(true);
$result = $this->MockSanityChecksScaffolding->runSanityCheck($this->constants, [], []);
assertTrue($result);
}