Skip to content

Commit

Permalink
Fix phpunit
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Mar 5, 2020
1 parent af3ec18 commit 4d2924a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ nbproject
/tests/Unit/coverage*
/tests/Unit/clover.xml
/tests/Unit/js/node_modules
/tests/Unit/.phpunit.result.cache

/tests/Integration/output
/tests/Integration/vendor
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/AppInfo/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
class RoutesTest extends TestCase {
public function testRoutes() {
$routes = include __DIR__ . '/../../../appinfo/routes.php';
$this->assertInternalType('array', $routes);
$this->assertIsArray($routes);
$this->assertCount(1, $routes);
$this->assertArrayHasKey('ocs', $routes);
$this->assertInternalType('array', $routes['ocs']);
$this->assertIsArray($routes['ocs']);
$this->assertCount(7, $routes['ocs']);
}
}
8 changes: 4 additions & 4 deletions tests/Unit/Controller/EndpointControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ public function testDeleteAllNotifications($_, $username) {

public function dataNotificationToArray() {
return [
['v1', 42, 'app1', 'user1', 1234, 'type1', 42, 'subject1', '', [], 'message1', 'richMessage 1', ['richMessage param'], 'link1', 'icon1', [], []],
['v1', 1337, 'app2', 'user2', 1337, 'type2', 21, 'subject2', 'richSubject 2', ['richSubject param'], 'message2', '', [], 'link2', 'icon2', [
['v1', 42, 'app1', 'user1', 1234, 'type1', '42', 'subject1', '', [], 'message1', 'richMessage 1', ['richMessage param'], 'link1', 'icon1', [], []],
['v1', 1337, 'app2', 'user2', 1337, 'type2', '21', 'subject2', 'richSubject 2', ['richSubject param'], 'message2', '', [], 'link2', 'icon2', [
$this->getMockBuilder(IAction::class)
->getMock(),
$this->getMockBuilder(IAction::class)
->getMock(),
], [['action'], ['action']]],
['v2', 42, 'app1', 'user1', 1234, 'type1', 42, 'subject1', '', [], 'message1', 'richMessage 1', ['richMessage param'], 'link1', 'icon1', [], []],
['v2', 1337, 'app2', 'user2', 1337, 'type2', 21, 'subject2', 'richSubject 2', ['richSubject param'], 'message2', '', [], 'link2', 'icon2', [
['v2', 42, 'app1', 'user1', 1234, 'type1', '42', 'subject1', '', [], 'message1', 'richMessage 1', ['richMessage param'], 'link1', 'icon1', [], []],
['v2', 1337, 'app2', 'user2', 1337, 'type2', '21', 'subject2', 'richSubject 2', ['richSubject param'], 'message2', '', [], 'link2', 'icon2', [
$this->getMockBuilder(IAction::class)
->getMock(),
$this->getMockBuilder(IAction::class)
Expand Down
12 changes: 4 additions & 8 deletions tests/Unit/Notifier/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ protected function setUp(): void {
);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Unknown app
*/
public function testPrepareWrongApp() {
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->createMock(INotification::class);
Expand All @@ -75,13 +71,11 @@ public function testPrepareWrongApp() {
$notification->expects($this->never())
->method('getSubject');

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown app');
$this->notifier->prepare($notification, 'en');
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Unknown subject
*/
public function testPrepareWrongSubject() {
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->createMock(INotification::class);
Expand All @@ -93,6 +87,8 @@ public function testPrepareWrongSubject() {
->method('getSubject')
->willReturn('wrong subject');

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown subject');
$this->notifier->prepare($notification, 'en');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/PushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public function testPushToDeviceSending($isDebug) {
$response2->expects($this->once())
->method('getStatusCode')
->willReturn(Http::STATUS_SERVICE_UNAVAILABLE);
$response2->expects($isDebug ? $this->once() : $this->never())
$response2->expects($this->once())
->method('getBody')
->willReturn('Maintenance');
$client->expects($this->at(2))
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
strict="true"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
Expand Down

0 comments on commit 4d2924a

Please sign in to comment.