Beispiel #1
0
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";
    }
}
 /**
  * @Then /^(?:|I )should not reach my rate limit$/
  */
 public function iShouldNotReachMyRateLimit()
 {
     $remainingCalls = $this->client->getHttpClient()->remainingCalls;
     assertNotNull($remainingCalls);
     assertTrue(5000 > $remainingCalls);
     assertTrue(0 < $remainingCalls);
 }
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');
}
Beispiel #4
0
 public function testCanValidatePasswordWithSymbols()
 {
     $validator = $this->createValidator();
     $validator->setMinSymbols(2);
     assertTrue($validator->isValid('!pass.word'));
     assertFalse($validator->isValid('1N3RD007'));
 }
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&amp;f=paths_prepend.css,styles.css&amp;{$maxTime}";
    $actual = Minify_HTML_Helper::getUri(array($uri1, $uri2));
    $passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given URIs');
    $expected = "/min/b=_test_files/css&amp;f=paths_prepend.css,styles.css&amp;{$maxTime}";
    $actual = Minify_HTML_Helper::getUri(array($file1, $file2));
    $passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given filepaths');
    $expected = "/min/g=notRealGroup&amp;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&amp;{$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;
}
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";
        }
    }
}
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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC');\n    }\n    ";
    $minExpected = "div.image{width:100px;height:100px;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC')}";
    // fails with java.lang.StackOverflowError as of Yui 2.4.6
    // unfortunately 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";
    }
}
        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());
            
        }
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;
    }
}
 /**
  * @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);
 }
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";
    }
}
 /**
  * @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'));
 }
Beispiel #13
0
 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);
 }
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";
        }
    }
}
Beispiel #15
0
 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);
 }
Beispiel #16
0
 public function test_ensure_interpret_makes_deleted_at()
 {
     $this->ScaffoldingManager->interpretInputData($this->input);
     assertEquals(count($this->input['fields']), 5);
     assertTrue(isset($this->input['fields'][4]));
     assertEquals($this->input['fields'][2]['name'], 'deleted_at');
 }
function test_Minify_Cache_File()
{
    $data = str_repeat(md5(time()) . 'í', 100);
    // 3400 bytes in UTF-8
    $id = 'Minify_test_cache_noLock';
    $prefix = 'Minify_Cache_File : ';
    $cache = new Minify_Cache_File();
    echo "NOTE: Minify_Cache_File : path is set to: '" . $cache->getPath() . "'.\n";
    assertTrue(true === $cache->store($id, $data), $prefix . 'store');
    assertTrue(countBytes($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('', true);
    assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock');
    assertTrue(countBytes($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');
}
 /**
  * @test
  */
 public function addingAnnotationWritesCacheFile()
 {
     $annotations = new Annotations('someTarget');
     AnnotationCache::put($annotations);
     AnnotationCache::__shutdown();
     assertTrue(file_exists(vfsStream::url('root/annotations.cache')));
 }
Beispiel #19
0
 public function test_it_disables()
 {
     $DvsMagicMode = new DvsMagicMode();
     $DvsMagicMode->disable(true);
     assertFalse($DvsMagicMode->enabled());
     assertTrue($DvsMagicMode->disabled());
 }
 public function testServiceAliasDefinition()
 {
     $definition = new ServiceDefinition('service_name', ['service' => __CLASS__]);
     assertTrue($definition->isAlias());
     assertFalse($definition->isFactory());
     assertSame(__CLASS__, $definition->getClass());
 }
