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

CheckTest::testGetFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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