Browse Source

Move Provisioning api to PSR-4 (#24510)

* Move app to PSR-4

* Fix setUp method

* Fix the tests
tags/v9.1.0beta1
Joas Schilling 8 years ago
parent
commit
2a05035339

+ 1
- 0
apps/provisioning_api/appinfo/info.xml View File

<admin>admin-provisioning-api</admin> <admin>admin-provisioning-api</admin>
</documentation> </documentation>
<version>0.5.0</version> <version>0.5.0</version>
<namespace>Provisioning_API</namespace>
<types> <types>
<prevent_group_restriction/> <prevent_group_restriction/>
</types> </types>

apps/provisioning_api/lib/apps.php → apps/provisioning_api/lib/Apps.php View File


apps/provisioning_api/lib/groups.php → apps/provisioning_api/lib/Groups.php View File


apps/provisioning_api/lib/users.php → apps/provisioning_api/lib/Users.php View File

private $userManager; private $userManager;
/** @var IConfig */ /** @var IConfig */
private $config; private $config;
/** @var IGroupManager */
/** @var IGroupManager|\OC\Group\Manager */ // FIXME Requires a method that is not on the interface
private $groupManager; private $groupManager;
/** @var IUserSession */ /** @var IUserSession */
private $userSession; private $userSession;

apps/provisioning_api/tests/appstest.php → apps/provisioning_api/tests/AppsTest.php View File

*/ */


namespace OCA\Provisioning_API\Tests; namespace OCA\Provisioning_API\Tests;


use OC\OCSClient; use OC\OCSClient;
use OCA\Provisioning_API\Apps; use OCA\Provisioning_API\Apps;
use OCP\API; use OCP\API;
private $api; private $api;
/** @var IUserSession */ /** @var IUserSession */
private $userSession; private $userSession;
/** @var OCSClient */
/** @var OCSClient|\PHPUnit_Framework_MockObject_MockObject */
private $ocsClient; private $ocsClient;


public function setup() {
parent::setup();
protected function setUp() {
parent::setUp();

$this->appManager = \OC::$server->getAppManager(); $this->appManager = \OC::$server->getAppManager();
$this->groupManager = \OC::$server->getGroupManager(); $this->groupManager = \OC::$server->getGroupManager();
$this->userSession = \OC::$server->getUserSession(); $this->userSession = \OC::$server->getUserSession();
$this->ocsClient = $this->getMockBuilder('\OC\OCSClient')
->disableOriginalConstructor()->getMock();
$this->ocsClient = $this->getMockBuilder('OC\OCSClient')
->disableOriginalConstructor()
->getMock();

$this->api = new Apps($this->appManager, $this->ocsClient); $this->api = new Apps($this->appManager, $this->ocsClient);
} }



apps/provisioning_api/tests/groupstest.php → apps/provisioning_api/tests/GroupsTest.php View File



namespace OCA\Provisioning_API\Tests; namespace OCA\Provisioning_API\Tests;


use OCA\Provisioning_API\Groups;
use OCP\API;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\IRequest; use OCP\IRequest;
protected $request; protected $request;
/** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */ /** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */
protected $subAdminManager; protected $subAdminManager;
/** @var \OCA\Provisioning_API\Groups */
/** @var Groups */
protected $api; protected $api;


protected function setup() {
$this->subAdminManager = $this->getMockBuilder('OC\SubAdmin')->disableOriginalConstructor()->getMock();
protected function setUp() {
parent::setUp();


$this->groupManager = $this->getMockBuilder('OC\Group\Manager')->disableOriginalConstructor()->getMock();
$this->subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()
->getMock();

$this->groupManager = $this->getMockBuilder('OC\Group\Manager')
->disableOriginalConstructor()
->getMock();
$this->groupManager $this->groupManager
->method('getSubAdmin') ->method('getSubAdmin')
->willReturn($this->subAdminManager); ->willReturn($this->subAdminManager);


$this->userSession = $this->getMock('OCP\IUserSession'); $this->userSession = $this->getMock('OCP\IUserSession');
$this->request = $this->getMock('OCP\IRequest'); $this->request = $this->getMock('OCP\IRequest');
$this->api = new \OCA\Provisioning_API\Groups(
$this->api = new Groups(
$this->groupManager, $this->groupManager,
$this->userSession, $this->userSession,
$this->request $this->request


/** /**
* @dataProvider dataGetGroups * @dataProvider dataGetGroups
*
* @param string|null $search
* @param int|null $limit
* @param int|null $offset
*/ */
public function testGetGroups($search, $limit, $offset) { public function testGetGroups($search, $limit, $offset) {
$this->request $this->request


$this->assertInstanceOf('OC_OCS_Result', $result); $this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded()); $this->assertFalse($result->succeeded());
$this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode());
$this->assertEquals(API::RESPOND_UNAUTHORISED, $result->getStatusCode());


} }




$this->assertInstanceOf('OC_OCS_Result', $result); $this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded()); $this->assertFalse($result->succeeded());
$this->assertEquals(\OCP\API::RESPOND_UNAUTHORISED, $result->getStatusCode());
$this->assertEquals(API::RESPOND_UNAUTHORISED, $result->getStatusCode());
} }


public function testGetGroupAsAdmin() { public function testGetGroupAsAdmin() {
$this->asUser(); $this->asUser();


$result = $this->api->getGroup([ $result = $this->api->getGroup([
'groupid' => $this->getUniqueId()
'groupid' => $this->getUniqueID()
]); ]);


$this->assertInstanceOf('OC_OCS_Result', $result); $this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded()); $this->assertFalse($result->succeeded());
$this->assertEquals(\OCP\API::RESPOND_NOT_FOUND, $result->getStatusCode());
$this->assertEquals(API::RESPOND_NOT_FOUND, $result->getStatusCode());
$this->assertEquals('The requested group could not be found', $result->getMeta()['message']); $this->assertEquals('The requested group could not be found', $result->getMeta()['message']);
} }



apps/provisioning_api/tests/testcase.php → apps/provisioning_api/tests/TestCase.php View File


apps/provisioning_api/tests/UsersTest.php
File diff suppressed because it is too large
View File


Loading…
Cancel
Save