I added the following test to GenericCacheBackendUnitTest.php:
/**
* Test Drupal\Core\Cache\CacheBackendInterface::removeBin().
*/
public function testRemoveBin() {
$backend = $this->getCacheBackend();
$unrelated = $this->getCacheBackend('bootstrap');
// Set both expiring and permanent keys.
$backend->set('test1', 1, Cache::PERMANENT);
$backend->set('test2', 3, time() + 1000);
$unrelated->set('test3', 4, Cache::PERMANENT);
$backend->removeBin();
$this->assertFalse($backend->get('test1'), 'First key has been deleted.');
$this->assertFalse($backend->get('test2'), 'Second key has been deleted.');
$this->assertTrue($unrelated->get('test3'), 'Item in other bin is preserved.');
}
The test initially failed, then passed after the patch was applied, but I'm a little wary that I reverse engineered an outcome so more reviewers would be good.
+++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
@@ -666,4 +666,23 @@ public function testInvalidateAll() {
+ $backend = $this->getCacheBackend();
+ $unrelated = $this->getCacheBackend('bootstrap');
...
+ $this->assertFalse($backend->get('test1'), 'First key has been deleted.');
+ $this->assertFalse($backend->get('test2', TRUE), 'Second key has been deleted.');
+ $this->assertTrue($unrelated->get('test3'), 'Item in other bin is preserved.');
Test looks good, but $unrelated is a bit a strange name, maybe renamed to $backend_a and $backend_b?
Comments
Comment #1
jesse.d commentedI added the following test to GenericCacheBackendUnitTest.php:
The test initially failed, then passed after the patch was applied, but I'm a little wary that I reverse engineered an outcome so more reviewers would be good.
Comment #2
olli commentedYour test looks good to me.
Comment #3
olli commentedOne small thing:
$backend->get('test2')could pass the second parameter$backend->get('test2', TRUE).Comment #4
olli commentedHere's the test from #1.
Comment #7
olli commentedComment #8
berdirTest looks good, but $unrelated is a bit a strange name, maybe renamed to $backend_a and $backend_b?
Tagging novice to update this.
Comment #9
rpayanmPlease review :)
Comment #10
berdirYou renamed it in the existing testDeleteAll() method (now I see where that came from), but not in the new test method testRemoveBin() :)
Comment #11
rpayanmOn two more method! :D
Comment #12
berdirGreat, looks good now.
Comment #13
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 87be19c and pushed to 8.0.x. Thanks!