Passed
Branch develop (84afed)
by Paulius
02:35
created

CheckTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 26
dl 0
loc 60
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testGetAction() 0 3 1
A testHasValidationConstraints() 0 7 1
A testCreateResult() 0 3 1
A testGetFileFieldsWithNonExistingFile() 0 6 1
A testGetMethod() 0 3 1
A testGetFields() 0 12 1
1
<?php
2
namespace Dokobit\Gateway\Tests\Query\File;
3
4
use Dokobit\Gateway\Query\File\Check;
5
use Dokobit\Gateway\Query\QueryInterface;
6
use Dokobit\Gateway\Tests\TestCase;
7
8
class CheckTest extends TestCase
9
{
10
    const TYPE = 'pdf';
11
    const NAME = 'document.pdf';
12
13
    /** @var Check */
14
    private $query;
15
16
    protected function setUp(): void
17
    {
18
        $this->query = new Check(
19
            self::TYPE,
20
            __DIR__.'/../../data/document.pdf'
21
        );
22
    }
23
24
    public function testGetFields()
25
    {
26
        $fields = $this->query->getFields();
27
28
        $this->assertArrayHasKey('type', $fields);
29
        $this->assertArrayHasKey('file', $fields);
30
        $this->assertArrayHasKey('name', $fields['file']);
31
        $this->assertArrayHasKey('digest', $fields['file']);
32
        $this->assertArrayHasKey('content', $fields['file']);
33
34
        $this->assertSame(self::TYPE, $fields['type']);
35
        $this->assertSame(self::NAME, $fields['file']['name']);
36
    }
37
38
    public function testGetFileFieldsWithNonExistingFile()
39
    {
40
        $this->expectException(\RuntimeException::class);
41
        $this->expectExceptionMessage('File "" does not exist');
42
        $method = new Check(self::TYPE, '');
43
        $method->getFields();
44
    }
45
46
    public function testGetAction()
47
    {
48
        $this->assertSame('file/check', $this->query->getAction());
49
    }
50
51
    public function testGetMethod()
52
    {
53
        $this->assertSame(QueryInterface::POST, $this->query->getMethod());
54
    }
55
56
    public function testCreateResult()
57
    {
58
        $this->assertInstanceOf('Dokobit\Gateway\Result\File\CheckResult', $this->query->createResult());
59
    }
60
61
    public function testHasValidationConstraints()
62
    {
63
        $collection = $this->query->getValidationConstraints();
64
65
        $this->assertInstanceOf(
66
            'Symfony\Component\Validator\Constraints\Collection',
67
            $collection
68
        );
69
    }
70
}
71