8
8
use InvalidArgumentException ;
9
9
use org \bovigo \vfs \vfsStream ;
10
10
use PHPStan \Cache \Cache ;
11
+ use PHPStan \Cache \CacheStorage ;
11
12
use PHPUnit \Framework \TestCase ;
12
13
13
14
class ExtensionInterfaceAutoloaderUnitTest extends TestCase
14
15
{
15
16
/**
16
- * @var Cache|\PHPUnit\Framework\MockObject\MockObject
17
+ * @var Cache
17
18
*/
18
19
private $ cache ;
19
20
/**
20
- * @var ExtensionAttributeDataProvider|\PHPUnit\Framework\MockObject\MockObject
21
+ * @var CacheStorage&\PHPUnit\Framework\MockObject\MockObject
22
+ */
23
+ private $ cacheStorage ;
24
+ /**
25
+ * @var ExtensionAttributeDataProvider&\PHPUnit\Framework\MockObject\MockObject
21
26
*/
22
27
private $ extAttrDataProvider ;
23
28
/**
24
- * @var ClassLoaderProvider| \PHPUnit\Framework\MockObject\MockObject
29
+ * @var ClassLoaderProvider& \PHPUnit\Framework\MockObject\MockObject
25
30
*/
26
31
private $ classLoader ;
27
32
/**
@@ -31,7 +36,8 @@ class ExtensionInterfaceAutoloaderUnitTest extends TestCase
31
36
32
37
protected function setUp (): void
33
38
{
34
- $ this ->cache = $ this ->createMock (Cache::class);
39
+ $ this ->cacheStorage = $ this ->createMock (CacheStorage::class);
40
+ $ this ->cache = new Cache ($ this ->cacheStorage );
35
41
$ this ->classLoader = $ this ->createMock (ClassLoaderProvider::class);
36
42
$ this ->extAttrDataProvider = $ this ->createMock (ExtensionAttributeDataProvider::class);
37
43
$ this ->autoloader = new ExtensionInterfaceAutoloader (
@@ -48,7 +54,7 @@ public function autoloaderIgnoresClassesWithoutExtensionInterfacePostfix(): void
48
54
{
49
55
$ this ->classLoader ->expects (self ::never ())
50
56
->method ('findFile ' );
51
- $ this ->cache ->expects (self ::never ())
57
+ $ this ->cacheStorage ->expects (self ::never ())
52
58
->method ('load ' );
53
59
54
60
$ this ->autoloader ->autoload ('SomeClass ' );
@@ -62,7 +68,7 @@ public function autoloaderPrefersLocalFile(): void
62
68
$ this ->classLoader ->expects (self ::once ())
63
69
->method ('findFile ' )
64
70
->willReturn (__DIR__ . '/HelperExtensionInterface.php ' );
65
- $ this ->cache ->expects (self ::never ())
71
+ $ this ->cacheStorage ->expects (self ::never ())
66
72
->method ('load ' );
67
73
68
74
$ this ->autoloader ->autoload (HelperExtensionInterface::class);
@@ -78,11 +84,11 @@ public function autoloaderUsesCachedFileWhenFound(): void
78
84
$ this ->classLoader ->expects (self ::once ())
79
85
->method ('findFile ' )
80
86
->willReturn (false );
81
- $ this ->cache ->expects (self ::once ())
87
+ $ this ->cacheStorage ->expects (self ::once ())
82
88
->method ('load ' )
83
89
->willReturn (__DIR__ . '/HelperExtensionInterface.php ' );
84
90
85
- $ this ->cache ->expects (self ::never ())
91
+ $ this ->cacheStorage ->expects (self ::never ())
86
92
->method ('save ' );
87
93
88
94
$ this ->autoloader ->autoload (HelperExtensionInterface::class);
@@ -103,7 +109,7 @@ public function autoloadDoesNotGenerateInterfaceWhenNoAttributesExist(): void
103
109
$ this ->classLoader ->expects (self ::once ())
104
110
->method ('findFile ' )
105
111
->willReturn (false );
106
- $ this ->cache ->expects (self ::once ())
112
+ $ this ->cacheStorage ->expects (self ::once ())
107
113
->method ('load ' )
108
114
->willReturn (null );
109
115
0 commit comments