|
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::expectException("\\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::expectException("InvalidArgumentException"); |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
Entry::build($this->client) |
|
25
|
|
|
->send(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function allowsOnlyCorrectDateNotUnixTime() |
|
29
|
|
|
{ |
|
30
|
|
|
self::expectException("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 allowsOnlyCorrectDate() |
|
41
|
|
|
{ |
|
42
|
|
|
self::expectException("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 testWithAllFields() |
|
76
|
|
|
{ |
|
77
|
|
|
$id = uniqid('', true); |
|
78
|
|
|
|
|
79
|
|
|
$response = Entry::build($this->client) |
|
80
|
|
|
->uniqueId($id) |
|
81
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
|
82
|
|
|
->name('q_KCyzOs7VqevWbEO0', "Unit", "Tester") |
|
|
|
|
|
|
83
|
|
|
->date('q_1J75WdyBwVpwlJUM', date('Y-m-d')) |
|
84
|
|
|
->response('q_KCyzOs7VqevWbEO0', ['o_wCcuY5a54YBeXLC1', 'o_ACvo61cUuKXxD5C1']) |
|
85
|
|
|
->send(); |
|
86
|
|
|
|
|
87
|
|
|
self::assertEquals('success', $response['message']); |
|
88
|
|
|
self::assertArrayHasKey('id', $response); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function testCreatesEntryWithEmailAndMarksCompleted() |
|
92
|
|
|
{ |
|
93
|
|
|
$id = uniqid('', true); |
|
94
|
|
|
|
|
95
|
|
|
$response = Entry::build($this->client) |
|
96
|
|
|
->uniqueId($id) |
|
97
|
|
|
->email('q_3RYJ4MpggyMFuU50', $id."[email protected]") |
|
98
|
|
|
->send(true); |
|
99
|
|
|
|
|
100
|
|
|
self::assertEquals('success', $response['message']); |
|
101
|
|
|
self::assertArrayHasKey('id', $response); |
|
102
|
|
|
} |
|
103
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.