From 677003d1b6f1ebabab6cee32b96ccad8d70ee863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Sun, 15 Sep 2019 00:28:32 +0200 Subject: Add TZ & LANG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- tests/bootstrap.php | 6 +++- tests/unit/Controller/PageControllerTest.php | 53 +++++++++++++++++++++------- 2 files changed, 46 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ba136a15..34f9a6d5 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,4 +9,8 @@ * @copyright Bernhard Posselt 2016 */ -require_once __DIR__ . '/../../../tests/bootstrap.php'; +require_once __DIR__.'/../../../lib/base.php'; +require_once __DIR__.'/../vendor/autoload.php'; + +\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); +\OC_App::loadApp('contacts'); diff --git a/tests/unit/Controller/PageControllerTest.php b/tests/unit/Controller/PageControllerTest.php index 0eb027a3..f23ef441 100644 --- a/tests/unit/Controller/PageControllerTest.php +++ b/tests/unit/Controller/PageControllerTest.php @@ -1,32 +1,61 @@ * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. + * @author John Molakvoæ + * + * @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 . * - * @author Hendrik Leppelsack - * @copyright Hendrik Leppelsack 2015 */ namespace OCA\Contacts\Controller; use OCP\AppFramework\Http\TemplateResponse; -use PHPUnit\Framework\TestCase as Base; +use PHPUnit\Framework\MockObject\MockObject; +use OCP\IInitialStateService; +use OCP\IRequest; +use OCP\L10N\IFactory; +use ChristophWurst\Nextcloud\Testing\TestCase; -class PageControllerTest extends Base { +class PageControllerTest extends TestCase { private $controller; - public function setUp(): void { - $config = $this->getMockBuilder('OCP\IConfig')->getMock(); - $request = $this->getMockBuilder('OCP\IRequest')->getMock(); + /** @var IRequest|MockObject */ + private $request; + + /** @var IInitialStateService|MockObject */ + private $initialStateService; + + /** @var IFactory|MockObject */ + private $languageFactory; + + public function setUp() { + parent::setUp(); + + $this->request = $this->createMock(IRequest::class); + $this->initialStateService = $this->createMock(IInitialStateService::class); + $this->languageFactory = $this->createMock(IFactory::class); $this->controller = new PageController( 'contacts', - $request, - $config + $this->request, + $this->initialStateService, + $this->languageFactory ); } -- cgit v1.2.3