AddressCrudTest::testUpdateAddressTooLongNote()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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