-
Notifications
You must be signed in to change notification settings - Fork 8
/
StaticInMemoryAdapterRegistryTest.php
57 lines (45 loc) · 1.68 KB
/
StaticInMemoryAdapterRegistryTest.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
<?php
namespace League\Flysystem\InMemory;
use League\Flysystem\Config;
use League\Flysystem\FilesystemAdapter;
class StaticInMemoryAdapterRegistryTest extends InMemoryFilesystemAdapterTest
{
/**
* @test
*/
public function using_different_name_to_segment_adapters(): void
{
$first = StaticInMemoryAdapterRegistry::get();
$second = StaticInMemoryAdapterRegistry::get('second');
$first->write('foo.txt', 'foo', new Config());
$second->write('bar.txt', 'bar', new Config());
$this->assertTrue($first->fileExists('foo.txt'));
$this->assertFalse($first->fileExists('bar.txt'));
$this->assertTrue($second->fileExists('bar.txt'));
$this->assertFalse($second->fileExists('foo.txt'));
}
/**
* @test
*/
public function files_persist_between_instances(): void
{
$first = StaticInMemoryAdapterRegistry::get();
$second = StaticInMemoryAdapterRegistry::get('second');
$first->write('foo.txt', 'foo', new Config());
$second->write('bar.txt', 'bar', new Config());
$this->assertTrue($first->fileExists('foo.txt'));
$this->assertTrue($second->fileExists('bar.txt'));
$first = StaticInMemoryAdapterRegistry::get();
$second = StaticInMemoryAdapterRegistry::get('second');
$this->assertTrue($first->fileExists('foo.txt'));
$this->assertTrue($second->fileExists('bar.txt'));
}
protected function tearDown(): void
{
StaticInMemoryAdapterRegistry::deleteAllFilesystems();
}
protected static function createFilesystemAdapter(): FilesystemAdapter
{
return StaticInMemoryAdapterRegistry::get();
}
}