Skip to content

Commit

Permalink
Improve other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gradinarufelix committed Oct 3, 2023
1 parent 353588d commit b484824
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion Tests/Unit/ZoomApiAccessTokenFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function getInvalidConfigurations(): array
* @dataProvider getInvalidConfigurations
* @test
*/
public function invalidConfigurationWillThrowException($invalidConfiguration): void
public function invalidConfigurationWillThrowException(array $invalidConfiguration): void
{
$this->expectException(ZoomApiException::class);
$this->expectExceptionMessage('Please set a Zoom Account ID, Client ID and Secret for CodeQ.ZoomApi to be able to authenticate.');
Expand Down Expand Up @@ -81,6 +81,39 @@ public function unsuccessfulRequestThrowsZoomApiException(): void
$factoryMock->createFromConfiguration();
}

public static function getInvalidAccessTokenScopes(): array
{
return [
['recording:read:admin,meeting:read:admin'],
['user:read:admin,meeting:read:admin'],
['user:read:admin,recording:read:admin'],
];
}

/**
* @test
* @dataProvider getInvalidAccessTokenScopes
* @param string $scopes
*
* @return void
*/
public function missingAccessTokenScopesThrowsZoomApiException(string $scopes): void
{
$this->expectException(ZoomApiException::class);
$this->expectExceptionMessage('Please ensure your Zoom app has the following scopes: user:read:admin, recording:read:admin, meeting:read:admin');


$handlerStack = HandlerStack::create(
new MockHandler([
new Response(200, [], json_encode(['access_token' => '1234567890', 'scope' => $scopes]))
])
);
$factoryMock = $this->getFactory($handlerStack);


$factoryMock->createFromConfiguration();
}

private function getFactory(HandlerStack $handlerStack = null): ZoomApiAccessTokenFactory|MockObject
{
$factory = $this->getAccessibleMock(ZoomApiAccessTokenFactory::class, ['buildClient'], [], '', false);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/ZoomApiServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function getUpcomingMeetingsWithEmptyResponseThrowsException()
}

/**
* @param Client $client
* @param HandlerStack|null $handlerStack
*
* @return ZoomApiService|MockObject
*/
Expand Down

0 comments on commit b484824

Please sign in to comment.