Fix warnings and errors with phpunit 8

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-11-28 14:54:16 +01:00
Родитель 80357681e6
Коммит 324a30dd5b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
9 изменённых файлов: 44 добавлений и 39 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -9,6 +9,7 @@ node_modules
coverage
tests/php/coverage-html
tests/php/clover.xml
tests/php/.phpunit.result.cache
tests/integration/vendor
tests/integration/output

Просмотреть файл

@ -162,9 +162,6 @@ class BaseTest extends TestCase {
$this->assertSame($event, static::invokePrivate($provider, 'preParse', [$event]));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPreParseThrows() {
/** @var IEvent|MockObject $event */
$event = $this->createMock(IEvent::class);
@ -172,6 +169,7 @@ class BaseTest extends TestCase {
->method('getApp')
->willReturn('activity');
$provider = $this->getProvider();
$this->expectException(\InvalidArgumentException::class);
static::invokePrivate($provider, 'preParse', [$event]);
}

Просмотреть файл

@ -96,9 +96,6 @@ class InvitationTest extends TestCase {
);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testParseThrowsWrongSubject() {
/** @var IEvent|MockObject $event */
$event = $this->createMock(IEvent::class);
@ -123,6 +120,7 @@ class InvitationTest extends TestCase {
->willReturn(false);
$provider = $this->getProvider();
$this->expectException(\InvalidArgumentException::class);
$provider->parse('en', $event);
}

Просмотреть файл

@ -49,7 +49,7 @@ class SettingTest extends TestCase {
public function testGetIdentifier($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('string', $setting->getIdentifier());
$this->assertIsString($setting->getIdentifier());
}
/**
@ -59,7 +59,7 @@ class SettingTest extends TestCase {
public function testGetName($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('string', $setting->getName());
$this->assertIsString($setting->getName());
}
/**
@ -70,7 +70,7 @@ class SettingTest extends TestCase {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$priority = $setting->getPriority();
$this->assertInternalType('int', $setting->getPriority());
$this->assertIsInt($setting->getPriority());
$this->assertGreaterThanOrEqual(0, $priority);
$this->assertLessThanOrEqual(100, $priority);
}
@ -82,7 +82,7 @@ class SettingTest extends TestCase {
public function testCanChangeStream($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->canChangeStream());
$this->assertIsBool($setting->canChangeStream());
}
/**
@ -92,7 +92,7 @@ class SettingTest extends TestCase {
public function testIsDefaultEnabledStream($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->isDefaultEnabledStream());
$this->assertIsBool($setting->isDefaultEnabledStream());
}
/**
@ -102,7 +102,7 @@ class SettingTest extends TestCase {
public function testCanChangeMail($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->canChangeMail());
$this->assertIsBool($setting->canChangeMail());
}
/**
@ -112,6 +112,6 @@ class SettingTest extends TestCase {
public function testIsDefaultEnabledMail($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->isDefaultEnabledMail());
$this->assertIsBool($setting->isDefaultEnabledMail());
}
}

Просмотреть файл

@ -68,7 +68,7 @@ class SearchPluginTest extends \Test\TestCase {
/**
* @param string[] $methods
* @return SearchPlugin|\PHPUnit_Framework_MockObject_MockObject
* @return SearchPlugin|MockObject
*/
protected function getPlugin(array $methods = []) {
if (empty($methods)) {
@ -131,7 +131,7 @@ class SearchPluginTest extends \Test\TestCase {
->with('fo', ['123', 'foo', 'bar'], $result)
->willReturnCallback(function($search, $users, $result) {
array_map(function($user) {
$this->assertInternalType('string', $user);
$this->assertIsString($user);
}, $users);
});
$plugin->expects($this->once())
@ -139,7 +139,7 @@ class SearchPluginTest extends \Test\TestCase {
->with('fo', $this->anything(), $result)
->willReturnCallback(function($search, $guests, $result) {
array_map(function($guest) {
$this->assertInternalType('string', $guest);
$this->assertIsString($guest);
$this->assertSame(40, strlen($guest));
}, $guests);
});

Просмотреть файл

@ -397,7 +397,6 @@ class SystemMessageTest extends TestCase {
/**
* @dataProvider dataParseMessageThrows
* @param string|null $return
* @expectedException \OutOfBoundsException
*/
public function testParseMessageThrows($return) {
/** @var IComment|MockObject $comment */
@ -416,6 +415,7 @@ class SystemMessageTest extends TestCase {
$chatMessage = new Message($room, $participant, $comment, $this->l);
$chatMessage->setMessage($return, []);
$this->expectException(\OutOfBoundsException::class);
$parser->parseMessage($chatMessage);
}
@ -606,9 +606,6 @@ class SystemMessageTest extends TestCase {
], self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']));
}
/**
* @expectedException \OCP\Files\NotFoundException
*/
public function testGetFileFromShareForRecipientThrows() {
$node = $this->createMock(Node::class);
$node->expects($this->once())
@ -651,12 +648,10 @@ class SystemMessageTest extends TestCase {
->method('linkToRouteAbsolute');
$parser = $this->getParser();
$this->expectException(NotFoundException::class);
self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']);
}
/**
* @expectedException \OCP\Share\Exceptions\ShareNotFound
*/
public function testGetFileFromShareThrows() {
$this->shareProvider->expects($this->once())
@ -666,6 +661,7 @@ class SystemMessageTest extends TestCase {
$participant = $this->createMock(Participant::class);
$parser = $this->getParser();
$this->expectException(ShareNotFound::class);
self::invokePrivate($parser, 'getFileFromShare', [$participant, '23']);
}

Просмотреть файл

@ -216,8 +216,8 @@ class RoomPluginTest extends \Test\TestCase {
* @dataProvider searchProvider
*
* @param string $searchTerm
* @param bool $limit
* @param bool $offset
* @param int $limit
* @param int $offset
* @param array $roomsForParticipant
* @param array $expectedMatchesExact
* @param array $expectedMatches
@ -225,8 +225,8 @@ class RoomPluginTest extends \Test\TestCase {
*/
public function testSearch(
string $searchTerm,
bool $limit,
bool $offset,
int $limit,
int $offset,
array $roomsForParticipant,
array $expectedMatchesExact,
array $expectedMatches,

Просмотреть файл

@ -758,8 +758,6 @@ class NotifierTest extends \Test\TestCase {
/**
* @dataProvider dataPrepareThrows
*
* @expectedException \InvalidArgumentException
*
* @param string $message
* @param string $app
* @param bool|null $isDisabledForUser
@ -835,15 +833,30 @@ class NotifierTest extends \Test\TestCase {
$n->expects($this->once())
->method('getApp')
->willReturn($app);
$n->expects($subject === null ? $this->never() : $this->atLeastOnce())
->method('getSubject')
->willReturn($subject);
$n->expects($params === null ? $this->never() : $this->once())
->method('getSubjectParameters')
->willReturn($params);
$n->expects($objectType === null ? $this->never() : $this->once())
->method('getObjectType')
->willReturn($objectType);
if ($subject === null) {
$n->expects($this->never())
->method('getSubject');
} else {
$n->expects($this->once())
->method('getSubject')
->willReturn($subject);
}
if ($params === null) {
$n->expects($this->never())
->method('getSubjectParameters');
} else {
$n->expects($this->once())
->method('getSubjectParameters')
->willReturn($params);
}
if ($objectType === null) {
$n->expects($this->never())
->method('getObjectType');
} else {
$n->expects($this->once())
->method('getObjectType')
->willReturn($objectType);
}
if ($message === AlreadyProcessedException::class) {
$this->expectException(AlreadyProcessedException::class);

Просмотреть файл

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
strict="true"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"