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

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2018-08-21 18:39:12 +0300
committerPhie <phie@phie.ovh>2018-08-21 18:39:12 +0300
commit7d24cc0120859fc4e46b301c08effc97ddfbb1bb (patch)
tree94b5b52074022ceccd4c91073f217feaec38ca40 /tests
first commit for Carnet NC server
Diffstat (limited to 'tests')
-rwxr-xr-xtests/Integration/AppTest.php29
-rwxr-xr-xtests/Unit/Controller/PageControllerTest.php31
-rwxr-xr-xtests/bootstrap.php19
3 files changed, 79 insertions, 0 deletions
diff --git a/tests/Integration/AppTest.php b/tests/Integration/AppTest.php
new file mode 100755
index 0000000..3d2420b
--- /dev/null
+++ b/tests/Integration/AppTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace OCA\QuickDoc\Tests\Integration\Controller;
+
+use OCP\AppFramework\App;
+use Test\TestCase;
+
+
+/**
+ * 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 {
+
+ private $container;
+
+ public function setUp() {
+ parent::setUp();
+ $app = new App('quickdoc');
+ $this->container = $app->getContainer();
+ }
+
+ public function testAppInstalled() {
+ $appManager = $this->container->query('OCP\App\IAppManager');
+ $this->assertTrue($appManager->isInstalled('quickdoc'));
+ }
+
+}
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
new file mode 100755
index 0000000..4d34c71
--- /dev/null
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace OCA\QuickDoc\Tests\Unit\Controller;
+
+use PHPUnit_Framework_TestCase;
+
+use OCP\AppFramework\Http\TemplateResponse;
+
+use OCA\QuickDoc\Controller\PageController;
+
+
+class PageControllerTest extends PHPUnit_Framework_TestCase {
+ private $controller;
+ private $userId = 'john';
+
+ public function setUp() {
+ $request = $this->getMockBuilder('OCP\IRequest')->getMock();
+
+ $this->controller = new PageController(
+ 'quickdoc', $request, $this->userId
+ );
+ }
+
+ public function testIndex() {
+ $result = $this->controller->index();
+
+ $this->assertEquals('index', $result->getTemplateName());
+ $this->assertTrue($result instanceof TemplateResponse);
+ }
+
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100755
index 0000000..318d169
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,19 @@
+<?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: .../quickdoc/tests/testcase.php"
+\OC_App::loadApp('quickdoc');
+
+if(!class_exists('PHPUnit_Framework_TestCase')) {
+ require_once('PHPUnit/Autoload.php');
+}
+
+OC_Hook::clear();