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 — master ( b0e03a...4af0c2 )
by Tobias
02:50
created

LoggerPluginTest::testPluginException()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Plugin\Tests\Plugin;
14
15
use Geocoder\Exception\QuotaExceeded;
16
use Geocoder\Model\AddressCollection;
17
use Geocoder\Plugin\Plugin\LoggerPlugin;
18
use Geocoder\Plugin\PluginProvider;
19
use Geocoder\Provider\Provider;
20
use Geocoder\Query\GeocodeQuery;
21
use PHPUnit\Framework\TestCase;
22
use Psr\Log\AbstractLogger;
23
24
class LoggerPluginTest extends TestCase
25
{
26
    public function testPlugin()
27
    {
28
        $logger = $this->getMockBuilder(AbstractLogger::class)
29
            ->disableOriginalConstructor()
30
            ->setMethods(['log'])
31
            ->getMock();
32
        $logger->expects($this->once())
33
            ->method('log')
34
            ->with('info', $this->callback(function ($message) {
35
                return false !== strstr($message, 'Got 0 results');
36
            }));
37
38
        $geocodeQuery = GeocodeQuery::create('foo');
39
        $collection = new AddressCollection([]);
40
41
        $provider = $this->getMockBuilder(Provider::class)
42
            ->disableOriginalConstructor()
43
            ->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
44
            ->getMock();
45
        $provider->expects($this->once())
46
            ->method('geocodeQuery')
47
            ->with($geocodeQuery)
48
            ->willReturn($collection);
49
        $provider->expects($this->never())->method('reverseQuery');
50
        $provider->expects($this->never())->method('getName');
51
52
        $pluginProvider = new PluginProvider($provider, [new LoggerPlugin($logger)]);
0 ignored issues
show
Documentation introduced by
array(new \Geocoder\Plug...\LoggerPlugin($logger)) is of type array<integer,object<Geo...lugin\\LoggerPlugin>"}>, but the function expects a array<integer,object<Geocoder\Plugin\Plugin>>.

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...
53
        $this->assertSame($collection, $pluginProvider->geocodeQuery($geocodeQuery));
54
    }
55
56
    public function testPluginException()
57
    {
58
        $this->expectException(QuotaExceeded::class);
59
        $logger = $this->getMockBuilder(AbstractLogger::class)
60
            ->disableOriginalConstructor()
61
            ->setMethods(['log'])
62
            ->getMock();
63
        $logger->expects($this->once())
64
            ->method('log')
65
            ->with('error', $this->callback(function ($message) {
66
                return false !== strstr($message, 'QuotaExceeded');
67
            }));
68
69
        $geocodeQuery = GeocodeQuery::create('foo');
70
        $provider = $this->getMockBuilder(Provider::class)
71
            ->disableOriginalConstructor()
72
            ->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
73
            ->getMock();
74
        $provider->expects($this->once())
75
            ->method('geocodeQuery')
76
            ->willThrowException(new QuotaExceeded());
77
        $provider->expects($this->never())->method('reverseQuery');
78
        $provider->expects($this->never())->method('getName');
79
80
        $pluginProvider = new PluginProvider($provider, [new LoggerPlugin($logger)]);
0 ignored issues
show
Documentation introduced by
array(new \Geocoder\Plug...\LoggerPlugin($logger)) is of type array<integer,object<Geo...lugin\\LoggerPlugin>"}>, but the function expects a array<integer,object<Geocoder\Plugin\Plugin>>.

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...
81
        $pluginProvider->geocodeQuery($geocodeQuery);
82
    }
83
}
84