Completed
Push — master ( e577bd...53a0ca )
by Grummfy
15:35
created

ReadOnlyFallbackAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 66
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAdapters() 0 11 1
B testHasPath() 0 36 1
A testWrite() 0 14 1
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 testWrite()
59
	{
60
		$readOnlyAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface');
61
		$mainAdapter = $this->newMockInstance('\League\Flysystem\AdapterInterface');
62
		$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...
63
		$this->calling($readOnlyAdapter)->write = 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...
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