Beispiel #21
0
 function testHtml()
 {
     $expectations = array(" - foo" => "<ul><li>foo</li></ul>");
     foreach ($expectations as $comcode => $html) {
         $actual = comcode_to_tempcode($comcode);
         assertTrue(preg_replace('#\\s#', '', $html) == preg_replace('#\\s#', '', $actual->evaluate()));
     }
 }
 public function test_it_creates_table_if_table_doesnt_exist()
 {
     $this->MockMigrationScaffolding->shouldReceive('runMigration')->times(1)->andReturn(true);
     $this->MockMigrationScaffolding->shouldReceive('saveMigration')->times(1)->andReturn(true);
     $this->MockMigrationScaffolding->shouldReceive('getMigrationTemplatePath')->times(1)->andReturn('src/scaffolding/migrations/create_model.txt');
     $result = $this->MockMigrationScaffolding->buildAndRun($this->constants, $this->fields);
     assertTrue($result);
 }
Beispiel #23
0
 public function test_it_can_store_simple_var()
 {
     $name = 'template.name';
     $var = array('var_name' => 'var', 'class_path' => 'Name\\Space\\Class', 'method_name' => 'find', 'params' => array());
     $configContents = array('template.name' => array('vars' => array('var' => 'Name\\Space\\Class.find')));
     $this->ConfigFileManager->shouldReceive('getAppOnly')->times(1)->with('devise.templates')->andReturn(array('template.name' => array('vars' => array())))->shouldReceive('saveToFile')->with($configContents, 'templates')->times(1)->andReturn(true);
     assertTrue($this->TemplatesManager->storeNewVariable($name, $var));
 }
Beispiel #24
0
function assertEquals($value, $expected)
{
    if (!assertTrue($value == $expected)) {
        echo " <strong>Should be</strong> [{$expected}]";
        echo " <strong>but found</strong> [";
        echo highlitesDifferentWords($expected, $value);
        echo "]";
    }
}
 function testChangingPassword()
 {
     $userB4 = $this->loginAsNormalUser();
     assertFalse(Passwords\isValid('n00p@ss', $userB4->passwordEncrypted));
     $this->get('/account/change-password');
     $this->submitForm($this->getForm('change-password-form'), array('current-password' => 'abc123', 'password' => 'n00p@ss', 'confirm-password' => 'n00p@ss'));
     $userAfter = User::loadFromID($userB4->id);
     assertTrue(Passwords\isValid('n00p@ss', $userAfter->passwordEncrypted));
 }
Beispiel #26
0
 /**
  * @Then /^I should find restaurant "([^"]*)"$/
  */
 public function iShouldFindRestaurant($name)
 {
     $restaurnat = $this->getRepository('TableRestaurantBundle:Restaurant')->findOneByName($name);
     $found = false;
     if ($restaurnat) {
         $found = true;
     }
     assertTrue($found);
 }
Beispiel #27
0
function activityLog_handler($handler = null)
{
    static $_handler;
    assertTrue(isset($_handler) xor isset($handler));
    if (!isset($_handler)) {
        $_handler = $handler;
    }
    return $_handler;
}
 /**
  * @Then /^I should see the "([^"]*)" form$/
  * @param string $id HTML ID of form
  */
 public function iShouldSeeTheForm($id)
 {
     /** @var DocumentElement $page */
     $page = $this->getSession()->getPage();
     $form = $this->retry(function () use($page, $id) {
         return $page->find('css', "form#{$id}");
     });
     assertNotNull($form, "form with id {$id} could not be found");
     assertTrue($form->isVisible(), "form with id {$id} is not visible");
 }
Beispiel #29
0
 /**
  * @Given /^bundles are indexed$/
  */
 public function bundlesAreIndexed()
 {
     assertTrue($this->isSolrEnabled());
     $bundles = $this->getContainer()->get('doctrine')->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle')->findAll();
     $indexer = $this->getContainer()->get('knp_bundles.indexer.solr');
     $indexer->deleteBundlesIndexes();
     foreach ($bundles as $bundle) {
         $indexer->indexBundle($bundle);
     }
 }
Beispiel #30
0
function includedFile($file = null)
{
    static $files = array();
    if ($file === null) {
        return array_unique(array_merge(get_included_files(), $files));
    }
    version_assert and assertTrue(is_string($file));
    version_assert and assertTrue(is_file($file));
    $files[] = realpath($file);
}