Neos\Flow\Tests\Unit\Session\SessionTest::shutdownChecksIfSessionStillExistsInStorageCacheBeforeWritingData PHP Method

shutdownChecksIfSessionStillExistsInStorageCacheBeforeWritingData() public method

    public function shutdownChecksIfSessionStillExistsInStorageCacheBeforeWritingData()
    {
        $metaDataCache = $this->createCache('Meta');
        $storageCache = $this->createCache('Storage');
        $session = new Session();
        $this->inject($session, 'bootstrap', $this->mockBootstrap);
        $this->inject($session, 'objectManager', $this->mockObjectManager);
        $this->inject($session, 'settings', $this->settings);
        $this->inject($session, 'metaDataCache', $metaDataCache);
        $this->inject($session, 'storageCache', $storageCache);
        $session->initializeObject();
        // Start a "local" session and store some data:
        $session->start();
        $sessionIdentifier = $session->getId();
        $session->putData('foo', 'bar');
        $session->close();
        $sessionInfo = $metaDataCache->get($sessionIdentifier);
        // Simulate a remote server referring to the same session:
        $remoteSession = new Session($sessionIdentifier, $sessionInfo['storageIdentifier'], $sessionInfo['lastActivityTimestamp']);
        $this->inject($remoteSession, 'bootstrap', $this->mockBootstrap);
        $this->inject($remoteSession, 'objectManager', $this->mockObjectManager);
        $this->inject($remoteSession, 'settings', $this->settings);
        $this->inject($remoteSession, 'metaDataCache', $metaDataCache);
        $this->inject($remoteSession, 'storageCache', $storageCache);
        $remoteSession->initializeObject();
        // Resume the local session and add more data:
        $this->assertTrue($metaDataCache->has($sessionIdentifier));
        $session->resume();
        $session->putData('baz', 'quux');
        // The remote server destroys the local session in the meantime:
        $remoteSession->destroy();
        // Close the local session – this must not write any data because the session doesn't exist anymore:
        $session->close();
        $this->assertFalse($metaDataCache->has($sessionIdentifier));
    }
SessionTest