Code Duplication    Length = 65-65 lines in 2 locations

tests/Document/CheckTest.php 1 location

@@ 10-74 (lines=65) @@
7
use Isign\QueryInterface;
8
use Isign\Tests\TestCase;
9
10
class CheckTest extends TestCase
11
{
12
    const TYPE = 'pdf';
13
    const NAME = 'document.pdf';
14
15
    /** @var  Check */
16
    private $query;
17
18
    public function setUp()
19
    {
20
        $this->query = new Check(
21
            self::TYPE,
22
            __DIR__.'/../data/document.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 Check(self::TYPE, null);
47
        $method->getFields();
48
    }
49
50
    public function testGetAction()
51
    {
52
        $this->assertSame('check', $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\CheckResult', $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

tests/Document/TimestampTest.php 1 location

@@ 10-74 (lines=65) @@
7
use Isign\QueryInterface;
8
use Isign\Tests\TestCase;
9
10
class TimestampTest extends TestCase
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(
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