Skip to content

Commit 1dc6708

Browse files
committed
Ensure each autoloader can register and unregister
1 parent 873777a commit 1dc6708

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace bitExpert\PHPStan\Magento\Autoload;
4+
5+
use PHPStan\Cache\Cache;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class RegistrationUnitTest extends TestCase
9+
{
10+
/**
11+
* @test
12+
* @dataProvider provideAutoloaders()
13+
*/
14+
public function autoloadersCanRegisterAndUnregister(Autoloader $autoloader)
15+
{
16+
$autoloadFunctions = spl_autoload_functions();
17+
$autoloader->register();
18+
static::assertCount(count($autoloadFunctions) + 1, spl_autoload_functions());
19+
$autoloader->unregister();
20+
static::assertCount(count($autoloadFunctions), spl_autoload_functions());
21+
}
22+
23+
public function provideAutoloaders(): array
24+
{
25+
$cache = new Cache($this->getMockBuilder(\PHPStan\Cache\CacheStorage::class)->getMock());
26+
27+
return [
28+
[new FactoryAutoloader($cache)],
29+
[new MockAutoloader()],
30+
[new ProxyAutoloader($cache)],
31+
[new TestFrameworkAutoloader()]
32+
];
33+
}
34+
}

0 commit comments

Comments
 (0)