mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2025-02-21 20:56:08 +00:00

- File: '... /tests/unit/phpunit/modules/CampaignTrackers/CampaignTrackerTest.php' - Replaced 4 occurrence(s) of 'new CampaignTracker()' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/modules/SugarFeed/SugarFeedTest.php' - Replaced 1 occurrence(s) of 'new Lead()' - Replaced 1 occurrence(s) of 'new User()' - Replaced 1 occurrence(s) of 'new Administration()' - Replaced 5 occurrence(s) of 'new SugarFeed()' - File: '... /tests/unit/phpunit/modules/EmailTemplates/EmailTemplateTest.php' - Replaced 1 occurrence(s) of 'new Lead()' - Replaced 1 occurrence(s) of 'new Prospect()' - Replaced 2 occurrence(s) of 'new Campaign()' - Replaced 2 occurrence(s) of 'new Contact()' - Replaced 2 occurrence(s) of 'new Account()' - Replaced 27 occurrence(s) of 'new EmailTemplate()' - Replaced 2 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/modules/EAPM/EAPMTest.php' - Replaced 9 occurrence(s) of 'new EAPM()' - File: '... /tests/unit/phpunit/modules/AOW_Actions/AOW_ActionTest.php' - Replaced 1 occurrence(s) of 'new User()' - Replaced 3 occurrence(s) of 'new AOW_Action()' - Replaced 1 occurrence(s) of 'new AOW_WorkFlow()' - File: '... /tests/unit/phpunit/modules/Emails/EmailTest.php' - Replaced 71 occurrence(s) of 'new Email()' - Replaced 1 occurrence(s) of 'new User()' - Replaced 5 occurrence(s) of 'new InboundEmail()' - File: '... /tests/unit/phpunit/modules/Emails/EmailFromValidatorTest.php' - Replaced 3 occurrence(s) of 'new Email()' - File: '... /tests/unit/phpunit/modules/Emails/NonGmailSentFolderHandlerTest.php' - Replaced 9 occurrence(s) of 'new InboundEmail()' - File: '... /tests/unit/phpunit/modules/Cases/CaseTest.php' - Replaced 15 occurrence(s) of 'new aCase()' - Replaced 1 occurrence(s) of 'new User()' - File: '... /tests/unit/phpunit/modules/OAuthKeys/OAuthKeyTest.php' - Replaced 1 occurrence(s) of 'new User()' - Replaced 4 occurrence(s) of 'new OAuthKey()'
88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php
|
|
|
|
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
|
|
|
|
class OAuthKeyTest extends SuitePHPUnitFrameworkTestCase
|
|
{
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
global $current_user;
|
|
get_sugar_config_defaults();
|
|
$current_user = BeanFactory::newBean('Users');
|
|
}
|
|
|
|
public function testOAuthKey()
|
|
{
|
|
// Execute the constructor and check for the Object type and attributes
|
|
$oauthKey = BeanFactory::newBean('OAuthKeys');
|
|
|
|
$this->assertInstanceOf('OAuthKey', $oauthKey);
|
|
$this->assertInstanceOf('Basic', $oauthKey);
|
|
$this->assertInstanceOf('SugarBean', $oauthKey);
|
|
|
|
$this->assertAttributeEquals('OAuthKeys', 'module_dir', $oauthKey);
|
|
$this->assertAttributeEquals('OAuthKey', 'object_name', $oauthKey);
|
|
$this->assertAttributeEquals('oauth_consumer', 'table_name', $oauthKey);
|
|
|
|
$this->assertAttributeEquals(true, 'disable_row_level_security', $oauthKey);
|
|
}
|
|
|
|
public function testMain()
|
|
{
|
|
// test
|
|
$oauthKey = BeanFactory::newBean('OAuthKeys');
|
|
|
|
//preset required attributes
|
|
$oauthKey->name = 'test';
|
|
$oauthKey->c_key = 'key';
|
|
$oauthKey->c_secret = 'secret';
|
|
|
|
$oauthKey->save();
|
|
|
|
//test getByKey method
|
|
$this->getByKey($oauthKey->c_key);
|
|
|
|
//test fetchKey method
|
|
$this->fetchKey($oauthKey->c_key);
|
|
|
|
//test mark_deleted method
|
|
$this->mark_deleted($oauthKey->id);
|
|
}
|
|
|
|
public function getByKey($key)
|
|
{
|
|
$oauthKey = BeanFactory::newBean('OAuthKeys');
|
|
|
|
//test with a invalid id
|
|
$result = $oauthKey->getByKey('');
|
|
$this->assertEquals(false, $result);
|
|
|
|
//test with a valid id
|
|
$result = $oauthKey->getByKey($key);
|
|
$this->assertInstanceOf('OAuthKey', $result);
|
|
}
|
|
|
|
public function fetchKey($key)
|
|
{
|
|
//test with a invalid id
|
|
$result = OAuthKey::fetchKey('');
|
|
$this->assertEquals(false, $result);
|
|
|
|
//test with a valid id
|
|
$result = OAuthKey::fetchKey($key);
|
|
$this->assertInstanceOf('OAuthKey', $result);
|
|
}
|
|
|
|
public function mark_deleted($id)
|
|
{
|
|
$oauthKey = BeanFactory::newBean('OAuthKeys');
|
|
|
|
$oauthKey->mark_deleted($id);
|
|
|
|
//verify that record is deleted
|
|
$result = $oauthKey->getByKey($id);
|
|
$this->assertEquals(false, $result);
|
|
}
|
|
}
|