Contao\CoreBundle\Test\Cache\ContaoCacheWarmerTest::testWarmUp PHP Метод

testWarmUp() публичный Метод

Tests the warmUp() method.
public testWarmUp ( )
    public function testWarmUp()
    {
        /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $connection */
        $connection = $this->getMock('Doctrine\\DBAL\\Connection', ['prepare', 'execute', 'fetch', 'query'], [], '', false);
        $connection->expects($this->any())->method('prepare')->willReturn($connection);
        $class1 = new \stdClass();
        $class1->language = 'en-US';
        $class2 = new \stdClass();
        $class2->language = 'en';
        $connection->expects($this->exactly(3))->method('fetch')->willReturnOnConsecutiveCalls($class1, $class2, false);
        $warmer = new ContaoCacheWarmer(new Filesystem(), new ResourceFinder($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'), new FileLocator($this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao'), $this->getRootDir() . '/vendor/contao/test-bundle/Resources/contao', $connection, $this->mockContaoFramework());
        $warmer->warmUp($this->getCacheDir());
        $this->assertFileExists($this->getCacheDir() . '/contao');
        $this->assertFileExists($this->getCacheDir() . '/contao/config');
        $this->assertFileExists($this->getCacheDir() . '/contao/config/autoload.php');
        $this->assertFileExists($this->getCacheDir() . '/contao/config/config.php');
        $this->assertFileExists($this->getCacheDir() . '/contao/config/templates.php');
        $this->assertFileExists($this->getCacheDir() . '/contao/dca');
        $this->assertFileExists($this->getCacheDir() . '/contao/dca/tl_test.php');
        $this->assertFileExists($this->getCacheDir() . '/contao/languages');
        $this->assertFileExists($this->getCacheDir() . '/contao/languages/en');
        $this->assertFileExists($this->getCacheDir() . '/contao/languages/en/default.php');
        $this->assertFileExists($this->getCacheDir() . '/contao/sql');
        $this->assertFileExists($this->getCacheDir() . '/contao/sql/tl_test.php');
        $this->assertContains("\$GLOBALS['TL_TEST'] = true;", file_get_contents($this->getCacheDir() . '/contao/config/config.php'));
        $this->assertContains(sprintf("'dummy' => '%s/vendor/contao/test-bundle/Resources/contao/templates'", strtr($this->getRootDir(), '\\', '/')), file_get_contents($this->getCacheDir() . '/contao/config/templates.php'));
        $this->assertContains("\$GLOBALS['TL_DCA']['tl_test'] = [\n", file_get_contents($this->getCacheDir() . '/contao/dca/tl_test.php'));
        $this->assertContains("\$GLOBALS['TL_LANG']['MSC']['first']", file_get_contents($this->getCacheDir() . '/contao/languages/en/default.php'));
        $this->assertContains("\$this->arrFields = array (\n  'id' => 'int(10) unsigned NOT NULL auto_increment',\n);", file_get_contents($this->getCacheDir() . '/contao/sql/tl_test.php'));
    }