88use InvalidArgumentException ;
99use org \bovigo \vfs \vfsStream ;
1010use PHPStan \Cache \Cache ;
11+ use PHPStan \Cache \CacheStorage ;
1112use PHPUnit \Framework \TestCase ;
1213
1314class ExtensionInterfaceAutoloaderUnitTest extends TestCase
1415{
1516 /**
16- * @var Cache|\PHPUnit\Framework\MockObject\MockObject
17+ * @var Cache
1718 */
1819 private $ cache ;
1920 /**
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
2126 */
2227 private $ extAttrDataProvider ;
2328 /**
24- * @var ClassLoaderProvider| \PHPUnit\Framework\MockObject\MockObject
29+ * @var ClassLoaderProvider& \PHPUnit\Framework\MockObject\MockObject
2530 */
2631 private $ classLoader ;
2732 /**
@@ -31,7 +36,8 @@ class ExtensionInterfaceAutoloaderUnitTest extends TestCase
3136
3237 protected function setUp (): void
3338 {
34- $ this ->cache = $ this ->createMock (Cache::class);
39+ $ this ->cacheStorage = $ this ->createMock (CacheStorage::class);
40+ $ this ->cache = new Cache ($ this ->cacheStorage );
3541 $ this ->classLoader = $ this ->createMock (ClassLoaderProvider::class);
3642 $ this ->extAttrDataProvider = $ this ->createMock (ExtensionAttributeDataProvider::class);
3743 $ this ->autoloader = new ExtensionInterfaceAutoloader (
@@ -48,7 +54,7 @@ public function autoloaderIgnoresClassesWithoutExtensionInterfacePostfix(): void
4854 {
4955 $ this ->classLoader ->expects (self ::never ())
5056 ->method ('findFile ' );
51- $ this ->cache ->expects (self ::never ())
57+ $ this ->cacheStorage ->expects (self ::never ())
5258 ->method ('load ' );
5359
5460 $ this ->autoloader ->autoload ('SomeClass ' );
@@ -62,7 +68,7 @@ public function autoloaderPrefersLocalFile(): void
6268 $ this ->classLoader ->expects (self ::once ())
6369 ->method ('findFile ' )
6470 ->willReturn (__DIR__ . '/HelperExtensionInterface.php ' );
65- $ this ->cache ->expects (self ::never ())
71+ $ this ->cacheStorage ->expects (self ::never ())
6672 ->method ('load ' );
6773
6874 $ this ->autoloader ->autoload (HelperExtensionInterface::class);
@@ -78,11 +84,11 @@ public function autoloaderUsesCachedFileWhenFound(): void
7884 $ this ->classLoader ->expects (self ::once ())
7985 ->method ('findFile ' )
8086 ->willReturn (false );
81- $ this ->cache ->expects (self ::once ())
87+ $ this ->cacheStorage ->expects (self ::once ())
8288 ->method ('load ' )
8389 ->willReturn (__DIR__ . '/HelperExtensionInterface.php ' );
8490
85- $ this ->cache ->expects (self ::never ())
91+ $ this ->cacheStorage ->expects (self ::never ())
8692 ->method ('save ' );
8793
8894 $ this ->autoloader ->autoload (HelperExtensionInterface::class);
@@ -103,7 +109,7 @@ public function autoloadDoesNotGenerateInterfaceWhenNoAttributesExist(): void
103109 $ this ->classLoader ->expects (self ::once ())
104110 ->method ('findFile ' )
105111 ->willReturn (false );
106- $ this ->cache ->expects (self ::once ())
112+ $ this ->cacheStorage ->expects (self ::once ())
107113 ->method ('load ' )
108114 ->willReturn (null );
109115
0 commit comments