GemberPHP /
cache-psr
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gember\CachePsr\Test; |
||
| 6 | |||
| 7 | use Gember\CachePsr\PsrSimpleCache; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Gember\CachePsr\Test\TestDoubles\TestPsrSimpleCache; |
||
| 9 | use PHPUnit\Framework\Attributes\Test; |
||
|
0 ignored issues
–
show
The type
PHPUnit\Framework\Attributes\Test was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | use PHPUnit\Framework\TestCase; |
||
| 11 | use DateInterval; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @internal |
||
| 15 | */ |
||
| 16 | final class PsrSimpleCacheTest extends TestCase |
||
| 17 | { |
||
| 18 | /** @var PsrSimpleCache<mixed> */ |
||
| 19 | private PsrSimpleCache $cache; |
||
| 20 | private TestPsrSimpleCache $psrSimpleCache; |
||
| 21 | |||
| 22 | protected function setUp(): void |
||
| 23 | { |
||
| 24 | parent::setUp(); |
||
| 25 | |||
| 26 | $this->cache = new PsrSimpleCache( |
||
| 27 | $this->psrSimpleCache = new TestPsrSimpleCache(), |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | #[Test] |
||
| 32 | public function itShouldSetAndGetFromCache(): void |
||
| 33 | { |
||
| 34 | $data = $this->cache->get('key'); |
||
| 35 | |||
| 36 | self::assertNull($data); |
||
| 37 | self::assertFalse($this->cache->has('key')); |
||
| 38 | |||
| 39 | $this->cache->set('key', 'some-data'); |
||
| 40 | |||
| 41 | $data = $this->cache->get('key'); |
||
| 42 | |||
| 43 | self::assertSame('some-data', $data); |
||
| 44 | self::assertTrue($this->cache->has('key')); |
||
| 45 | self::assertNull($this->psrSimpleCache->data['key'][1]); |
||
| 46 | } |
||
| 47 | |||
| 48 | #[Test] |
||
| 49 | public function itShouldSetAndGetFromCacheWithTtl(): void |
||
| 50 | { |
||
| 51 | $this->cache->set('key', 'some-data', $ttl = new DateInterval('P2D')); |
||
| 52 | |||
| 53 | $data = $this->cache->get('key'); |
||
| 54 | |||
| 55 | self::assertSame('some-data', $data); |
||
| 56 | self::assertTrue($this->cache->has('key')); |
||
| 57 | |||
| 58 | self::assertSame($ttl, $this->psrSimpleCache->data['key'][1]); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths