Completed
Push — master ( 1b2de0...45960b )
by Laurynas
59:18 queued 14:19
created

EntryTest::testCreatesEntryWithEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

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.

Loading history...
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");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

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.

Loading history...
23
24
        Entry::build($this->client)
25
             ->send();
26
    }
27
28
    public function allowsOnlyCorrectDateNotUnixTime()
29
    {
30
        self::setExpectedException("InvalidArgumentException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

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.

Loading history...
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::setExpectedException("InvalidArgumentException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

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.

Loading history...
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
}