1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Qualia\Client; |
4
|
|
|
use Qualia\Exceptions\RequestException; |
5
|
|
|
use Qualia\Submission\Entry; |
6
|
|
|
|
7
|
|
|
class EntryTest extends TestCase |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function testInvalidCredentials() |
11
|
|
|
{ |
12
|
|
|
self::setExpectedException("\\Qualia\\Exceptions\\RequestException"); |
|
|
|
|
13
|
|
|
|
14
|
|
|
Entry::build(new Client('597768e728d8f1508f6d9f62', 'invalid-credentials')) |
15
|
|
|
->email('q_tVabQ3cUlwZTgQ10', '[email protected]') |
16
|
|
|
->send(); |
17
|
|
|
|
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function testFailsWithoutData() |
21
|
|
|
{ |
22
|
|
|
self::setExpectedException("InvalidArgumentException"); |
|
|
|
|
23
|
|
|
|
24
|
|
|
Entry::build($this->client) |
25
|
|
|
->send(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function allowsOnlyCorrectDateNotUnixTime() |
29
|
|
|
{ |
30
|
|
|
self::setExpectedException("InvalidArgumentException"); |
|
|
|
|
31
|
|
|
|
32
|
|
|
$id = uniqid('', true); |
33
|
|
|
|
34
|
|
|
Entry::build($this->client) |
35
|
|
|
->uniqueId($id) |
36
|
|
|
->date('q_1J75WdyBwVpwlJUM', time()) |
37
|
|
|
->send(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testAllowsOnlyCorrectDate() |
41
|
|
|
{ |
42
|
|
|
self::setExpectedException("InvalidArgumentException"); |
|
|
|
|
43
|
|
|
|
44
|
|
|
Entry::build($this->client) |
45
|
|
|
->date('q_1J75WdyBwVpwlJUM', 'invalid') |
46
|
|
|
->send(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testCreatesEntryWithEmail() |
50
|
|
|
{ |
51
|
|
|
$id = uniqid('', true); |
52
|
|
|
|
53
|
|
|
$response = Entry::build($this->client) |
54
|
|
|
->uniqueId($id) |
55
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
56
|
|
|
->send(); |
57
|
|
|
|
58
|
|
|
self::assertEquals('success', $response['message']); |
59
|
|
|
self::assertArrayHasKey('id', $response); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testSingleCheckbox() |
63
|
|
|
{ |
64
|
|
|
$id = uniqid('', true); |
65
|
|
|
|
66
|
|
|
$response = Entry::build($this->client) |
67
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
68
|
|
|
->response('q_tVabQ3cUlwZTgQ10', 'o_ACvo61cUuKXxD5C1') |
69
|
|
|
->send(); |
70
|
|
|
|
71
|
|
|
self::assertEquals('success', $response['message']); |
72
|
|
|
self::assertArrayHasKey('id', $response); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testSubmitWithLanguage() |
76
|
|
|
{ |
77
|
|
|
$response = Entry::build($this->client) |
78
|
|
|
->language('en') |
79
|
|
|
->date('q_1J75WdyBwVpwlJUM', date('Y-m-d')) |
80
|
|
|
->send(); |
81
|
|
|
|
82
|
|
|
self::assertEquals('success', $response['message']); |
83
|
|
|
self::assertArrayHasKey('id', $response); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testSubmitWithInvalidLanguage() |
87
|
|
|
{ |
88
|
|
|
self::setExpectedException("Qualia\Exceptions\RequestException"); |
|
|
|
|
89
|
|
|
|
90
|
|
|
$response = Entry::build($this->client) |
|
|
|
|
91
|
|
|
->language('xy') |
92
|
|
|
->date('q_1J75WdyBwVpwlJUM', date('Y-m-d')) |
93
|
|
|
->send(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function testWithAllFields() |
97
|
|
|
{ |
98
|
|
|
$id = uniqid('', true); |
99
|
|
|
|
100
|
|
|
$response = Entry::build($this->client) |
101
|
|
|
->uniqueId($id) |
102
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
103
|
|
|
->name('q_KCyzOs7VqevWbEO0', "Unit", "Tester") |
104
|
|
|
->date('q_1J75WdyBwVpwlJUM', date('Y-m-d')) |
105
|
|
|
->response('q_KCyzOs7VqevWbEO0', ['o_wCcuY5a54YBeXLC1', 'o_ACvo61cUuKXxD5C1']) |
106
|
|
|
->send(); |
107
|
|
|
|
108
|
|
|
self::assertEquals('success', $response['message']); |
109
|
|
|
self::assertArrayHasKey('id', $response); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testCreatesEntryWithEmailAndMarksCompleted() |
113
|
|
|
{ |
114
|
|
|
$id = uniqid('', true); |
115
|
|
|
|
116
|
|
|
$response = Entry::build($this->client) |
117
|
|
|
->uniqueId($id) |
118
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
119
|
|
|
->send(true); |
120
|
|
|
|
121
|
|
|
self::assertEquals('success', $response['message']); |
122
|
|
|
self::assertArrayHasKey('id', $response); |
123
|
|
|
} |
124
|
|
|
} |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.