mirror of
https://github.com/netzbegruenung/circles.git
synced 2024-05-04 12:53:41 +02:00
Fix silently failing tests
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
parent
c1c41c7a41
commit
e403c36ca0
|
@ -28,8 +28,14 @@
|
|||
namespace OCA\Circles\Tests;
|
||||
|
||||
use OCA\Circles\Model\DeprecatedCircle;
|
||||
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 \PHPUnit_Framework_TestListener {
|
||||
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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue