|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace tests\units\BePark\Flysystem\ReadOnlyFallback; |
|
4
|
|
|
|
|
5
|
|
|
use League\Flysystem\Config; |
|
6
|
|
|
|
|
7
|
|
|
class ReadOnlyFallbackAdapter extends \atoum\test |
|
8
|
|
|
{ |
|
9
|
|
|
public function testAdapters() |
|
10
|
|
|
{ |
|
11
|
|
|
$readOnlyAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
12
|
|
|
$mainAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
13
|
|
|
|
|
14
|
|
|
$this |
|
15
|
|
|
->given($this->newTestedInstance($mainAdapter, $readOnlyAdapter)) |
|
16
|
|
|
->then |
|
17
|
|
|
->object($this->testedInstance->getMainAdapter())->isIdenticalTo($mainAdapter) |
|
18
|
|
|
->object($this->testedInstance->getReadOnlyAdapter())->isIdenticalTo($readOnlyAdapter); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testHasPath() |
|
22
|
|
|
{ |
|
23
|
|
|
$readOnlyAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
24
|
|
|
$mainAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
25
|
|
|
|
|
26
|
|
|
$this |
|
27
|
|
|
->assert('test path existence on readOnly') |
|
28
|
|
|
->given( |
|
29
|
|
|
$this->newTestedInstance($mainAdapter, $readOnlyAdapter), |
|
30
|
|
|
$this->calling($readOnlyAdapter)->has = true, |
|
|
|
|
|
|
31
|
|
|
$this->calling($mainAdapter)->has = false |
|
|
|
|
|
|
32
|
|
|
) |
|
33
|
|
|
->then |
|
34
|
|
|
->boolean($this->testedInstance->has('/foo'))->isTrue |
|
35
|
|
|
->mock($readOnlyAdapter)->receive('has')->withIdenticalArguments('/foo')->once |
|
36
|
|
|
->mock($mainAdapter)->receive('has')->withIdenticalArguments('/foo')->once; |
|
37
|
|
|
|
|
38
|
|
|
$this |
|
39
|
|
|
->assert('test path existence on mainAdapter') |
|
40
|
|
|
->given($this->calling($mainAdapter)->has = true, |
|
|
|
|
|
|
41
|
|
|
$this->calling($readOnlyAdapter)->has = false) |
|
|
|
|
|
|
42
|
|
|
->then |
|
43
|
|
|
->boolean($this->testedInstance->has('/foo'))->isTrue |
|
44
|
|
|
->mock($mainAdapter)->receive('has')->withIdenticalArguments('/foo')->once |
|
45
|
|
|
->mock($readOnlyAdapter)->call('has')->never; |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
$this |
|
49
|
|
|
->assert('test none existing path') |
|
50
|
|
|
->given($this->calling($mainAdapter)->has = false, |
|
|
|
|
|
|
51
|
|
|
$this->calling($readOnlyAdapter)->has = false) |
|
|
|
|
|
|
52
|
|
|
->then |
|
53
|
|
|
->boolean($this->testedInstance->has('/foo'))->isFalse |
|
54
|
|
|
->mock($mainAdapter)->receive('has')->withIdenticalArguments('/foo')->once |
|
55
|
|
|
->mock($readOnlyAdapter)->receive('has')->withIdenticalArguments('/foo')->once; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testWrite() |
|
59
|
|
|
{ |
|
60
|
|
|
$readOnlyAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
61
|
|
|
$mainAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface'); |
|
62
|
|
|
$this->calling($mainAdapter)->write = true; |
|
|
|
|
|
|
63
|
|
|
$this->calling($readOnlyAdapter)->write = true; |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
$this |
|
66
|
|
|
->given($this->newTestedInstance($mainAdapter, $readOnlyAdapter)) |
|
67
|
|
|
->then |
|
68
|
|
|
->boolean($this->testedInstance->write('/foo', 'bar', new Config()))->isTrue |
|
69
|
|
|
->mock($readOnlyAdapter)->wasNotCalled |
|
70
|
|
|
->mock($mainAdapter)->receive('write')->withAtLeastArguments(['/foo', 'bar'])->once; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: