public function createCacheSegmentAndProcessCacheSegmentsDoesWorkWithCacheSegmentTokensInContent()
{
$contentCache = new ContentCache();
$mockSecurityContext = $this->createMock(Context::class);
$this->inject($contentCache, 'securityContext', $mockSecurityContext);
$this->inject($contentCache, 'parser', new CacheSegmentParser());
$mockCache = $this->createMock(FrontendInterface::class);
$this->inject($contentCache, 'cache', $mockCache);
$invalidContent = 'You should probably not use ' . ContentCache::CACHE_SEGMENT_START_TOKEN . ', ' . ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN . ' or ' . ContentCache::CACHE_SEGMENT_END_TOKEN . ' inside your content.';
$content = $contentCache->createCacheSegment($invalidContent, 'some.typoscripth.path', array('node' => 'foo'), array('mytag1', 'mytag2'));
$validContent = 'But the cache should not fail because of it.';
$content .= $contentCache->createCacheSegment($validContent, 'another.typoscripth.path', array('node' => 'bar'), array('mytag2'), 86400);
$mockCache->expects($this->at(0))->method('set')->with($this->anything(), $invalidContent, array('mytag1', 'mytag2'), null);
$mockCache->expects($this->at(1))->method('set')->with($this->anything(), $validContent, array('mytag2'), 86400);
$output = $contentCache->processCacheSegments($content);
$this->assertSame($invalidContent . $validContent, $output);
}