You are here

public function FeedsHTTPCacheTest::testGet in Feeds 7.2

@covers FeedsHTTPCache::get().

File

tests/FeedsHTTPCacheTest.test, line 195

Class

FeedsHTTPCacheTest
@coversDefaultClass FeedsHTTPCache @group feeds

Code

public function testGet() {
  $cid = static::randomName();
  $file_data = static::randomName();

  // Save a file to the cache dir.
  $dir = static::FEEDS_CACHE_DIR;
  file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
  file_put_contents(static::FEEDS_CACHE_DIR . '/' . $cid, $file_data);

  // Manually create a record in cache_feeds_http table.
  $this
    ->createCacheRecord($cid);

  // Assert that the item can be get from cache.
  $item = $this->cache
    ->get($cid);
  $this
    ->assertEqual($file_data, $item->data
    ->getFileContents());
}