Neos\Fusion\Tests\Functional\TypoScriptObjects\ContentCacheTest::cacheUsesGlobalCacheIdentifiersAsDefaultPrototypeForEntryIdentifier PHP Метод

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

    public function cacheUsesGlobalCacheIdentifiersAsDefaultPrototypeForEntryIdentifier()
    {
        $entriesWritten = array();
        $mockCache = $this->createMock(\Neos\Cache\Frontend\FrontendInterface::class);
        $mockCache->expects($this->any())->method('get')->will($this->returnValue(false));
        $mockCache->expects($this->any())->method('has')->will($this->returnValue(false));
        $mockCache->expects($this->atLeastOnce())->method('set')->will($this->returnCallback(function ($entryIdentifier, $data, $tags, $lifetime) use(&$entriesWritten) {
            $entriesWritten[$entryIdentifier] = array('tags' => $tags);
        }));
        $this->inject($this->contentCache, 'cache', $mockCache);
        $object = new TestModel(42, 'Object value 1');
        $view = $this->buildView();
        $view->setOption('enableContentCache', true);
        $view->setTypoScriptPath('contentCache/entryIdentifiersAreMergedWithGlobalIdentifiers');
        $view->assign('object', $object);
        $view->assign('site', 'site1');
        $firstRenderResult = $view->render();
        $this->assertSame('Cached segment|Object value 1', $firstRenderResult);
        // As the site should be added to the entry identifier because it is in the Neos.Fusion:GlobalCacheIdentifiers prototype, changing the value should give us a different identifier
        $view->assign('site', 'site2');
        $secondRenderResult = $view->render();
        $this->assertSame($firstRenderResult, $secondRenderResult);
        $this->assertCount(2, $entriesWritten);
        $this->assertEquals(array('49c7f1e2dde942ea9cc6c658a7ece943' => array('tags' => array('site1')), 'a932d6d5860b204e82079255e224c613' => array('tags' => array('site2'))), $entriesWritten);
    }