Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Add new test case and refactor ScopeTest
Browse files Browse the repository at this point in the history
Added test case 'testEqual' to enhance the coverage of code in ScopeTest. Simplified the occurrences of UnknownScopeCodeException in all test cases, and corrected the order of scope codes inside the 'testInitFromString' test case.

Signed-off-by: mesilov <[email protected]>
  • Loading branch information
mesilov committed Jul 6, 2024
1 parent b460b22 commit 5da2ef1
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/Unit/Core/Credentials/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
use Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException;
use PHPUnit\Framework\TestCase;

/**
* Class ScopeTest
*
* @package Bitrix24\SDK\Tests\Unit\Core
*/
class ScopeTest extends TestCase
{
/**
* @throws \Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException
* @throws UnknownScopeCodeException
*/
public function testBuildScopeFromArray(): void
{
Expand Down Expand Up @@ -73,6 +68,16 @@ public function testUnknownScope(): void
$scope = new Scope(['fooo']);
}

/**
* @throws UnknownScopeCodeException
*/
public function testEqual(): void
{
$scope = Scope::initFromString('crm,telephony');
$this->assertTrue($scope->equal(Scope::initFromString('telephony,crm')));
$this->assertFalse($scope->equal(Scope::initFromString('telephony')));
}

/**
* @throws UnknownScopeCodeException
*/
Expand All @@ -89,18 +94,20 @@ public function testWrongScopeCode(): void
{
$scope = new Scope(['CRM', 'Call', 'im']);

$this->assertEquals(['crm', 'call', 'im'], $scope->getScopeCodes());
$this->assertEquals(['call', 'crm', 'im'], $scope->getScopeCodes());
}

/**
* @return void
* @throws \Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException
* @throws UnknownScopeCodeException
* @covers \Bitrix24\SDK\Core\Credentials\Scope::initFromString
* @testdox Test init Scope from string
*/
public function testInitFromString(): void
{
$scopeList = ['crm', 'telephony', 'call', 'user_basic', 'placement', 'im', 'imopenlines'];
sort($scopeList);
$scope = Scope::initFromString('crm,telephony,call,user_basic,placement,im,imopenlines');
$this->assertEquals(['crm', 'telephony', 'call', 'user_basic', 'placement', 'im', 'imopenlines'], $scope->getScopeCodes());
$this->assertEquals($scopeList, $scope->getScopeCodes());
}
}

0 comments on commit 5da2ef1

Please sign in to comment.