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 |
|
|
|
|
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
|
|
|
|
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.