mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2025-11-17 02:30:54 -03:00
Including Tests and verifications for errors
This commit is contained in:
34
tests/oauthTest.php
Normal file
34
tests/oauthTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use BrunoFontes\Memsource;
|
||||
|
||||
final class oauthTest extends TestCase
|
||||
{
|
||||
public function testOauthGetAuthorizationCodeUrl()
|
||||
{
|
||||
$customServerURL = 'http://myPersonalMemsource.com';
|
||||
$api = new Memsource(null, $customServerURL);
|
||||
$expected = $customServerURL . '/oauth/authorize?response_type=code&client_id=id&redirect_uri=http%3A%2F%2Furi&scope=openid';
|
||||
$memsourceUrl = $api->oauth()->getAuthorizationCodeUrl('id', 'http://uri');
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$memsourceUrl
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetAccessTokenExceptionOnFakeCode()
|
||||
{
|
||||
$api = new Memsource();
|
||||
$this->expectException(\Exception::class);
|
||||
$token = $api->oauth()->getAccessToken('fakeCode', 'fakeId', 'fakePass', 'http://any');
|
||||
}
|
||||
|
||||
public function testGetAccessTokenExceptionOnEmptyCode()
|
||||
{
|
||||
$api = new Memsource();
|
||||
$this->expectException(\Exception::class);
|
||||
$token = $api->oauth()->getAccessToken('', '', '', '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user