diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php index b2ba8ba119..36aa4fa449 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php @@ -25,8 +25,9 @@ namespace OCA\DAV\Tests\unit\CalDAV\Publishing; use OCA\DAV\CalDAV\Publishing\Xml\Publisher; use Sabre\Xml\Writer; +use Test\TestCase; -class PublisherTest extends \PHPUnit_Framework_TestCase { +class PublisherTest extends TestCase { const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; diff --git a/apps/dav/tests/unit/bootstrap.php b/apps/dav/tests/unit/bootstrap.php index 178bc695b6..a2ad505342 100644 --- a/apps/dav/tests/unit/bootstrap.php +++ b/apps/dav/tests/unit/bootstrap.php @@ -26,10 +26,6 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../../lib/base.php'; -if(!class_exists('PHPUnit_Framework_TestCase')) { - require_once('PHPUnit/Autoload.php'); -} - \OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true); \OC_App::loadApp('dav'); diff --git a/autotest.sh b/autotest.sh index da9661f067..7a91b07719 100755 --- a/autotest.sh +++ b/autotest.sh @@ -53,7 +53,7 @@ else fi if ! [ -x "$PHPUNIT" ]; then - echo "phpunit executable not found, please install phpunit version >= 4.8" >&2 + echo "phpunit executable not found, please install phpunit version >= 6.5" >&2 exit 3 fi @@ -68,8 +68,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2) PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1) PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2) -if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 4 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 4 -a "$PHPUNIT_MINOR_VERSION" -ge 8 \) ]; then - echo "phpunit version >= 4.8 required. Version found: $PHPUNIT_VERSION" >&2 +if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 6 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 6 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then + echo "phpunit version >= 6.5 required. Version found: $PHPUNIT_VERSION" >&2 exit 4 fi diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 44c42d353e..a1bc26bbf0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,10 +14,6 @@ require_once __DIR__ . '/../lib/base.php'; // load all enabled apps \OC_App::loadApps(); -if (!class_exists('PHPUnit_Framework_TestCase')) { - require_once('PHPUnit/Autoload.php'); -} - OC_Hook::clear(); set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php'); diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php index ddc6cc916d..d5141136a1 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -26,10 +26,9 @@ namespace Tests\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\Actions\LinkAction; use OC\Contacts\ContactsMenu\Entry; -use OCP\Contacts\ContactsMenu\IAction; use Test\TestCase; -class EntryTest extends \PHPUnit_Framework_TestCase { +class EntryTest extends TestCase { /** @var Entry */ private $entry; diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 345b2a68e6..9207658051 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -33,7 +33,7 @@ use OCP\IDBConnection; use OCP\IL10N; use OCP\Security\ISecureRandom; -abstract class TestCase extends \PHPUnit_Framework_TestCase { +abstract class TestCase extends \PHPUnit\Framework\TestCase { /** @var \OC\Command\QueueBus */ private $commandBus; @@ -46,24 +46,6 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { /** @var array */ protected $services = []; - /** - * Wrapper to be forward compatible to phpunit 5.4+ - * - * @param string $originalClassName - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function createMock($originalClassName) { - if (is_callable('parent::createMock')) { - return parent::createMock($originalClassName); - } - - return $this->getMockBuilder($originalClassName) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->disableArgumentCloning() - ->getMock(); - } - /** * @param string $name * @param mixed $newService @@ -152,7 +134,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { } } - protected function onNotSuccessfulTest($e) { + protected function onNotSuccessfulTest(\Throwable $t) { $this->restoreAllServices(); // restore database connection @@ -162,7 +144,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { }); } - parent::onNotSuccessfulTest($e); + parent::onNotSuccessfulTest($t); } protected function tearDown() { diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php index 88544cc6ce..24a72db006 100644 --- a/tests/startsessionlistener.php +++ b/tests/startsessionlistener.php @@ -6,45 +6,25 @@ * See the COPYING-README file. */ +use OC\Session\Memory; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestListenerDefaultImplementation; + /** * Starts a new session before each test execution */ -class StartSessionListener implements PHPUnit_Framework_TestListener { +class StartSessionListener implements TestListener { - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { - } + use TestListenerDefaultImplementation; - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { - } - - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function startTest(PHPUnit_Framework_Test $test) { - } - - public function endTest(PHPUnit_Framework_Test $test, $time) { + public function endTest(Test $test, $time) { // reopen the session - only allowed for memory session - if (\OC::$server->getSession() instanceof \OC\Session\Memory) { - /** @var $session \OC\Session\Memory */ + if (\OC::$server->getSession() instanceof Memory) { + /** @var $session Memory */ $session = \OC::$server->getSession(); $session->reopen(); } } - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { - } - - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) { - } - - public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) { - } - }