Completed
Push — master ( b2c31d...142309 )
by Vitaliy
01:49
created

CertificateTest::shouldSuccessCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the AppleApnPush package
5
 *
6
 * (c) Vitaliy Zhuk <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code
10
 */
11
12
namespace Tests\Apple\ApnPush\Certificate;
13
14
use Apple\ApnPush\Certificate\Certificate;
15
use PHPUnit\Framework\TestCase;
16
17
class CertificateTest extends TestCase
18
{
19
    /**
20
     * @test
21
     *
22
     * @expectedException \Apple\ApnPush\Exception\CertificateFileNotFoundException
23
     * @expectedExceptionMessage The certificate file "/path/to/missing/certificate.pem" was not found.
24
     */
25
    public function shouldFailIfCertificateNotFound()
26
    {
27
        new Certificate('/path/to/missing/certificate.pem', '');
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function shouldSuccessCreate()
34
    {
35
        $tmpDir = sys_get_temp_dir();
36
        $file = $tmpDir.'/'.md5(uniqid(random_int(0, 9999), true)).'.pem';
37
        touch($file);
38
39
        $certificate = new Certificate($file, 'pass-phrase');
40
41
        self::assertEquals($file, $certificate->getPath());
42
        self::assertEquals('pass-phrase', $certificate->getPassPhrase());
43
44
        unlink($file);
45
    }
46
}
47