| 1 | <?php |
||
| 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 |