Passed
Push — master ( ddb420...13a60b )
by Dispositif
02:30
created

WikidataAdapterTest::testGetUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.8333
1
<?php
2
/**
3
 * This file is part of dispositif/wikibot application
4
 * 2019 : Philippe M. <[email protected]>
5
 * For the full copyright and MIT license information, please view the LICENSE file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Infrastructure\Tests;
11
12
use App\Infrastructure\WikidataAdapter;
13
use GuzzleHttp\Client;
14
use GuzzleHttp\Handler\MockHandler;
15
use GuzzleHttp\HandlerStack;
16
use GuzzleHttp\Psr7\Response;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * Class WikidataAdapterTest
21
 *
22
 * @package App\Infrastructure\Tests
23
 */
24
class WikidataAdapterTest extends TestCase
25
{
26
27
    public function testGetUrl()
28
    {
29
        $jsonFixture = file_get_contents(__DIR__.'/fixture_WD_ISNI.json');
30
31
        $mock = new MockHandler(
32
            [
33
                new Response(200, ['X-Foo' => 'Bar'], $jsonFixture),
34
            ]
35
        );
36
        $handler = HandlerStack::create($mock);
37
        $clientMocked = new Client(['handler' => $handler]);
38
39
        $wikidata = new WikidataAdapter($clientMocked);
40
        $actual = $wikidata->searchByISNI('0000 0001 2137 320X');
41
42
        $this::assertSame(
43
            'https://fr.wikipedia.org/wiki/Michel_Houellebecq',
44
            $actual['article']['value']
45
        );
46
47
        $this::assertSame(
48
            '66522427',
49
            $actual['viaf']['value']
50
        );
51
    }
52
}
53