public function aSessionCanBeTaggedAndBeRetrievedAgainByTheseTags()
{
$metaDataCache = $this->createCache('Meta');
$storageCache = $this->createCache('Storage');
$otherSession = new Session();
$this->inject($otherSession, 'bootstrap', $this->mockBootstrap);
$this->inject($otherSession, 'settings', $this->settings);
$this->inject($otherSession, 'metaDataCache', $metaDataCache);
$this->inject($otherSession, 'storageCache', $storageCache);
$this->inject($otherSession, 'objectManager', $this->mockObjectManager);
$otherSession->initializeObject();
$otherSession->start();
$taggedSession = new Session();
$this->inject($taggedSession, 'bootstrap', $this->mockBootstrap);
$this->inject($taggedSession, 'settings', $this->settings);
$this->inject($taggedSession, 'metaDataCache', $metaDataCache);
$this->inject($taggedSession, 'storageCache', $storageCache);
$this->inject($taggedSession, 'objectManager', $this->mockObjectManager);
$taggedSession->initializeObject();
$taggedSession->start();
$taggedSessionId = $taggedSession->getId();
$otherSession->putData('foo', 'bar');
$taggedSession->putData('foo', 'baz');
$taggedSession->addTag('SampleTag');
$taggedSession->addTag('AnotherTag');
$otherSession->close();
$taggedSession->close();
$sessionManager = new SessionManager();
$this->inject($sessionManager, 'metaDataCache', $metaDataCache);
$retrievedSessions = $sessionManager->getSessionsByTag('SampleTag');
$this->assertSame($taggedSessionId, $retrievedSessions[0]->getId());
$this->assertEquals(['SampleTag', 'AnotherTag'], $retrievedSessions[0]->getTags());
}