Move Provisioning api to PSR-4 (#24510)
* Move app to PSR-4 * Fix setUp method * Fix the tests
This commit is contained in:
parent
e03f9e8103
commit
2a05035339
|
@ -18,6 +18,7 @@
|
||||||
<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>
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Users {
|
||||||
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;
|
|
@ -25,6 +25,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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;
|
||||||
|
@ -45,16 +47,19 @@ class AppsTest extends TestCase {
|
||||||
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() {
|
protected function setUp() {
|
||||||
parent::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')
|
$this->ocsClient = $this->getMockBuilder('OC\OCSClient')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
$this->api = new Apps($this->appManager, $this->ocsClient);
|
$this->api = new Apps($this->appManager, $this->ocsClient);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
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;
|
||||||
|
@ -38,20 +40,26 @@ class GroupsTest extends \Test\TestCase {
|
||||||
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() {
|
protected function setUp() {
|
||||||
$this->subAdminManager = $this->getMockBuilder('OC\SubAdmin')->disableOriginalConstructor()->getMock();
|
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
|
||||||
|
@ -129,6 +137,10 @@ class GroupsTest extends \Test\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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
|
||||||
|
@ -161,7 +173,7 @@ class GroupsTest extends \Test\TestCase {
|
||||||
|
|
||||||
$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());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +227,7 @@ class GroupsTest extends \Test\TestCase {
|
||||||
|
|
||||||
$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() {
|
||||||
|
@ -252,12 +264,12 @@ class GroupsTest extends \Test\TestCase {
|
||||||
$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']);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue