-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.0' of https://github.com/sugarcrm/rest-php-client
- Loading branch information
Showing
4 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/** | ||
* ©[2017] SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license. | ||
*/ | ||
|
||
namespace Sugarcrm\REST\Tests\Storage; | ||
|
||
use Sugarcrm\REST\Storage\SugarStaticStorage; | ||
|
||
|
||
/** | ||
* Class SugarStaticStorageTest | ||
* @package Sugarcrm\REST\Tests\Storage | ||
* @coversDefaultClass Sugarcrm\REST\Storage\SugarStaticStorage | ||
* @group SugarStaticStorageTest | ||
*/ | ||
class SugarStaticStorageTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
protected $token = array( | ||
'access_token' => '1234' | ||
); | ||
|
||
public static function setUpBeforeClass() | ||
{ | ||
//Add Setup for static properties here | ||
} | ||
|
||
public static function tearDownAfterClass() | ||
{ | ||
//Add Tear Down for static properties here | ||
} | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @covers ::store | ||
* @covers ::get | ||
* @covers ::remove | ||
* @covers ::formatKey | ||
* | ||
*/ | ||
public function testStorage(){ | ||
$Storage = new SugarStaticStorage(); | ||
$this->assertEquals(true,$Storage->store(array( | ||
'server' => 'test.sugarondemand.com' | ||
),$this->token)); | ||
$token = $Storage->get('test.sugarondemand.com_'); | ||
$this->assertEquals($this->token,json_decode($token,TRUE)); | ||
$this->assertEquals(true,$Storage->remove(array( | ||
'server' => 'test.sugarondemand.com' | ||
))); | ||
$token = $Storage->get('test.sugarondemand.com_'); | ||
$this->assertEquals(NULL,$token); | ||
|
||
|
||
$this->assertEquals(true,$Storage->store(array( | ||
'client_id' => 'test', | ||
'platform' => 'base' | ||
),$this->token)); | ||
$token = $Storage->get('test_base'); | ||
$this->assertEquals(json_encode($this->token),$token); | ||
$this->assertEquals(true,$Storage->store(array( | ||
'server' => 'test.sugarondemand.com', | ||
'platform' => 'base' | ||
),$this->token)); | ||
$token = $Storage->get('test.sugarondemand.com_base'); | ||
$this->assertEquals(json_encode($this->token),$token); | ||
$this->assertEquals(true,$Storage->store('foobar',$this->token)); | ||
$token = $Storage->get('foobar'); | ||
$this->assertEquals(json_encode($this->token),$token); | ||
|
||
$this->assertEquals(true,$Storage->remove(array( | ||
'server' => 'test.sugarondemand.com', | ||
'platform' => 'base' | ||
))); | ||
$this->assertEquals(true,$Storage->remove('test_base')); | ||
$token = $Storage->get(array( | ||
'server' => 'test.sugarondemand.com', | ||
'platform' => 'base' | ||
)); | ||
$this->assertEquals(NULL,$token); | ||
} | ||
|
||
} |