Skip to content

Commit f68d1e2

Browse files
authored
SymfonyUsageProviderTest: add testAutodetectConfigDir (#260)
1 parent a12cdd0 commit f68d1e2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace ShipMonk\PHPStan\DeadCode\Provider;
4+
5+
use PHPStan\Testing\PHPStanTestCase;
6+
use ReflectionClass;
7+
use function mkdir;
8+
use function realpath;
9+
use function rmdir;
10+
11+
class SymfonyUsageProviderTest extends PHPStanTestCase
12+
{
13+
14+
public function testAutodetectConfigDir(): void
15+
{
16+
$configDir = __DIR__ . '/../../config';
17+
@mkdir($configDir);
18+
19+
$provider = new SymfonyUsageProvider(self::getContainer(), true, null);
20+
21+
$providerReflection = new ReflectionClass(SymfonyUsageProvider::class);
22+
$configDirPropertyReflection = $providerReflection->getProperty('configDir');
23+
$configDirPropertyReflection->setAccessible(true);
24+
25+
$configDirFromProperty = $configDirPropertyReflection->getValue($provider);
26+
27+
self::assertIsString($configDirFromProperty);
28+
self::assertNotFalse(realpath($configDir));
29+
self::assertNotFalse(realpath($configDirFromProperty));
30+
self::assertSame(
31+
realpath($configDir),
32+
realpath($configDirFromProperty),
33+
);
34+
35+
@rmdir($configDir);
36+
}
37+
38+
}

0 commit comments

Comments
 (0)