Description
Following issue #27604 where @nicolas-grekas, I found a minor inconsistency within unit tests:
In the Symfony\Component\Cache\Tests\Adapter\AdapterTestCase::testGet()
method:
$this->assertNull($cache->get('foo', function (CacheItem $item) use (&$isHit, $value) {
$isHit = false;
$this->assertTrue($item->isHit());
$this->assertSame($value, $item->get());
}, INF));
The $this->assertTrue($item->isHit())
asumption is wrong, since that $beta
is INF
, probabilistic early expiration will recompute an item, but this new item that's going to be computed which will be passed to the anonymous callback is at the discretion of the implementation, it's not documented as being the previous hit, this test does not makes sense.
In fine, it exposes internal implementation details to a unit test that is supposed to test the behaviour, not how it does it.
Since that a $beta
value to INF
will always lead to a recomputation, it could be optimized by not loading the item before recomputing it, case in which this test is even less consistent.