GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CacheDecoratorTest::testDecoratorRequireRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 9.472
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Test\Skautis;
4
5
use Skautis\User;
6
use Skautis\Wsdl\Decorator\Cache\ArrayCache;
7
use Skautis\Wsdl\Decorator\Cache\CacheDecorator;
8
9
class CacheDecoratorTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    protected function tearDown()
13
    {
14
        \Mockery::close();
15
    }
16
17
    public function testDecoratorRequireRequest()
18
    {
19
        $value = ['id' => 'response'];
20
        $args = ['asd', 'uv', User::ID_LOGIN => 'a'];
21
22
        /** @var Skautis\Wsdl\WebServiceInterface */
23
        $webService = \Mockery::mock('Skautis\Wsdl\WebServiceInterface');
24
        $webService->shouldReceive('call')->with('funkceA', $args)->once()->andReturn($value);
25
26
        $cache = new ArrayCache();
27
28
        //Prazdna cache, musi poslat request
29
        $decoratedServiceA = new CacheDecorator($webService, $cache);
0 ignored issues
show
Documentation introduced by
$webService is of type object<Mockery\LegacyMockInterface>, but the function expects a object<Skautis\Wsdl\WebServiceInterface>.

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...
30
        $response = $decoratedServiceA->call('funkceA', $args);
31
        $this->assertEquals($value, $response);
32
33
34
        //Jina instance WS
35
        /** @var Skautis\Wsdl\WebServiceInterface */
36
        $webServiceB = \Mockery::mock('Skautis\Wsdl\WebServiceInterface');
37
38
        //Cache naplnena z prechoziho requestu
39
        $decoratedServiceB = new CacheDecorator($webServiceB, $cache);
0 ignored issues
show
Documentation introduced by
$webServiceB is of type object<Mockery\LegacyMockInterface>, but the function expects a object<Skautis\Wsdl\WebServiceInterface>.

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...
40
        $response = $decoratedServiceB->call('funkceA', $args);
41
42
        //Vraci data z cache
43
        $this->assertEquals($value, $response);
44
    }
45
46
    public function testDecorator()
47
    {
48
        $value = ['id' => 'response'];
49
        $args = ['asd', 'uv'];
50
51
        /** @var Skautis\Wsdl\WebServiceInterface */
52
        $webService = \Mockery::mock('Skautis\Wsdl\WebServiceInterface');
53
        $webService->shouldReceive('call')->with('funkceA', $args)->once()->andReturn($value);
54
        $webService->shouldReceive('call')->with('funkceB', $args)->once()->andReturn($value);
55
56
        $cache = new ArrayCache();
57
58
        $decoratedService = new CacheDecorator($webService, $cache);
0 ignored issues
show
Documentation introduced by
$webService is of type object<Mockery\LegacyMockInterface>, but the function expects a object<Skautis\Wsdl\WebServiceInterface>.

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...
59
60
61
62
63
        // Stejne volani pouze 1x WebService
64
        $response = $decoratedService->call('funkceA', $args);
65
        $this->assertEquals($value, $response);
66
67
        // __call() stejny jako call()
68
        $response = $decoratedService->funkceA($args[0], $args[1]);
69
        $this->assertEquals($value, $response);
70
71
        // Stejne parametry jina funkce
72
        $response = $decoratedService->call('funkceB', $args);
73
        $this->assertEquals($value, $response);
74
75
76
        // Zmena obsahu parametru
77
        $args[0] = 'qwe';
78
        $webService->shouldReceive('call')->with('funkceA', $args)->once()->andReturn($value);
79
80
        $response = $decoratedService->call('funkceA', $args);
81
        $this->assertEquals($value, $response);
82
83
84
        // Odebrani parametru
85
        unset($args['1']);
86
        $webService->shouldReceive('call')->with('funkceA', $args)->once()->andReturn($value);
87
88
        $response = $decoratedService->call('funkceA', $args);
89
        $this->assertEquals($value, $response);
90
    }
91
}
92