forked from phpactor/phpactor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MappedFilesystemRegistryTest.php
63 lines (50 loc) · 1.67 KB
/
MappedFilesystemRegistryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Phpactor\Filesystem\Tests\Unit\Domain;
use PHPUnit\Framework\TestCase;
use Phpactor\Filesystem\Domain\Filesystem;
use Phpactor\Filesystem\Domain\MappedFilesystemRegistry;
use Prophecy\PhpUnit\ProphecyTrait;
use InvalidArgumentException;
use Prophecy\Prophecy\ObjectProphecy;
class MappedFilesystemRegistryTest extends TestCase
{
use ProphecyTrait;
/**
* @var ObjectProphecy<Filesystem>
*/
private ObjectProphecy $filesystem;
public function setUp(): void
{
$this->filesystem = $this->prophesize(Filesystem::class);
}
public function testRetrievesFilesystems(): void
{
$registry = $this->createRegistry([
'foobar' => $this->filesystem->reveal()
]);
$filesystem = $registry->get('foobar');
$this->assertEquals($this->filesystem->reveal(), $filesystem);
}
public function testHasFilesystem(): void
{
$registry = $this->createRegistry([
'foobar' => $this->filesystem->reveal()
]);
$this->assertTrue($registry->has('foobar'));
$this->assertFalse($registry->has('barbar'));
}
public function testExceptionOnNotFound(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown filesystem "barfoo"');
$registry = $this->createRegistry([
'foobar' => $this->filesystem->reveal()
]);
$registry->get('barfoo');
}
/** @param array<string, Filesystem> $filesystems */
private function createRegistry(array $filesystems): MappedFilesystemRegistry
{
return new MappedFilesystemRegistry($filesystems);
}
}