Completed
Push — master ( 3656be...0c0759 )
by Mike
03:02
created

SugarAPITest::testSetCredentials()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace SugarAPI\SDK\Tests\Clients;
4
5
use SugarAPI\SDK\SugarAPI;
6
7
/**
8
 * Class SugarAPITest
9
 * @package SugarAPI\SDK\Tests\Clients
10
 * @coversDefaultClass SugarAPI\SDK\SugarAPI
11
 * @group clients
12
 */
13
class SugarAPITest extends \PHPUnit_Framework_TestCase {
14
15
16
    public static function setUpBeforeClass()
17
    {
18
    }
19
20
    public static function tearDownAfterClass()
21
    {
22
    }
23
24
    protected $SugarAPI;
25
    protected $credentials = array(
26
        'username' => 'admin',
27
        'password' => 'asdf',
28
        'client_id' => 'sugar',
29
        'client_secret' => '',
30
        'platform' => 'api'
31
    );
32
33
34
    public function setUp()
35
    {
36
        $this->SugarAPI = new SugarAPI();
37
        parent::setUp();
38
    }
39
40
    public function tearDown()
41
    {
42
        unset($this->SugarAPI);
43
        parent::tearDown();
44
    }
45
46
    /**
47
     * @test
48
     * @covers ::setCredentials
49
     * @group sugarapi
50
     */
51
    public function testSetCredentials()
52
    {
53
        $this->SugarAPI->setCredentials(array('username' => 'admin'));
54
        $this->assertEquals(array(
55
            'username' => 'admin',
56
            'password' => '',
57
            'client_id' => 'sugar',
58
            'client_secret' => '',
59
            'platform' => 'api'
60
        ),$this->SugarAPI->getCredentials());
61
        $this->SugarAPI->setCredentials(array('password' => 'asdf'));
62
        $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials());
63
        $this->SugarAPI->setCredentials(array());
64
        $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials());
65
        $this->SugarAPI->setCredentials($this->credentials);
66
        $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials());
67
        $this->SugarAPI->setCredentials(array('foo' => 'bar' ));
68
        $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials());
69
    }
70
71
}
72