Browse Source

Require PHPUnit 6.5 or higher

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/8036/head
Joas Schilling 8 years ago
parent
commit
c3424df1f0
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 3
      apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php
  2. 4
      apps/dav/tests/unit/bootstrap.php
  3. 6
      autotest.sh
  4. 4
      tests/bootstrap.php
  5. 3
      tests/lib/Contacts/ContactsMenu/EntryTest.php
  6. 24
      tests/lib/TestCase.php
  7. 40
      tests/startsessionlistener.php

3
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/';

4
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');

6
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

4
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');

3
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;

24
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() {

40
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 {
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
}
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) {
}
class StartSessionListener implements TestListener {
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
}
public function startTest(PHPUnit_Framework_Test $test) {
}
use TestListenerDefaultImplementation;
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) {
}
}
Loading…
Cancel
Save