|
1
|
|
|
<?php |
|
2
|
|
|
namespace Staticus\Resources\Commands; |
|
3
|
|
|
|
|
4
|
|
|
use League\Flysystem\Filesystem; |
|
5
|
|
|
use Staticus\Resources\ResourceDOInterface; |
|
6
|
|
|
|
|
7
|
|
|
class AddWrongFilesToDiskHelper |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var Filesystem |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $filesystem; |
|
13
|
|
|
/** |
|
14
|
|
|
* @var \PHPUnit_Framework_TestCase |
|
15
|
|
|
*/ |
|
16
|
|
|
private $testCase; |
|
17
|
|
|
|
|
18
|
26 |
|
public function __construct(Filesystem $filesystem, \PHPUnit_Framework_TestCase $testCase) |
|
19
|
|
|
{ |
|
20
|
26 |
|
$this->filesystem = $filesystem; |
|
21
|
26 |
|
$this->testCase = $testCase; |
|
22
|
26 |
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Put bad files to the 'disk' |
|
26
|
|
|
* @param $resourceDO |
|
27
|
|
|
* @param $content |
|
28
|
|
|
* @return string |
|
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
11 |
|
public function create(ResourceDOInterface $resourceDO, $content = '') |
|
31
|
|
|
{ |
|
32
|
11 |
|
$resourceDO = clone $resourceDO; |
|
33
|
11 |
|
$resourceDO->setName('another'); |
|
34
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
35
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
36
|
|
|
|
|
37
|
11 |
|
$resourceDO = clone $resourceDO; |
|
38
|
11 |
|
$resourceDO->setNameAlternative('another'); |
|
39
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
40
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
41
|
|
|
|
|
42
|
11 |
|
$resourceDO = clone $resourceDO; |
|
43
|
11 |
|
$resourceDO->setBaseDirectory('another'); |
|
44
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
45
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
46
|
|
|
|
|
47
|
11 |
|
$resourceDO = clone $resourceDO; |
|
48
|
11 |
|
$resourceDO->setNamespace('another'); |
|
49
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
50
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
51
|
|
|
|
|
52
|
11 |
|
$resourceDO = clone $resourceDO; |
|
53
|
11 |
|
$resourceDO->setType('wrong-type'); |
|
54
|
11 |
|
$filePath = $resourceDO->getFilePath(); |
|
55
|
11 |
|
$this->filesystem->put($filePath, $content); |
|
56
|
11 |
|
} |
|
57
|
|
|
|
|
58
|
4 |
|
public function assertExist(ResourceDOInterface $resourceDO) |
|
59
|
|
|
{ |
|
60
|
4 |
|
$resourceDO = clone $resourceDO; |
|
61
|
4 |
|
$resourceDO->setName('another'); |
|
62
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
63
|
4 |
|
$this->testCase->assertTrue($this->filesystem->has($filePath)); |
|
64
|
|
|
|
|
65
|
4 |
|
$resourceDO = clone $resourceDO; |
|
66
|
4 |
|
$resourceDO->setNameAlternative('another'); |
|
67
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
68
|
4 |
|
$this->testCase->assertTrue($this->filesystem->has($filePath)); |
|
69
|
|
|
|
|
70
|
4 |
|
$resourceDO = clone $resourceDO; |
|
71
|
4 |
|
$resourceDO->setBaseDirectory('another'); |
|
72
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
73
|
4 |
|
$this->testCase->assertTrue($this->filesystem->has($filePath)); |
|
74
|
|
|
|
|
75
|
4 |
|
$resourceDO = clone $resourceDO; |
|
76
|
4 |
|
$resourceDO->setNamespace('another'); |
|
77
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
78
|
4 |
|
$this->testCase->assertTrue($this->filesystem->has($filePath)); |
|
79
|
|
|
|
|
80
|
4 |
|
$resourceDO = clone $resourceDO; |
|
81
|
4 |
|
$resourceDO->setType('wrong-type'); |
|
82
|
4 |
|
$filePath = $resourceDO->getFilePath(); |
|
83
|
4 |
|
$this->testCase->assertTrue($this->filesystem->has($filePath)); |
|
84
|
|
|
} |
|
85
|
|
|
} |
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.