Change to be able to return called API version

This commit is contained in:
Benoît Burnichon
2015-12-16 16:31:42 +01:00
parent 0dfe794145
commit b2ee2668a1
19 changed files with 247 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\ControllerProvider\Api\V1;
use Alchemy\Phrasea\ControllerProvider\Api\V2;
use Alchemy\Phrasea\Model\Manipulator\ApiAccountManipulator;
/**
@@ -24,16 +24,16 @@ class ApiAccountManipulatorTest extends \PhraseanetTestCase
public function testCreate()
{
$nbApps = count(self::$DI['app']['repo.api-accounts']->findAll());
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$this->assertGreaterThan($nbApps, count(self::$DI['app']['repo.api-accounts']->findAll()));
$this->assertFalse($account->isRevoked());
$this->assertEquals(V1::VERSION, $account->getApiVersion());
$this->assertEquals(V2::VERSION, $account->getApiVersion());
$this->assertGreaterThan($nbApps, count(self::$DI['app']['repo.api-accounts']->findAll()));
}
public function testDelete()
{
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$accountMem = clone $account;
$countBefore = count(self::$DI['app']['repo.api-accounts']->findAll());
self::$DI['app']['manipulator.api-oauth-token']->create($account);
@@ -45,7 +45,7 @@ class ApiAccountManipulatorTest extends \PhraseanetTestCase
public function testUpdate()
{
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$account->setApiVersion(24);
$this->sut->update($account);
$account = self::$DI['app']['repo.api-accounts']->find($account->getId());
@@ -54,14 +54,14 @@ class ApiAccountManipulatorTest extends \PhraseanetTestCase
public function testAuthorizeAccess()
{
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$this->sut->authorizeAccess($account);
$this->assertFalse($account->isRevoked());
}
public function testRevokeAccess()
{
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $this->sut->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$this->sut->revokeAccess($account);
$this->assertTrue($account->isRevoked());
}

View File

@@ -2,6 +2,7 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\ControllerProvider\Api\V2;
use Alchemy\Phrasea\Model\Manipulator\ApiLogManipulator;
use Alchemy\Phrasea\Model\Manipulator\ApiAccountManipulator;
use Symfony\Component\HttpFoundation\Request;
@@ -16,7 +17,7 @@ class ApiLogManipulatorTest extends \PhraseanetTestCase
public function testCreate()
{
$manipulator = new ApiAccountManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-accounts']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$nbLogs = count(self::$DI['app']['repo.api-logs']->findAll());
$manipulator = new ApiLogManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-logs']);
$manipulator->create($account, Request::create('/databoxes/list/', 'POST'), new Response());
@@ -41,7 +42,7 @@ class ApiLogManipulatorTest extends \PhraseanetTestCase
public function testDelete()
{
$manipulator = new ApiAccountManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-accounts']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$manipulator = new ApiLogManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-logs']);
$log = $manipulator->create($account, Request::create('/databoxes/list/', 'POST'), new Response());
$countBefore = count(self::$DI['app']['repo.api-logs']->findAll());
@@ -52,7 +53,7 @@ class ApiLogManipulatorTest extends \PhraseanetTestCase
public function testUpdate()
{
$manipulator = new ApiAccountManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-accounts']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user']);
$account = $manipulator->create(self::$DI['oauth2-app-user'], self::$DI['user'], V2::VERSION);
$manipulator = new ApiLogManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.api-logs']);
$log = $manipulator->create($account, Request::create('/databoxes/list/', 'POST'), new Response());
$log->setAspect('a-new-aspect');