Completed
Branch master (431168)
by Gennady
09:40
created

ClientTest::dataValidSslCert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Apns;
4
5
class ClientTest extends \PHPUnit_Framework_TestCase
6
{
7
    public function testCreateSandbox()
8
    {
9
        $client = new Client('', true);
10
        $this->assertContains('development', $client->getServer());
11
    }
12
13
    /**
14
     * @dataProvider dataValidSslCert
15
     */
16
    public function testSslCert($sslCert)
17
    {
18
        $client = new Client($sslCert, true);
19
        $this->assertSame($sslCert, $client->getSslCert());
20
    }
21
22
    public function dataValidSslCert()
23
    {
24
        return [
25
            ['foo.pem'],
26
            [['foo.pem', 'bar']],
27
        ];
28
    }
29
30
    public function testCreateProd()
31
    {
32
        $client = new Client('', false);
33
        $this->assertNotContains('develop', $client->getServer());
34
    }
35
36
    public function testCreatePushURI()
37
    {
38
        $client = new Client('', true);
39
        $pushUri = $client->getPushURI((new Message())->setDeviceIdentifier('foobar'));
40
41
        $this->assertContains('develop', $pushUri);
42
        $this->assertContains('foobar', $pushUri);
43
    }
44
45
    public function testSend()
46
    {
47
        $mock = $this->getMockCallable();
48
        $client = new Client('', true, $mock);
49
        $message = new Message();
50
51
        $mock->expects($this->once())->method('__invoke')->with($client, $message);
52
53
        $client->send($message);
54
    }
55
56
    /**
57
     * @return \PHPUnit_Framework_MockObject_MockObject
58
     */
59
    private function getMockCallable()
60
    {
61
        return $this->getMockBuilder('object')->setMethods(['__invoke'])->getMock();
62
    }
63
}
64