/** * @inheritDoc */ public function fetchWithNamespace($id, $namespaceId = null) { self::$stopwatch->start('doctrine_cache_extension_bundle'); $data = $this->cacheProviderDecorator->fetchWithNamespace($id, $namespaceId); self::$stopwatch->stop('doctrine_cache_extension_bundle'); self::$collectedData[self::$callId++] = new FetchWithNamespaceCacheCollectedData($id, $namespaceId, $data, self::$stopwatch); return $data; }
/** * {@inheritdoc} */ public function fetchWithNamespace($id, $namespaceId = null) { $start = $this->startQuery(); $data = $this->cacheProviderDecorator->fetchWithNamespace($id, $namespaceId); $stop = $this->stopQuery(); self::$collectedData[self::$callId++] = $this->create(CacheCollectedData::FETCH_WITH_NAMESPACE)->withData($data)->withId($id)->withNamespaceId($namespaceId)->withStart($start)->withStop($stop)->build(); return $data; }
/** * @test */ public function WithNamespaceId_FetchWithNamespace_ReturnData() { $this->emptyCacheProvider->save(CacheProviderMock::NAMESPACE_ID, CacheProviderMock::NAMESPACE_ID_VALUE); $this->emptyCacheProvider->save(CacheProviderMock::NAMESPACE_ID_VALUE . CacheProviderMock::ID, CacheProviderMock::NAMESPACE_DATA); $data = $this->emptyCacheProviderDecorator->fetchWithNamespace(CacheProviderMock::ID, CacheProviderMock::NAMESPACE_ID); $this->assertEquals(CacheProviderMock::NAMESPACE_DATA, $data); $this->assertTrue($this->emptyCacheProvider->doFetchHasBeenCalled); $this->assertStringStartsWith('[' . CacheProviderMock::NAMESPACE_ID_VALUE . CacheProviderMock::ID . ']', $this->emptyCacheProvider->id); }