PhroznTest\Site\View\JsTest::testViewCompiling PHP Method

testViewCompiling() public method

public testViewCompiling ( )
    public function testViewCompiling()
    {
        $jsIn = dirname(__FILE__) . '/scripts/jquery/test.js';
        $jsOut = dirname(__FILE__) . '/scripts/jquery/test.js';
        $path = dirname(__FILE__) . '/out';
        $view = new View($jsIn, $path);
        $view->setInputRootDir(dirname(__FILE__));
        $this->assertSame('test.js', basename($view->getInputFile()));
        $this->assertSame('test.js', basename($view->getOutputFile()));
        @unlink($path . '/scripts/jquery/test.js');
        $this->assertFalse(is_readable($path . '/scripts/jquery/test.js'));
        $rendered = $view->compile();
        $this->assertTrue(is_readable($path . '/scripts/jquery/test.js'));
        $loaded = file_get_contents($jsOut);
        $this->assertSame(trim($loaded), trim($rendered));
        // load from out
        $loaded = file_get_contents($path . '/scripts/jquery/test.js');
        $this->assertSame(trim($loaded), trim($rendered));
        // cleanup
        unlink($path . '/scripts/jquery/test.js');
    }