1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hyde\Framework\Testing\Unit; |
4
|
|
|
|
5
|
|
|
use Hyde\Framework\Concerns\InteractsWithDirectories; |
6
|
|
|
use Hyde\Framework\Hyde; |
7
|
|
|
use Hyde\Testing\TestCase; |
8
|
|
|
use Illuminate\Support\Facades\File; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class InteractsWithDirectoriesConcernTest. |
12
|
|
|
* |
13
|
|
|
* @covers \Hyde\Framework\Concerns\InteractsWithDirectories |
14
|
|
|
*/ |
15
|
|
|
class InteractsWithDirectoriesConcernTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
use InteractsWithDirectories; |
18
|
|
|
|
19
|
|
|
protected function setUp(): void |
20
|
|
|
{ |
21
|
|
|
parent::setUp(); |
22
|
|
|
|
23
|
|
|
File::deleteDirectory(Hyde::path('foo')); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
protected function tearDown(): void |
27
|
|
|
{ |
28
|
|
|
File::deleteDirectory(Hyde::path('foo')); |
29
|
|
|
|
30
|
|
|
parent::tearDown(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function test_needs_directory_creates_the_directory() |
34
|
|
|
{ |
35
|
|
|
$this->needsDirectory(Hyde::path('foo')); |
36
|
|
|
$this->assertDirectoryExists(Hyde::path('foo')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function test_needs_directory_creates_the_directory_recursively() |
40
|
|
|
{ |
41
|
|
|
$this->needsDirectory(Hyde::path('foo/bar/baz')); |
42
|
|
|
$this->assertDirectoryExists(Hyde::path('foo/bar/baz')); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function test_needs_directory_handles_existing_directory() |
46
|
|
|
{ |
47
|
|
|
$this->needsDirectory(Hyde::path('foo')); |
48
|
|
|
$this->needsDirectory(Hyde::path('foo')); |
49
|
|
|
$this->assertDirectoryExists(Hyde::path('foo')); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function test_needs_directories_creates_single_directory() |
53
|
|
|
{ |
54
|
|
|
$this->needsDirectories([Hyde::path('foo')]); |
55
|
|
|
$this->assertDirectoryExists(Hyde::path('foo')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function test_needs_directories_creates_multiple_directories() |
59
|
|
|
{ |
60
|
|
|
$this->needsDirectories([Hyde::path('foo'), Hyde::path('bar')]); |
61
|
|
|
$this->assertDirectoryExists(Hyde::path('foo')); |
62
|
|
|
$this->assertDirectoryExists(Hyde::path('bar')); |
63
|
|
|
|
64
|
|
|
File::deleteDirectory(Hyde::path('bar')); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|