CredentialsTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateFromArray() 0 7 1
A testCreateFromString() 0 6 1
A testCreateFromInvalidArray() 0 4 1
A testCreateFromInvalidValue() 0 4 1
A testToArray() 0 6 1
1
<?php
2
namespace Wonnova\SDK\Test\Auth;
3
4
use PHPUnit_Framework_TestCase as TestCase;
5
use Wonnova\SDK\Auth\Credentials;
6
7
/**
8
 * Class CredentialsTest
9
 * @author Wonnova
10
 * @link http://www.wonnova.com
11
 */
12
class CredentialsTest extends TestCase
13
{
14
    public function testCreateFromArray()
15
    {
16
        $expected = 'expected_value';
17
        $data = ['key' => $expected];
18
        $credentials = new Credentials($data);
19
        $this->assertEquals($expected, $credentials->getKey());
20
    }
21
22
    public function testCreateFromString()
23
    {
24
        $expected = 'expected_value';
25
        $credentials = new Credentials($expected);
26
        $this->assertEquals($expected, $credentials->getKey());
27
    }
28
29
    /**
30
     * @expectedException \Wonnova\SDK\Exception\InvalidArgumentException
31
     */
32
    public function testCreateFromInvalidArray()
33
    {
34
        new Credentials([]);
35
    }
36
37
    /**
38
     * @expectedException \Wonnova\SDK\Exception\InvalidArgumentException
39
     */
40
    public function testCreateFromInvalidValue()
41
    {
42
        new Credentials(123);
43
    }
44
45
    public function testToArray()
46
    {
47
        $data = ['key' => 'expected_value'];
48
        $credentials = new Credentials($data);
49
        $this->assertEquals($data, $credentials->toArray());
50
    }
51
}
52