Completed
Push — master ( e53efb...f3ecaf )
by Grummfy
02:39
created

ReadOnlyFallbackAdapter::testWriteAndWriteStream()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 1
eloc 21
nc 1
nop 0
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,
0 ignored issues
show
Documentation introduced by
$readOnlyAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
				$this->calling($mainAdapter)->has = false
0 ignored issues
show
Documentation introduced by
$mainAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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,
0 ignored issues
show
Documentation introduced by
$mainAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
			        $this->calling($readOnlyAdapter)->has = false)
0 ignored issues
show
Documentation introduced by
$readOnlyAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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,
0 ignored issues
show
Documentation introduced by
$mainAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
			        $this->calling($readOnlyAdapter)->has = false)
0 ignored issues
show
Documentation introduced by
$readOnlyAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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 testWriteAndWriteStream()
59
	{
60
		$readOnlyAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface');
61
		$mainAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface');
62
63
		$this->calling($mainAdapter)->write = true;
0 ignored issues
show
Documentation introduced by
$mainAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
		$this->calling($readOnlyAdapter)->write = false;
0 ignored issues
show
Documentation introduced by
$readOnlyAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
65
66
		$this->calling($mainAdapter)->writeStream = true;
0 ignored issues
show
Documentation introduced by
$mainAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
67
		$this->calling($readOnlyAdapter)->writeStream = false;
0 ignored issues
show
Documentation introduced by
$readOnlyAdapter is of type object|null, but the function expects a object<mageekguy\atoum\mock\aggregator>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68
69
		$this
70
			->assert('test write')
71
			->given($this->newTestedInstance($mainAdapter, $readOnlyAdapter))
72
			->then
73
			->boolean($this->testedInstance->write('/foo', 'bar', new Config()))->isTrue
74
				->mock($readOnlyAdapter)->wasNotCalled
75
				->mock($mainAdapter)->receive('write')->withAtLeastArguments(['/foo', 'bar'])->once;
76
77
		$this
78
			->assert('test write stream')
79
			->given($this->newTestedInstance($mainAdapter, $readOnlyAdapter))
80
			->then
81
			->boolean($this->testedInstance->write('/foo', 'bar', new Config()))->isTrue
82
				->mock($readOnlyAdapter)->wasNotCalled
83
				->mock($mainAdapter)->receive('writeStream')->withAtLeastArguments(['/foo', 'bar'])->once;
84
	}
85
}
86