From 9085f08269c1f7f715b52f3395ccc80f1afb9b7b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 10 Jul 2020 13:12:20 +0200 Subject: [PATCH 1/2] Correctly run the phpunit tests again Signed-off-by: Joas Schilling --- tests/Integration/Controller/RegisterControllerTest.php | 1 + tests/Integration/Service/RegistrationServiceTest.php | 9 +++++---- tests/Unit/Controller/ApiControllerTest.php | 1 + tests/phpunit.integration.xml | 2 +- tests/phpunit.unit.xml | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/Integration/Controller/RegisterControllerTest.php b/tests/Integration/Controller/RegisterControllerTest.php index 6b310e6..2690e75 100644 --- a/tests/Integration/Controller/RegisterControllerTest.php +++ b/tests/Integration/Controller/RegisterControllerTest.php @@ -2,6 +2,7 @@ namespace OCA\Registration\Tests\Integration\Controller; +use OCA\Registration\Controller\RegisterController; use OCA\Registration\Db\RegistrationMapper; use OCA\Registration\Service\MailService; use OCA\Registration\Service\RegistrationService; diff --git a/tests/Integration/Service/RegistrationServiceTest.php b/tests/Integration/Service/RegistrationServiceTest.php index 72392ca..e1f8c7f 100644 --- a/tests/Integration/Service/RegistrationServiceTest.php +++ b/tests/Integration/Service/RegistrationServiceTest.php @@ -5,6 +5,7 @@ namespace OCA\Registration\Tests\Integration\Service; use OCA\Registration\Db\Registration; use OCA\Registration\Db\RegistrationMapper; use OCA\Registration\Service\MailService; +use OCA\Registration\Service\RegistrationException; use OCA\Registration\Service\RegistrationService; use OCP\Defaults; use OCP\IConfig; @@ -133,11 +134,11 @@ class RegistrationServiceTest extends TestCase { } /** * @depends testValidateNewEmailWithinAllowedDomain - * @expectedException OCA\Registration\Service\RegistrationException */ public function testValidateNewEmailNotWithinAllowedDomain() { $email2 = 'bbbb@gmail.com'; + $this->expectException(RegistrationException::class); $this->service->validateEmail($email2); } @@ -155,11 +156,11 @@ class RegistrationServiceTest extends TestCase { } /** * @depends testValidateNewEmailWithinMultipleAllowedDomain - * @expectedException OCA\Registration\Service\RegistrationException */ public function testValidateNewEmailNotWithinMultipleAllowedDomain() { $email2 = 'cccc@yahoo.com'; + $this->expectException(RegistrationException::class); $this->service->validateEmail($email2); } @@ -213,7 +214,6 @@ class RegistrationServiceTest extends TestCase { /** * @depends testCreateAccountWebForm - * @expectedException OCA\Registration\Service\RegistrationException */ public function testDuplicateUsernameWebForm() { $reg = new Registration(); @@ -223,6 +223,7 @@ class RegistrationServiceTest extends TestCase { //$reg->setPassword("asdf"); $reg->setEmailConfirmed(true); + $this->expectException(RegistrationException::class); $resulting_user = $this->service->createAccount($reg, 'alice1', 'asdf'); } @@ -236,7 +237,6 @@ class RegistrationServiceTest extends TestCase { /** * @depends testCreateAccountWebForm - * @expectedException OCA\Registration\Service\RegistrationException */ public function testDuplicateUsernameApi() { $reg = new Registration(); @@ -246,6 +246,7 @@ class RegistrationServiceTest extends TestCase { $reg->setPassword("asdf"); $reg->setEmailConfirmed(true); + $this->expectException(RegistrationException::class); $resulting_user = $this->service->createAccount($reg); } diff --git a/tests/Unit/Controller/ApiControllerTest.php b/tests/Unit/Controller/ApiControllerTest.php index 2f0221f..f4b3351 100644 --- a/tests/Unit/Controller/ApiControllerTest.php +++ b/tests/Unit/Controller/ApiControllerTest.php @@ -11,6 +11,7 @@ namespace OCA\Registration\Tests\Unit\Controller; +use OCA\Registration\Controller\ApiController; use OCA\Registration\Db\Registration; use OCA\Registration\Service\MailService; use OCA\Registration\Service\RegistrationService; diff --git a/tests/phpunit.integration.xml b/tests/phpunit.integration.xml index 941d68e..dbdf50d 100644 --- a/tests/phpunit.integration.xml +++ b/tests/phpunit.integration.xml @@ -3,7 +3,7 @@ verbose="true" > - integration + Integration diff --git a/tests/phpunit.unit.xml b/tests/phpunit.unit.xml index 1b5554d..c56ee9e 100644 --- a/tests/phpunit.unit.xml +++ b/tests/phpunit.unit.xml @@ -3,7 +3,7 @@ verbose="true" > - unit + Unit From e9dfd13fe04e3b4784a17e639a835dd51d8c44fd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 10 Jul 2020 13:13:59 +0200 Subject: [PATCH 2/2] Combine both phpunit configs into one Signed-off-by: Joas Schilling --- tests/phpunit.unit.xml | 14 -------------- tests/{phpunit.integration.xml => phpunit.xml} | 1 + tests/scripts/phpunit.sh | 3 +-- 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 tests/phpunit.unit.xml rename tests/{phpunit.integration.xml => phpunit.xml} (87%) diff --git a/tests/phpunit.unit.xml b/tests/phpunit.unit.xml deleted file mode 100644 index c56ee9e..0000000 --- a/tests/phpunit.unit.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - Unit - - - - - ../ - - - diff --git a/tests/phpunit.integration.xml b/tests/phpunit.xml similarity index 87% rename from tests/phpunit.integration.xml rename to tests/phpunit.xml index dbdf50d..b833956 100644 --- a/tests/phpunit.integration.xml +++ b/tests/phpunit.xml @@ -4,6 +4,7 @@ > Integration + Unit diff --git a/tests/scripts/phpunit.sh b/tests/scripts/phpunit.sh index bab4f16..0f92356 100755 --- a/tests/scripts/phpunit.sh +++ b/tests/scripts/phpunit.sh @@ -7,7 +7,6 @@ set -e cd ${BUILD_APP_MODULE_DIR} composer install --prefer-dist --no-interaction -o -vendor/bin/phpunit -c tests/phpunit.unit.xml -vendor/bin/phpunit -c tests/phpunit.integration.xml +vendor/bin/phpunit -c tests/phpunit.xml echo "travis_fold:end:phpunit"