diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-01-12 15:49:44 +0300 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-03-28 11:32:11 +0300 |
commit | e403c36ca0f18da2a8b4af520947f024dde3265f (patch) | |
tree | ebe4b4a4b03e0f28a49cf416623d8edcde06ceb7 /tests | |
parent | c1c41c7a41705e86506a45086f221464f0286335 (diff) |
Fix silently failing tests
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TestSuiteListener.php | 39 | ||||
-rw-r--r-- | tests/bootstrap.php | 6 | ||||
-rw-r--r-- | tests/unit/lib/Api/CirclesTest.php | 8 |
3 files changed, 32 insertions, 21 deletions
diff --git a/tests/TestSuiteListener.php b/tests/TestSuiteListener.php index 01bab544..a6c873ad 100644 --- a/tests/TestSuiteListener.php +++ b/tests/TestSuiteListener.php @@ -28,8 +28,14 @@ namespace OCA\Circles\Tests; use OCA\Circles\Model\DeprecatedCircle; - -class Env implements \PHPUnit_Framework_TestListener { +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Warning; +use Throwable; + +class Env implements TestListener { public const ENV_TEST_OWNER1 = '_test_circles_owner1'; public const ENV_TEST_OWNER2 = '_test_circles_owner2'; public const ENV_TEST_OWNER3 = '_test_circles_owner3'; @@ -54,31 +60,31 @@ class Env implements \PHPUnit_Framework_TestListener { /** @var array<string> */ private $users; - public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) { + public function addError(Test $test, Throwable $e, float $time): void { } public function addFailure( - \PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time - ) { + Test $test, AssertionFailedError $e, float $time + ): void { } - public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { + public function addIncompleteTest(Test $test, Throwable $e, float $time): void { } - public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { + public function addRiskyTest(Test $test, Throwable $e, float $time): void { } - public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { + public function addSkippedTest(Test $test, Throwable $e, float $time): void { } - public function startTest(\PHPUnit_Framework_Test $test) { + public function startTest(Test $test): void { } - public function endTest(\PHPUnit_Framework_Test $test, $time) { + public function endTest(Test $test, float $time): void { } - public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) { - if ($suite->getName() !== '.') { + public function startTestSuite(TestSuite $suite): void { + if ($suite->getName() !== 'OCA\Circles\Tests\Api\CirclesTest') { return; } @@ -92,7 +98,7 @@ class Env implements \PHPUnit_Framework_TestListener { } } - public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) { + public function endTestSuite(TestSuite $suite): void { if ($suite->getName() !== '.') { return; } @@ -106,8 +112,8 @@ class Env implements \PHPUnit_Framework_TestListener { } } - public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time - ) { + public function addWarning(Test $test, Warning $e, float $time + ): void { } public static function setUser($which) { @@ -117,8 +123,7 @@ class Env implements \PHPUnit_Framework_TestListener { ->get($which) ); - return $userSession->getUser() - ->getUID(); + return $userSession->getUser()->getUID(); } public static function currentUser() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4d16b4de..9a4ec249 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,8 +1,12 @@ <?php +define('PHPUNIT_RUN', 1); require_once __DIR__.'/../../../lib/base.php'; require_once __DIR__.'/../vendor/autoload.php'; -\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); +\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/unit/', true); + \OC_App::loadApp('circles'); + +OC_Hook::clear(); diff --git a/tests/unit/lib/Api/CirclesTest.php b/tests/unit/lib/Api/CirclesTest.php index c38aa1cf..495a1a03 100644 --- a/tests/unit/lib/Api/CirclesTest.php +++ b/tests/unit/lib/Api/CirclesTest.php @@ -40,7 +40,9 @@ use OCA\Circles\Model\DeprecatedMember; use OCA\Circles\Tests\Env; use OCP\AppFramework\QueryException; -class CirclesTest extends \PHPUnit_Framework_TestCase { +use Test\TestCase; + +class CirclesTest extends TestCase { public const NAME_PUBLIC_CIRCLE1 = '_circleNamePublic1'; public const NAME_SECRET_CIRCLE1 = '_circleNameSecret1'; public const NAME_CLOSED_CIRCLE1 = '_circleNameClosed1'; @@ -62,7 +64,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { * * @throws Exception */ - protected function setUp() { + protected function setUp(): void { Env::setUser(Env::ENV_TEST_OWNER1); $this->circles = []; @@ -92,7 +94,7 @@ class CirclesTest extends \PHPUnit_Framework_TestCase { * * @throws Exception */ - protected function tearDown() { + protected function tearDown(): void { Env::setUser(Env::ENV_TEST_OWNER1); try { foreach ($this->circles as $circle) { |