Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken CacheResolver tests (#650) #655

Merged
merged 1 commit into from
Nov 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Tests/Imagine/Cache/Resolver/CacheResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,16 @@ public function testRemoveSinglePathCacheOnRemove()
$cacheResolver->resolve($this->path, $this->filter);

/*
* Three items:
* Checking 2 items:
* * The result of one resolve execution.
* * The index of entity.
* * The array cache meta info
*/
$this->assertCount(3, $this->readAttribute($cache, 'data'));
$this->assertCount(2, $this->getCacheEntries($cache));

$cacheResolver->remove(array($this->path), array($this->filter));

// Cache including index has been removed.
$this->assertCount(1, $this->readAttribute($cache, 'data'));
$this->assertCount(0, $this->getCacheEntries($cache));
}

public function testRemoveAllFilterCacheOnRemove()
Expand All @@ -167,16 +166,33 @@ public function testRemoveAllFilterCacheOnRemove()
$cacheResolver->resolve('aPathBar', 'thumbnail_100x100');

/*
* Seven items:
* Checking 6 items:
* * The result of four resolve execution.
* * The index of two entities.
* * The array cache meta info
*/
$this->assertCount(7, $this->readAttribute($cache, 'data'));
$this->assertCount(6, $this->getCacheEntries($cache));

$cacheResolver->remove(array(), array('thumbnail_233x233'));

// Cache including index has been removed.
$this->assertCount(4, $this->readAttribute($cache, 'data'));
$this->assertCount(3, $this->getCacheEntries($cache));
}

/**
* There's an intermittent cache entry which is a cache namespace
* version, it may or may not be there depending on doctrine-cache
* version. There's no point in checking it anyway since it's a detail
* of doctrine cache implementation.
*
* @param ArrayCache $cache
*
* @return array
*/
private function getCacheEntries(ArrayCache $cache)
{
$cacheEntries = $this->readAttribute($cache, 'data');
unset($cacheEntries['DoctrineNamespaceCacheKey[]']);

return $cacheEntries;
}
}