Completed
Pull Request — develop (#14)
by Rimas
03:51
created

TimestampTest::testGetFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
4
namespace Isign\Tests\Document;
5
6
use Isign\Document\Timestamp;
7
use Isign\QueryInterface;
8
use Isign\Tests\TestCase;
9
10 View Code Duplication
class TimestampTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    const TYPE = 'pdf';
13
    const NAME = 'signed.pdf';
14
15
    /** @var  Check */
16
    private $query;
17
18
    public function setUp()
19
    {
20
        $this->query = new Timestamp(
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Isign\Document\Time... '/../data/signed.pdf') of type object<Isign\Document\Timestamp> is incompatible with the declared type object<Isign\Tests\Document\Check> of property $query.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
21
            self::TYPE,
22
            __DIR__ . '/../data/signed.pdf'
23
        );
24
    }
25
26
    public function testGetFields()
27
    {
28
        $fields = $this->query->getFields();
29
30
        $this->assertArrayHasKey('type', $fields);
31
        $this->assertArrayHasKey('file', $fields);
32
        $this->assertArrayHasKey('name', $fields['file']);
33
        $this->assertArrayHasKey('digest', $fields['file']);
34
        $this->assertArrayHasKey('content', $fields['file']);
35
36
        $this->assertSame(self::TYPE, $fields['type']);
37
        $this->assertSame(self::NAME, $fields['file']['name']);
38
    }
39
40
    /**
41
     * @expectedException \RuntimeException
42
     * @expectedExceptionMessage File "" does not exist
43
     */
44
    public function testGetFileFieldsWithNonExistingFile()
45
    {
46
        $method = new Timestamp(self::TYPE, '');
47
        $method->getFields();
48
    }
49
50
    public function testGetAction()
51
    {
52
        $this->assertSame('timestamp', $this->query->getAction());
53
    }
54
55
    public function testGetMethod()
56
    {
57
        $this->assertSame(QueryInterface::POST, $this->query->getMethod());
58
    }
59
60
    public function testCreateResult()
61
    {
62
        $this->assertInstanceOf('Isign\Document\TimestampResult', $this->query->createResult());
63
    }
64
65
    public function testHasValidationConstraints()
66
    {
67
        $collection = $this->query->getValidationConstraints();
68
69
        $this->assertInstanceOf(
70
            'Symfony\Component\Validator\Constraints\Collection',
71
            $collection
72
        );
73
    }
74
}
75