Fix tests

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-02-10 17:12:48 +01:00
parent a6722de14c
commit fa0315a043
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
4 changed files with 7 additions and 44 deletions

View File

@ -31,7 +31,6 @@ use OCP\IRequest;
class PageController extends Controller {
protected $appName;
private $userId;
/**
* @var IConfig
@ -40,11 +39,10 @@ class PageController extends Controller {
public function __construct(string $AppName,
IRequest $request,
string $UserId = null,
IConfig $config) {
parent::__construct($AppName, $request);
$this->appName = $AppName;
$this->userId = $UserId;
$this->config = $config;
}

View File

@ -1,36 +0,0 @@
<?php
/**
* Nextcloud - contacts
*
* 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('contacts');
$this->container = $app->getContainer();
}
public function testAppInstalled() {
$appManager = $this->container->query('OCP\App\IAppManager');
$this->assertTrue($appManager->isInstalled('contacts'));
}
}

View File

@ -56,7 +56,7 @@ class DetailsProviderTest extends Base {
/** @var DetailsProvider */
private $provider;
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->urlGenerator = $this->createMock(IURLGenerator::class);

View File

@ -18,13 +18,15 @@ use PHPUnit\Framework\TestCase as Base;
class PageControllerTest extends Base {
private $controller;
private $userId = 'john';
public function setUp() {
public function setUp(): void {
$config = $this->getMockBuilder('OCP\IConfig')->getMock();
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->controller = new PageController(
'contacts', $request, $this->userId
'contacts',
$request,
$config
);
}
@ -32,7 +34,6 @@ class PageControllerTest extends Base {
public function testIndex() {
$result = $this->controller->index();
$this->assertEquals(['user' => 'john'], $result->getParams());
$this->assertEquals('main', $result->getTemplateName());
$this->assertEquals('user', $result->getRenderAs());
$this->assertTrue($result instanceof TemplateResponse);