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.
Completed
Push — 3.x ( 52ff30...48a2e9 )
by Jindřich
12s queued 11s
created

WebServiceTest::testCallback()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 3
nop 0
dl 0
loc 30
rs 9.44
c 0
b 0
f 0
1
<?php
2
3
namespace Skaut\Skautis\Test\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use Skaut\Skautis;
7
use Skaut\Skautis\Exception as SkautisException;
8
use Skaut\Skautis\SkautisQuery;
9
use Skaut\Skautis\Wsdl\WebService;
10
use Skaut\Skautis\Wsdl\WebServiceFactory;
11
12
class WebServiceTest extends TestCase
13
{
14
15
    protected $queries = [];
16
17
    /**
18
     * @var WebServiceFactory
19
     */
20
    private $wsFactory;
21
22
    protected function setUp(): void
23
    {
24
      $this->wsFactory = new WebServiceFactory();
25
    }
26
27
28
    public function queryCallback($query)
29
    {
30
        $this->queries[] = $query;
31
    }
32
33
    public function testCallback()
34
    {
35
        $callback = [$this, 'queryCallback'];
36
37
        $data = [
38
            'ID_Application' => 123,
39
            Skautis\User::ID_LOGIN => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
40
        ];
41
42
43
        $webService = $this->wsFactory->createWebService(
44
          'https://test-is.skaut.cz/JunakWebservice/UserManagement.asmx?WSDL',
45
          $data
46
        );
47
        $webService->subscribe(WebService::EVENT_FAILURE, $callback);
48
49
        try {
50
            $webService->call('UserDetail');
51
            $this->fail();
52
        } catch (SkautisException $e) {
53
            //Vyjimku chceme
54
        }
55
56
        $this->assertCount(1, $this->queries);
0 ignored issues
show
Documentation introduced by
$this->queries is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
57
        $this->assertInstanceOf(SkautisQuery::class, $this->queries[0]);
58
        $this->assertEquals('UserDetail', $this->queries[0]->fname);
59
        $this->assertGreaterThan(0, strlen($this->queries[0]->getExceptionString()));
60
        $this->assertEquals('SoapFault', $this->queries[0]->getExceptionClass());
61
        $this->assertTrue($this->queries[0]->hasFailed());
62
    }
63
64
    public function testCall()
65
    {
66
        $callback = [$this, 'queryCallback'];
67
68
        $data = [
69
            'ID_Application' => 123,
70
            Skautis\User::ID_LOGIN => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
71
        ];
72
        $webService = $this->wsFactory->createWebService(
73
          'https://test-is.skaut.cz/JunakWebservice/UserManagement.asmx?WSDL',
74
          $data
75
        );
76
        $webService->subscribe(WebService::EVENT_FAILURE, $callback);
77
78
        try {
79
            $webService->UserDetail();
80
            $this->fail();
81
        } catch (SkautisException $e) {
82
            //Vyjimku chceme
83
        }
84
85
        $this->assertCount(1, $this->queries);
0 ignored issues
show
Documentation introduced by
$this->queries is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
86
        $this->assertInstanceOf(SkautisQuery::class, $this->queries[0]);
87
        $this->assertEquals('UserDetail', $this->queries[0]->fname);
88
        $this->assertGreaterThan(0, strlen($this->queries[0]->getExceptionString()));
89
        $this->assertEquals('SoapFault', $this->queries[0]->getExceptionClass());
90
        $this->assertTrue($this->queries[0]->hasFailed());
91
    }
92
}
93