1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\FileLocator; |
6
|
|
|
|
7
|
|
|
use org\bovigo\vfs\vfsStream; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use ProxyManager\Exception\InvalidProxyDirectoryException; |
10
|
|
|
use ProxyManager\FileLocator\FileLocator; |
11
|
|
|
use const DIRECTORY_SEPARATOR; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests for {@see \ProxyManager\FileLocator\FileLocator} |
15
|
|
|
* |
16
|
|
|
* @group Coverage |
17
|
|
|
*/ |
18
|
|
|
final class FileLocatorTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @covers \ProxyManager\FileLocator\FileLocator::__construct |
22
|
|
|
* @covers \ProxyManager\FileLocator\FileLocator::getProxyFileName |
23
|
|
|
*/ |
24
|
|
|
public function testGetProxyFileName() : void |
25
|
|
|
{ |
26
|
|
|
$locator = new FileLocator(__DIR__); |
27
|
|
|
|
28
|
|
|
self::assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'FooBarBaz.php', $locator->getProxyFileName('Foo\\Bar\\Baz')); |
29
|
|
|
self::assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'Foo_Bar_Baz.php', $locator->getProxyFileName('Foo_Bar_Baz')); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @covers \ProxyManager\FileLocator\FileLocator::__construct |
34
|
|
|
*/ |
35
|
|
|
public function testRejectsNonExistingDirectory() : void |
36
|
|
|
{ |
37
|
|
|
$this->expectException(InvalidProxyDirectoryException::class); |
38
|
|
|
new FileLocator(__DIR__ . '/non-existing'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @covers \ProxyManager\FileLocator\FileLocator::__construct |
43
|
|
|
*/ |
44
|
|
|
public function testStreamWrappersSupported() : void |
45
|
|
|
{ |
46
|
|
|
$vfs = vfsStream::setup('root', null, ['dir' => []]); |
47
|
|
|
$path = $vfs->url() . '/dir'; |
48
|
|
|
$locator = new FileLocator($path); |
49
|
|
|
self::assertSame($path . DIRECTORY_SEPARATOR . 'FooBarBaz.php', $locator->getProxyFileName('Foo\\Bar\\Baz')); |
50
|
|
|
self::assertSame($path . DIRECTORY_SEPARATOR . 'Foo_Bar_Baz.php', $locator->getProxyFileName('Foo_Bar_Baz')); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|