CredentialsTest::testCreateFromInvalidValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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