Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsplitt3r <splitt3r@users.noreply.github.com>2017-10-09 19:08:36 +0300
committersplitt3r <splitt3r@users.noreply.github.com>2017-10-09 19:08:36 +0300
commit19ecdc08a324f5f5a96f68c7f975aca9b69ad23b (patch)
tree1f146434ee4625c13e0934a2275e1ff1b8a27c0e /tests
parent0faa40a07aa0831d21b4be386b064bc4bb4c83ac (diff)
Match NC style guide
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/AppTest.php18
-rw-r--r--tests/Unit/Controller/PageControllerTest.php50
-rw-r--r--tests/bootstrap.php18
3 files changed, 72 insertions, 14 deletions
diff --git a/tests/Integration/AppTest.php b/tests/Integration/AppTest.php
index 945d7069..87f7fdaf 100644
--- a/tests/Integration/AppTest.php
+++ b/tests/Integration/AppTest.php
@@ -21,31 +21,23 @@
*
*/
-namespace OCA\Polls\Tests\Integration\Controller;
+namespace OCA\Polls\Tests\Integration;
use Test\TestCase;
-use OCP\AppFramework\App;
+use \OCP\AppFramework\App;
-/**
- * This test shows how to make a small Integration Test. Query your class
- * directly from the container, only pass in mocks if needed and run your tests
- * against the database
- */
-class AppTest extends TestCase
-{
+class AppTest extends TestCase {
private $container;
- public function setUp()
- {
+ public function setUp() {
parent::setUp();
$app = new App('polls');
$this->container = $app->getContainer();
}
- public function testAppInstalled()
- {
+ public function testAppInstalled() {
$appManager = $this->container->query('OCP\App\IAppManager');
$this->assertTrue($appManager->isInstalled('polls'));
}
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
new file mode 100644
index 00000000..b0c07527
--- /dev/null
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Kai Schröer <kai@schroeer.co>
+ *
+ * @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\Polls\Tests\Unit\Controller;
+
+use OCA\Polls\Controller\PageController;
+use PHPUnit_Framework_TestCase;
+
+use OCP\AppFramework\Http\TemplateResponse;
+
+class PageControllerTest extends PHPUnit_Framework_TestCase {
+
+ private $controller;
+ private $userId = 'john';
+
+ public function setUp() {
+ $request = $this->getMockBuilder('OCP\IRequest')->getMock();
+
+ $this->controller = new PageController(
+ 'polls', $request, $this->userId
+ );
+ }
+
+ public function testIndex() {
+ $result = $this->controller->index();
+
+ $this->assertEquals('main.tmpl', $result->getTemplateName());
+ $this->assertTrue($result instanceof TemplateResponse);
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index eebb738d..64fc285e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -21,4 +21,20 @@
*
*/
-require_once __DIR__ . '/../../../tests/bootstrap.php';
+if (!defined('PHPUNIT_RUN')) {
+ define('PHPUNIT_RUN', 1);
+}
+
+require_once(__DIR__.'/../../../lib/base.php');
+
+// Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
+\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
+
+// Fix for "Autoload path not allowed: .../polls/tests/testcase.php"
+\OC_App::loadApp('polls');
+
+if (!class_exists('PHPUnit_Framework_TestCase')) {
+ require_once('PHPUnit/Autoload.php');
+}
+
+OC_Hook::clear();