summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHendrik Leppelsack <hendrik@leppelsack.de>2015-10-26 11:29:01 +0100
committerHendrik Leppelsack <hendrik@leppelsack.de>2015-10-26 11:29:01 +0100
commit14804ae7b7d7a2d006b42189ad303241cde2550b (patch)
tree41740c2f9a49d9491f34a1db30261e9cb52608e1 /tests
Initial commit
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/AppTest.php36
-rw-r--r--tests/travis/php.ini2
-rw-r--r--tests/unit/controller/PageControllerTest.php48
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/integration/AppTest.php b/tests/integration/AppTest.php
new file mode 100644
index 00000000..92c1435c
--- /dev/null
+++ b/tests/integration/AppTest.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * ownCloud - contactsrework
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Hendrik Leppelsack <hendrik@leppelsack.de>
+ * @copyright Hendrik Leppelsack 2015
+ */
+
+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('contactsrework');
+ $this->container = $app->getContainer();
+ }
+
+ public function testAppInstalled() {
+ $appManager = $this->container->query('OCP\App\IAppManager');
+ $this->assertTrue($appManager->isInstalled('contactsrework'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/travis/php.ini b/tests/travis/php.ini
new file mode 100644
index 00000000..3b365b09
--- /dev/null
+++ b/tests/travis/php.ini
@@ -0,0 +1,2 @@
+default_charset = "UTF-8"
+always_populate_raw_post_data = -1 \ No newline at end of file
diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php
new file mode 100644
index 00000000..8d1b4b2a
--- /dev/null
+++ b/tests/unit/controller/PageControllerTest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * ownCloud - contactsrework
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Hendrik Leppelsack <hendrik@leppelsack.de>
+ * @copyright Hendrik Leppelsack 2015
+ */
+
+namespace OCA\ContactsRework\Controller;
+
+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(
+ 'contactsrework', $request, $this->userId
+ );
+ }
+
+
+ public function testIndex() {
+ $result = $this->controller->index();
+
+ $this->assertEquals(['user' => 'john'], $result->getParams());
+ $this->assertEquals('main', $result->getTemplateName());
+ $this->assertTrue($result instanceof TemplateResponse);
+ }
+
+
+ public function testEcho() {
+ $result = $this->controller->doEcho('hi');
+ $this->assertEquals(['echo' => 'hi'], $result->getData());
+ }
+
+
+} \ No newline at end of file