|
1
|
|
|
<?php |
|
2
|
|
|
namespace Staticus\Resources\Commands; |
|
3
|
|
|
|
|
4
|
|
|
use Staticus\Resources\ResourceDOInterface; |
|
5
|
|
|
|
|
6
|
|
|
trait AddWrongFilesToDiskTrait |
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* Put bad files to the 'disk' |
|
10
|
|
|
* @param $resourceDO |
|
11
|
|
|
* @param $content |
|
12
|
|
|
* @return string |
|
|
|
|
|
|
13
|
|
|
*/ |
|
14
|
11 |
|
protected function addWrongFilesToDisk(ResourceDOInterface $resourceDO, $content) |
|
15
|
|
|
{ |
|
16
|
11 |
|
$resourceDO = clone $resourceDO; |
|
17
|
11 |
|
$resourceDO->setName('another'); |
|
18
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
19
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
|
|
|
|
|
20
|
11 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
11 |
|
$resourceDO = clone $resourceDO; |
|
23
|
11 |
|
$resourceDO->setNameAlternative('another'); |
|
24
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
25
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
26
|
11 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
11 |
|
$resourceDO = clone $resourceDO; |
|
29
|
11 |
|
$resourceDO->setBaseDirectory('another'); |
|
30
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
31
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
32
|
11 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
11 |
|
$resourceDO = clone $resourceDO; |
|
35
|
11 |
|
$resourceDO->setNamespace('another'); |
|
36
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
37
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
38
|
11 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
11 |
|
$resourceDO = clone $resourceDO; |
|
41
|
11 |
|
$resourceDO->setType('wrong-type'); |
|
42
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
43
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
44
|
11 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
45
|
11 |
|
} |
|
46
|
|
|
|
|
47
|
4 |
|
protected function assertWrongFilesIsStillHere($resourceDO) |
|
48
|
|
|
{ |
|
49
|
4 |
|
$resourceDO = clone $resourceDO; |
|
50
|
4 |
|
$resourceDO->setName('another'); |
|
51
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
52
|
4 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
4 |
|
$resourceDO = clone $resourceDO; |
|
55
|
4 |
|
$resourceDO->setNameAlternative('another'); |
|
56
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
57
|
4 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
4 |
|
$resourceDO = clone $resourceDO; |
|
60
|
4 |
|
$resourceDO->setBaseDirectory('another'); |
|
61
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
62
|
4 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
4 |
|
$resourceDO = clone $resourceDO; |
|
65
|
4 |
|
$resourceDO->setNamespace('another'); |
|
66
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
67
|
4 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
4 |
|
$resourceDO = clone $resourceDO; |
|
70
|
4 |
|
$resourceDO->setType('wrong-type'); |
|
71
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
72
|
4 |
|
$this->assertTrue($this->filesystem->has($filePath)); |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
} |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.