mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
class API_OAuth2_AuthCodeTest extends \PhraseanetTestCase
|
|
{
|
|
/**
|
|
* @var API_OAuth2_AuthCode
|
|
*/
|
|
protected $object;
|
|
protected $code;
|
|
|
|
protected $account;
|
|
protected $application;
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
$this->account = API_OAuth2_Account::load_with_user(self::$DI['app'], self::$DI['oauth2-app-user'], self::$DI['user']);
|
|
$expires = time() + 100;
|
|
$this->code = random::generatePassword(8);
|
|
$this->object = API_OAuth2_AuthCode::create(self::$DI['app'], $this->account, $this->code, $expires);
|
|
}
|
|
|
|
public function testGet_code()
|
|
{
|
|
$this->assertEquals($this->code, $this->object->get_code());
|
|
}
|
|
|
|
public function testGet_account()
|
|
{
|
|
$this->assertInstanceOf('API_OAuth2_Account', $this->object->get_account());
|
|
}
|
|
|
|
public function testGet_redirect_uri()
|
|
{
|
|
$this->assertEquals('', $this->object->get_redirect_uri());
|
|
}
|
|
|
|
public function testSet_redirect_uri()
|
|
{
|
|
$redirect_uri = 'https://www.google.com';
|
|
$this->assertEquals('', $this->object->get_redirect_uri());
|
|
$this->object->set_redirect_uri($redirect_uri);
|
|
$this->assertEquals($redirect_uri, $this->object->get_redirect_uri());
|
|
}
|
|
|
|
public function testGet_expires()
|
|
{
|
|
$this->assertInternalType('string', $this->object->get_expires());
|
|
}
|
|
|
|
public function testGet_scope()
|
|
{
|
|
$this->assertEquals('', $this->object->get_scope());
|
|
}
|
|
|
|
public function testSet_scope()
|
|
{
|
|
$scope = 'prout';
|
|
$this->assertEquals('', $this->object->get_scope());
|
|
$this->object->set_scope($scope);
|
|
$this->assertEquals($scope, $this->object->get_scope());
|
|
}
|
|
|
|
public function testLoad_codes_by_account()
|
|
{
|
|
$this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(self::$DI['app'], $this->account)));
|
|
$this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(self::$DI['app'], $this->account)) > 0);
|
|
}
|
|
}
|