-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDocumentParametersSpec.php
More file actions
81 lines (66 loc) · 2.19 KB
/
DocumentParametersSpec.php
File metadata and controls
81 lines (66 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace spec\rosette\api;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use rosette\api\RosetteConstants;
class DocumentParametersSpec extends ObjectBehavior
{
private $sampleStringData = 'Sample string data';
public function it_is_initializable()
{
$this->shouldHaveType('rosette\api\DocumentParameters');
}
public function it_validates_no_content_or_content_uri()
{
$this->shouldThrow(RosetteConstants::$RosetteExceptionFullClassName)->duringValidate();
}
public function it_validates_no_content_and_content_uri()
{
$this->content = 'content';
$this->contentUri = 'contentUri';
$this->shouldThrow(RosetteConstants::$RosetteExceptionFullClassName)->duringValidate();
}
public function it_loads_document_file()
{
$this->loadDocumentFile('path');
$this->getMultiPartContent()->shouldNotBe('');
$this->content->shouldBe('');
}
public function it_loads_document_string()
{
$this->loadDocumentString($this->sampleStringData);
$this->content->shouldBe($this->sampleStringData);
$this->getMultiPartContent()->shouldBe('');
}
// These test the abstract RosetteParamsSetBase
public function it_sets_and_gets_a_property()
{
$property = 'content';
$value = 'Sample content';
$this->Set($property, $value);
$this->Get($property)->shouldBe($value);
}
public function it_throws_if_invalid_property()
{
$this->shouldThrow(RosetteConstants::$RosetteExceptionFullClassName)->duringGet('bogus');
}
public function it_serialized()
{
$options = array();
$this->content = 'Sample Content';
$this->serialize($options)->shouldBeLike('{"content":"Sample Content"}');
}
public function it_serialized_with_options()
{
$options = array();
$this->content = 'Sample Content';
$options["test"] = "foo";
$this->serialize($options)->shouldBeLike('{"content":"Sample Content","options":{"test":"foo"}}');
}
}
namespace rosette\api;
// mock the global function file_get_contents()
function file_get_contents($path)
{
return 'Sample string data';
}