APITest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testLookup() 0 7 1
A testNearest() 0 5 1
A testRandom() 0 9 1
1
<?php
2
3
4
namespace Tests\Suilven\UKPostCodes;
5
6
use PHPUnit\Framework\TestCase;
7
use Suilven\UKPostCodes\API;
8
use Suilven\UKPostCodes\Models\PostCode;
9
10
class APITest extends TestCase
11
{
12
    /**
13
     * @var API
14
     */
15
    private $api;
16
17
    public function setUp(): void
18
    {
19
        parent::setUp();
20
        $this->api = new API();
21
    }
22
23
    /**
24
     * @test
25
     * @vcr testlookup.yml
26
     * @group PhpVcrTest
27
     */
28
    public function testLookup()
29
    {
30
        $lookup = $this->api->lookup('SW1A 2AA');
31
        error_log(print_r($lookup, 1));
32
33
        $this->assertEquals('SW1A 2AA', $lookup->postcode);
34
    }
35
36
    /**
37
     * @test
38
     * @vcr testnearest.yml
39
     * @group PhpVcrTest
40
     */
41
    public function testNearest()
42
    {
43
        $response = $this->api->nearest('SW1A 2AA');
44
        error_log(print_r($response, 1));
45
    }
46
47
    /**
48
     * @test
49
     * @vcr testrandom.yml
50
     * @group PhpVcrTest
51
     */
52
    public function testRandom()
53
    {
54
        /** @var PostCode $random */
55
        $random = $this->api->random();
56
        $this->assertEquals('CM6 1EJ', $random->postcode);
57
58
        $lookup = $this->api->lookup('CM6 1EJ');
59
        $this->assertEquals($lookup, $random);
60
    }
61
}
62