AddressCrudTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testUpdateAddressTooLongNote() 0 6 1
A setUp() 0 4 1
A testCreateAddressTooLongNote() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SergeyNezbritskiy\NovaPoshta\Tests\Unit\Models\Address;
6
7
use PHPUnit\Framework\MockObject\Exception;
8
use PHPUnit\Framework\TestCase;
9
use RuntimeException;
10
use SergeyNezbritskiy\NovaPoshta\Connection;
11
use SergeyNezbritskiy\NovaPoshta\Models\Address;
12
use SergeyNezbritskiy\NovaPoshta\NovaPoshtaApiException;
13
14
class AddressCrudTest extends TestCase
15
{
16
    private Address $model;
17
18
    /**
19
     * @return void
20
     * @throws Exception
21
     */
22
    protected function setUp(): void
23
    {
24
        $connection = $this->createMock(Connection::class);
25
        $this->model = new Address($connection);
26
    }
27
28
    /**
29
     * @throws NovaPoshtaApiException
30
     */
31
    public function testCreateAddressTooLongNote(): void
32
    {
33
        $note = 'This is the note that exceeds forty symbols - the limit from Nova Poshta API';
34
        $this->expectException(RuntimeException::class);
35
        $this->expectExceptionMessage('Note exceeds the limit of 40 symbols');
36
        $this->model->save('', [], $note);
37
    }
38
39
    /**
40
     * @throws NovaPoshtaApiException
41
     */
42
    public function testUpdateAddressTooLongNote(): void
43
    {
44
        $note = 'This is the note that exceeds forty symbols - the limit from Nova Poshta API';
45
        $this->expectException(RuntimeException::class);
46
        $this->expectExceptionMessage('Note exceeds the limit of 40 symbols');
47
        $this->model->update([], $note);
48
    }
49
}
50