Completed
Push — master ( 3528be...829c65 )
by Laurynas
03:21
created

EntryTest::testCreatesEntryWithEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
10
    public function testInvalidCredentials()
11
    {
12
        self::expectException("\\Qualia\\Exceptions\\RequestException");
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit_Framework_TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
        /** @scrutinizer ignore-call */ self::expectException("\\Qualia\\Exceptions\\RequestException");
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::expectException("InvalidArgumentException");
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit_Framework_TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ self::expectException("InvalidArgumentException");
Loading history...
23
24
        Entry::build($this->client)
25
             ->send();
26
    }
27
28
    public function allowsOnlyCorrectDateNotUnixTime()
29
    {
30
        self::expectException("InvalidArgumentException");
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit_Framework_TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        /** @scrutinizer ignore-call */ self::expectException("InvalidArgumentException");
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::expectException("InvalidArgumentException");
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit_Framework_TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        /** @scrutinizer ignore-call */ self::expectException("InvalidArgumentException");
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")
0 ignored issues
show
Bug introduced by
'Tester' of type string is incompatible with the type null expected by parameter $lastName of Qualia\Submission\Entry::name(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
             ->name('q_KCyzOs7VqevWbEO0', "Unit", /** @scrutinizer ignore-type */ "Tester")
Loading history...
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
}