Skip to content

Commit 72d247c

Browse files
janpalickaf3l1x
authored andcommitted
tests: fix tests and phpstan config
1 parent db6890b commit 72d247c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"require-dev": {
2121
"contributte/phpstan": "^0.1",
2222
"contributte/qa": "^0.4",
23-
"contributte/tester": "^0.3"
23+
"contributte/tester": "^0.3",
24+
"symfony/cache": "^7.2"
2425
},
2526
"autoload": {
2627
"psr-4": {

phpstan.neon

-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ parameters:
1616
- .docs
1717

1818
ignoreErrors:
19-
# No replacement available
20-
- '#Call to deprecated method registerUniqueLoader\(\) of class Doctrine\\Common\\Annotations\\AnnotationRegistry.#'
21-
- '#Fetching class constant class of deprecated class Doctrine\\Common\\Annotations\\CachedReader#'

tests/Cases/DI/AnnotationsExtensionTest.php

+13-14
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
use Contributte\Tester\Environment;
66
use Contributte\Tester\Utils\ContainerBuilder;
77
use Contributte\Tester\Utils\Neonkit;
8-
use Doctrine\Common\Annotations\CachedReader;
8+
use Doctrine\Common\Annotations\PsrCachedReader;
99
use Doctrine\Common\Annotations\Reader;
10-
use Doctrine\Common\Cache\ApcuCache;
11-
use Doctrine\Common\Cache\Cache;
12-
use Doctrine\Common\Cache\PhpFileCache;
1310
use Nette\DI\Compiler;
1411
use Nette\InvalidStateException;
1512
use Nettrine\Annotations\DI\AnnotationsExtension;
16-
use Nettrine\Cache\DI\CacheExtension;
13+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
14+
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
1715
use Tester\Assert;
1816
use Tester\TestCase;
1917

@@ -27,18 +25,20 @@ public function testAutowiredCache(): void
2725
$container = ContainerBuilder::of()
2826
->withCompiler(function (Compiler $compiler): void {
2927
$compiler->addExtension('annotations', new AnnotationsExtension());
30-
$compiler->addExtension('cache', new CacheExtension());
3128
$compiler->addConfig([
3229
'parameters' => [
3330
'tempDir' => Environment::getTestDir(),
3431
],
32+
'annotations' => [
33+
'cache' => PhpFilesAdapter::class, // Use PSR-6 cache
34+
],
3535
]);
3636
$compiler->addDependencies([__FILE__]);
3737
})
3838
->build();
3939

40-
Assert::type(CachedReader::class, $container->getByType(Reader::class));
41-
Assert::type(PhpFileCache::class, $container->getService('cache.driver'));
40+
Assert::type(PsrCachedReader::class, $container->getByType(Reader::class));
41+
Assert::type(PhpFilesAdapter::class, $container->getService('annotations.cache'));
4242
}
4343

4444
public function testProvidedCache(): void
@@ -47,16 +47,15 @@ public function testProvidedCache(): void
4747
->withCompiler(function (Compiler $compiler): void {
4848
$compiler->addExtension('annotations', new AnnotationsExtension());
4949
$compiler->addConfig(Neonkit::load('
50-
annotations:
51-
cache: Doctrine\Common\Cache\ApcuCache
52-
'));
50+
annotations:
51+
cache: Symfony\Component\Cache\Adapter\ArrayAdapter
52+
'));
5353
$compiler->addDependencies([__FILE__]);
5454
})
5555
->build();
5656

57-
Assert::type(CachedReader::class, $container->getByType(Reader::class));
58-
Assert::type(ApcuCache::class, $container->getService('annotations.cache'));
59-
Assert::null($container->getByType(Cache::class, false));
57+
Assert::type(PsrCachedReader::class, $container->getByType(Reader::class));
58+
Assert::type(ArrayAdapter::class, $container->getService('annotations.cache'));
6059
}
6160

6261
public function testNoCache(): void

tests/Cases/Reader/ReaderTest.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use Contributte\Tester\Environment;
66
use Contributte\Tester\Utils\ContainerBuilder;
7-
use Contributte\Tester\Utils\Neonkit;
87
use Doctrine\Common\Annotations\Reader;
98
use Nette\DI\Compiler;
109
use Nettrine\Annotations\DI\AnnotationsExtension;
1110
use ReflectionClass;
11+
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1212
use Tester\Assert;
1313
use Tester\TestCase;
1414
use Tests\Fixtures\SampleAnnotation;
@@ -25,12 +25,15 @@ public function testIgnoreAnnotations(): void
2525
->withCompiler(function (Compiler $compiler): void {
2626
$compiler->addExtension('annotations', new AnnotationsExtension());
2727
$compiler->addConfig(['parameters' => ['tempDir' => Environment::getTestDir()]]);
28-
$compiler->addConfig(Neonkit::load('
29-
annotations:
30-
cache: Doctrine\Common\Cache\FilesystemCache(%tempDir%/nettrine.annotations)
31-
ignore:
32-
- ignoredAnnotation
33-
'));
28+
$compiler->addConfig([
29+
'parameters' => [
30+
'tempDir' => Environment::getTestDir(),
31+
],
32+
'annotations' => [
33+
'cache' => FilesystemAdapter::class,
34+
'ignore' => ['ignoredAnnotation'],
35+
],
36+
]);
3437
$compiler->addDependencies([__FILE__]);
3538
})
3639
->build();

0 commit comments

Comments
 (0)