mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Initial release
This commit is contained in:
13
tests/bootstrap.php
Normal file
13
tests/bootstrap.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - quicknotes
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Matias De lellis <mati86dl@gmail.com>
|
||||
* @copyright Matias De lellis 2016
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../tests/bootstrap.php';
|
||||
require_once __DIR__ . '/../appinfo/autoload.php';
|
||||
36
tests/integration/AppTest.php
Normal file
36
tests/integration/AppTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - quicknotes
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Matias De lellis <mati86dl@gmail.com>
|
||||
* @copyright Matias De lellis 2016
|
||||
*/
|
||||
|
||||
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('quicknotes');
|
||||
$this->container = $app->getContainer();
|
||||
}
|
||||
|
||||
public function testAppInstalled() {
|
||||
$appManager = $this->container->query('OCP\App\IAppManager');
|
||||
$this->assertTrue($appManager->isInstalled('quicknotes'));
|
||||
}
|
||||
|
||||
}
|
||||
48
tests/unit/controller/PageControllerTest.php
Normal file
48
tests/unit/controller/PageControllerTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud - quicknotes
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Matias De lellis <mati86dl@gmail.com>
|
||||
* @copyright Matias De lellis 2016
|
||||
*/
|
||||
|
||||
namespace OCA\QuickNotes\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(
|
||||
'quicknotes', $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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user