This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5eb2388
commit b2cef92
Showing
11 changed files
with
291 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\AppOrder\AppInfo; | ||
|
||
use OCP\AppFramework\App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
<?php | ||
/** | ||
* ownCloud - foobar | ||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @author jus <jus@bitgrid.net> | ||
* @copyright jus 2016 | ||
*/ | ||
|
||
require_once __DIR__.'/../../../tests/bootstrap.php'; | ||
require_once __DIR__.'/../appinfo/autoload.php'; | ||
require_once __DIR__ . '/../../../tests/bootstrap.php'; | ||
require_once __DIR__ . '/../appinfo/autoload.php'; | ||
|
||
|
||
require_once __DIR__.'/../../../lib/base.php'; | ||
if(!class_exists('PHPUnit_Framework_TestCase')) { | ||
require_once('PHPUnit/Autoload.php'); | ||
} | ||
|
||
\OC::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); | ||
\OC_App::loadApp('apporder'); | ||
|
||
OC_Hook::clear(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\AppOrder; | ||
|
||
use OCA\AppOrder\Service\ConfigService; | ||
use \OCA\AppOrder\Util; | ||
|
||
class UtilTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* @var ConfigService | ||
*/ | ||
private $service; | ||
private $userId; | ||
private $util; | ||
private $config; | ||
public function setUp() { | ||
|
||
parent::setUp(); | ||
|
||
$this->config = $this->getMockBuilder('OCP\IConfig') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->userId = 'admin'; | ||
$this->util = new Util($this->service, $this->userId); | ||
|
||
} | ||
|
||
public function testMatchOrder() { | ||
$nav = [ | ||
['href' => '/app/files/', 'name' => 'Files'], | ||
['href' => '/app/calendar/', 'name' => 'Calendar'], | ||
['href' => '/app/tasks/', 'name' => 'Tasks'], | ||
]; | ||
$order = ['/app/calendar/', '/app/tasks/']; | ||
$result = $this->util->matchOrder($nav, $order); | ||
$expected = [ | ||
'/app/calendar/' => ['href' => '/app/calendar/', 'name' => 'Calendar'], | ||
'/app/tasks/' => ['href' => '/app/tasks/', 'name' => 'Tasks'], | ||
'/app/files/' => ['href' => '/app/files/', 'name' => 'Files'], | ||
]; | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testGetAppOrder() { | ||
$nav_system = ['/app/calendar/', '/app/tasks/']; | ||
$nav_user = ['/app/files/', '/app/calendar/', '/app/tasks/']; | ||
$this->service->expects($this->once()) | ||
->method('getAppValue') | ||
->with('order') | ||
->will($this->returnValue(json_encode($nav_system))); | ||
$this->service->expects($this->once()) | ||
->method('getUserValue') | ||
->with('order', $this->userId) | ||
->will($this->returnValue(json_encode($nav_user))); | ||
$result = $this->util->getAppOrder(); | ||
$this->assertEquals(json_encode($nav_user), $result); | ||
} | ||
|
||
public function testGetAppOrderNoUser() { | ||
$nav_system = ['/app/calendar/', '/app/tasks/']; | ||
$nav_user = ''; | ||
$this->service->expects($this->once()) | ||
->method('getAppValue') | ||
->with('order') | ||
->will($this->returnValue(json_encode($nav_system))); | ||
$this->service->expects($this->once()) | ||
->method('getUserValue') | ||
->with('order', $this->userId) | ||
->will($this->returnValue($nav_user)); | ||
$result = $this->util->getAppOrder(); | ||
$this->assertEquals(json_encode($nav_system), $result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\AppOrder\Tests\Unit\Controller; | ||
|
||
use OCP\IRequest; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\Http; | ||
use \OCA\AppOrder\Service; | ||
use \OCA\AppOrder\AppInfo\Application; | ||
use \OCA\AppOrder\Controller; | ||
use OCA\AppOrder\Controller\AppController; | ||
|
||
class AppControllerTest extends \Test\TestCase { | ||
|
||
private $container; | ||
private $request; | ||
private $service; | ||
private $urlGenerator; | ||
private $userId; | ||
private $appName; | ||
/** | ||
* @var AppController | ||
*/ | ||
private $controller; | ||
private $config; | ||
private $util; | ||
|
||
public function setUp() { | ||
|
||
parent::setUp(); | ||
|
||
$app = new \OCA\AppOrder\AppInfo\Application(); | ||
$this->container = $app->getContainer(); | ||
$this->request = $this->getMockBuilder('OCP\IRequest') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->config = $this->getMockBuilder('OCP\IConfig') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->service = $this->getMockBuilder('\OCA\AppOrder\Service\ConfigService') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->urlGenerator = \OC::$server->getURLGenerator(); | ||
$this->util = $this->getMockBuilder('\OCA\AppOrder\Util')->disableOriginalConstructor()->getMock(); | ||
|
||
$this->userId = 'admin'; | ||
$this->appName = 'apporder'; | ||
$this->controller = new AppController( | ||
$this->appName, $this->request, $this->service, $this->urlGenerator, $this->util, | ||
$this->userId | ||
); | ||
|
||
} | ||
|
||
public function testIndex() { | ||
$this->util->expects($this->once()) | ||
->method('getAppOrder') | ||
->willReturn( | ||
json_encode(['/index.php/foo/bar', '/index.php/bar/foo']) | ||
); | ||
$expected = new Http\RedirectResponse('/index.php/foo/bar'); | ||
$result = $this->controller->index(); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testIndexEmpty() { | ||
$this->util->expects($this->once()) | ||
->method('getAppOrder') | ||
->willReturn(""); | ||
$result = $this->controller->index(); | ||
|
||
$expected = new Http\RedirectResponse('/apps/files/'); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.