diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-12 10:27:08 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-14 18:34:07 +0200 |
commit | 092b767ef998a6afe2e01eb34aef1f8d21f6ec69 (patch) | |
tree | a374e54d3c0d125a126ad2876e616c962425e98c /apps/provisioning_api/tests | |
parent | 8f4adebab7cf3133bb33b8081fbdf2c6e2e8e549 (diff) | |
download | nextcloud-server-092b767ef998a6afe2e01eb34aef1f8d21f6ec69.tar.gz nextcloud-server-092b767ef998a6afe2e01eb34aef1f8d21f6ec69.zip |
Move Apps to OCSController
Diffstat (limited to 'apps/provisioning_api/tests')
-rw-r--r-- | apps/provisioning_api/tests/Controller/AppsControllerTest.php (renamed from apps/provisioning_api/tests/AppsTest.php) | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/apps/provisioning_api/tests/AppsTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php index 35808b15816..9ac4a8290e4 100644 --- a/apps/provisioning_api/tests/AppsTest.php +++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php @@ -25,11 +25,11 @@ * */ -namespace OCA\Provisioning_API\Tests; +namespace OCA\Provisioning_API\Tests\Controller; use OC\OCSClient; -use OCA\Provisioning_API\Apps; +use OCA\Provisioning_API\Controller\AppsController; use OCP\API; use OCP\App\IAppManager; use OCP\IUserSession; @@ -41,10 +41,10 @@ use OCP\IUserSession; * * @package OCA\Provisioning_API\Tests */ -class AppsTest extends TestCase { +class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { /** @var IAppManager */ private $appManager; - /** @var Apps */ + /** @var AppsController */ private $api; /** @var IUserSession */ private $userSession; @@ -61,20 +61,30 @@ class AppsTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->api = new Apps($this->appManager, $this->ocsClient); + $request = $this->getMockBuilder('OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); + + $this->api = new AppsController( + 'provisioning_api', + $request, + $this->appManager, + $this->ocsClient + ); } public function testGetAppInfo() { - $result = $this->api->getAppInfo(['appid' => 'provisioning_api']); - $this->assertInstanceOf('\OC\OCS\Result', $result); - $this->assertTrue($result->succeeded()); + $result = $this->api->getAppInfo('provisioning_api'); + $expected = \OC_App::getAppInfo('provisioning_api'); + $this->assertEquals($expected, $result->getData()); } + /** + * @expectedException \OCP\AppFramework\OCS\OCSException + * @expectedExceptionCode 998 + */ public function testGetAppInfoOnBadAppID() { - $result = $this->api->getAppInfo(['appid' => 'not_provisioning_api']); - $this->assertInstanceOf('\OC\OCS\Result', $result); - $this->assertFalse($result->succeeded()); - $this->assertEquals(API::RESPOND_NOT_FOUND, $result->getStatusCode()); + $this->api->getAppInfo('not_provisioning_api'); } public function testGetApps() { @@ -86,17 +96,14 @@ class AppsTest extends TestCase { $this->groupManager->get('admin')->addUser($user); $this->userSession->setUser($user); - $result = $this->api->getApps([]); + $result = $this->api->getApps(); - $this->assertTrue($result->succeeded()); $data = $result->getData(); $this->assertEquals(count(\OC_App::listAllApps(false, true, $this->ocsClient)), count($data['apps'])); } public function testGetAppsEnabled() { - $_GET['filter'] = 'enabled'; - $result = $this->api->getApps(['filter' => 'enabled']); - $this->assertTrue($result->succeeded()); + $result = $this->api->getApps('enabled'); $data = $result->getData(); $this->assertEquals(count(\OC_App::getEnabledApps()), count($data['apps'])); } @@ -106,9 +113,7 @@ class AppsTest extends TestCase { ->expects($this->any()) ->method($this->anything()) ->will($this->returnValue(null)); - $_GET['filter'] = 'disabled'; - $result = $this->api->getApps(['filter' => 'disabled']); - $this->assertTrue($result->succeeded()); + $result = $this->api->getApps('disabled'); $data = $result->getData(); $apps = \OC_App::listAllApps(false, true, $this->ocsClient); $list = array(); @@ -119,10 +124,11 @@ class AppsTest extends TestCase { $this->assertEquals(count($disabled), count($data['apps'])); } + /** + * @expectedException \OCP\AppFramework\OCS\OCSException + * @expectedExceptionCode 101 + */ public function testGetAppsInvalidFilter() { - $_GET['filter'] = 'foo'; - $result = $this->api->getApps([]); - $this->assertFalse($result->succeeded()); - $this->assertEquals(101, $result->getStatusCode()); + $this->api->getApps('foo'); } } |