Update tests: phpunit version, adhere to official app bootstraping

approach
This commit is contained in:
Pellaeon Lin 2020-04-11 00:56:28 +00:00
parent de4b3d5b83
commit be903f4602
10 changed files with 40 additions and 34 deletions

View File

@ -1,6 +1,6 @@
{
"require-dev": {
"phpunit/phpunit": "^7.5",
"christophwurst/nextcloud_testing": "^0.6.0"
"phpunit/phpunit": "^8.0",
"christophwurst/nextcloud_testing": "0.10.0"
}
}

View File

@ -1,12 +0,0 @@
<?php
/**
* ownCloud - registration
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Pellaeon Lin <pellaeon@hs.ntnu.edu.tw>
* @copyright Pellaeon Lin 2014
*/
require_once __DIR__ . '/../../../tests/bootstrap.php';

4
tests/bootstrap.php Normal file
View File

@ -0,0 +1,4 @@
<?php
require_once __DIR__.'/../../../tests/bootstrap.php';
require_once __DIR__.'/../vendor/autoload.php';

View File

@ -67,7 +67,7 @@ class RegistrationControllerTest extends TestCase {
/** @var ICrypto */
private $crypto;
public function setUp () {
public function setUp (): void {
parent::setUp();
$this->mailService = $this->createMock(MailService::class);
$this->l10n = $this->createMock(IL10N::class);

View File

@ -65,7 +65,7 @@ class RegistrationServiceTest extends TestCase {
/** @var ICrypto */
private $crypto;
public function setUp () {
public function setUp (): void {
parent::setUp();
$this->mailService = $this->createMock(MailService::class);
$this->l10n = $this->createMock(IL10N::class);

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
verbose="true"
>
<testsuite name='Registration app tests'>
<directory suffix='Test.php'>integration</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">../</directory>
</whitelist>
</filter>
</phpunit>

14
tests/phpunit.unit.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
verbose="true"
>
<testsuite name='Registration app tests'>
<directory suffix='Test.php'>unit</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">../</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -1,15 +0,0 @@
<phpunit bootstrap="autoloader.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>./unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -7,6 +7,7 @@ set -e
cd ${BUILD_APP_MODULE_DIR}
composer install --prefer-dist --no-interaction -o
vendor/bin/phpunit -c tests/phpunit.xml
vendor/bin/phpunit -c tests/phpunit.unit.xml
vendor/bin/phpunit -c tests/phpunit.integration.xml
echo "travis_fold:end:phpunit"

View File

@ -21,7 +21,7 @@ use OCP\Defaults;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
use \Test\TestCase;
use ChristophWurst\Nextcloud\Testing\TestCase;
class ApiControllerTest extends TestCase {
@ -38,7 +38,7 @@ class ApiControllerTest extends TestCase {
/** @var ApiController */
private $controller;
public function setUp () {
public function setUp (): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->registrationService = $this->createMock(RegistrationService::class);