8000 Inconsistency in Symfony\Component\Cache\Tests\Adapter\AdapterTestCase::testGet() method · Issue #27731 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content 8000
Inconsistency in Symfony\Component\Cache\Tests\Adapter\AdapterTestCase::testGet() method #27731
Closed
@pounard

Description

@pounard

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0