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

MessageAlertTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSettersAndGetters() 0 8 1
A dataSettersAndGetters() 0 13 1
A serialized() 0 4 1
1
<?php
2
3
namespace Apns;
4
5
class MessageAlertTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @dataProvider dataSettersAndGetters
9
     */
10
    public function testSettersAndGetters($method, $jsonKey)
11
    {
12
        $alert = new MessageAlert();
13
        $alert->{'set'.$method}('foo');
14
15
        $this->assertSame('foo', $alert->{'get'.$method}());
16
        $this->assertSame([$jsonKey => 'foo'], $this->serialized($alert));
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public function dataSettersAndGetters()
23
    {
24
        return [
25
            ['Title', 'title'],
26
            ['Body', 'body'],
27
            ['TitleLocKey', 'title-loc-key'],
28
            ['TitleLocArgs', 'title-loc-args'],
29
            ['ActionLocKey', 'action-loc-key'],
30
            ['LocKey', 'loc-key'],
31
            ['LocArgs', 'loc-args'],
32
            ['LaunchImage', 'laungh-image'],
33
        ];
34
    }
35
36
    /**
37
     * @param MessageAlert $msg
38
     * @return array
39
     */
40
    private function serialized(MessageAlert $msg)
41
    {
42
        return json_decode(json_encode($msg), true);
43
    }
44
}