Skip to content

Commit 653a85b

Browse files
jessarcheratymic
authored andcommitted
Fix tests and build (laravel-notification-channels#41)
* Update to latest phpunit and mockery * Fix test expectations * Linting * Test with PHP 7.4 * Remove unnecessary test tear down
1 parent 223623e commit 653a85b

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
build
33
composer.phar
44
composer.lock
5+
.phpunit.result.cache

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: php
33
php:
44
- 7.2
55
- 7.3
6+
- 7.4
67

78
env:
89
matrix:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"pusher/pusher-php-server": "~3.0 || ~4.0"
4141
},
4242
"require-dev": {
43-
"mockery/mockery": "^0.9.5",
44-
"phpunit/phpunit": "5.*"
43+
"mockery/mockery": "^1.3",
44+
"phpunit/phpunit": "^8.5"
4545
},
4646
"autoload": {
4747
"psr-4": {

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<logging>
2323
<log type="tap" target="build/report.tap"/>
2424
<log type="junit" target="build/report.junit.xml"/>
25-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
25+
<log type="coverage-html" target="build/coverage"/>
2626
<log type="coverage-text" target="build/coverage.txt"/>
2727
<log type="coverage-clover" target="build/logs/clover.xml"/>
2828
</logging>

tests/ChannelTest.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace NotificationChannels\PusherPushNotifications\Test;
44

5-
use Mockery;
6-
use Pusher\Pusher;
7-
use PHPUnit_Framework_TestCase;
85
use Illuminate\Events\Dispatcher;
6+
use Illuminate\Notifications\Events\NotificationFailed;
97
use Illuminate\Notifications\Notifiable;
108
use Illuminate\Notifications\Notification;
11-
use Illuminate\Notifications\Events\NotificationFailed;
9+
use Mockery;
10+
use Mockery\Adapter\Phpunit\MockeryTestCase;
1211
use NotificationChannels\PusherPushNotifications\PusherChannel;
1312
use NotificationChannels\PusherPushNotifications\PusherMessage;
13+
use Pusher\Pusher;
1414

15-
class ChannelTest extends PHPUnit_Framework_TestCase
15+
class ChannelTest extends MockeryTestCase
1616
{
17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
$this->pusher = Mockery::mock(Pusher::class);
2020

@@ -27,21 +27,14 @@ public function setUp()
2727
$this->notifiable = new TestNotifiable;
2828
}
2929

30-
public function tearDown()
31-
{
32-
Mockery::close();
33-
34-
parent::tearDown();
35-
}
36-
3730
/** @test */
3831
public function it_can_send_a_notification()
3932
{
4033
$message = $this->notification->toPushNotification($this->notifiable);
4134

4235
$data = $message->toArray();
4336

44-
$this->pusher->shouldReceive('notify')->with('interest_name', $data, true)->andReturn(['status' => 202]);
37+
$this->pusher->shouldReceive('notify')->with(['interest_name'], $data, true)->andReturn(['status' => 202]);
4538

4639
$this->channel->send($this->notifiable, $this->notification);
4740
}
@@ -53,7 +46,7 @@ public function it_fires_failure_event_on_failure()
5346

5447
$data = $message->toArray();
5548

56-
$this->pusher->shouldReceive('notify')->with('interest_name', $data, true)->andReturn(['status' => 500]);
49+
$this->pusher->shouldReceive('notify')->with(['interest_name'], $data, true)->andReturn(['status' => 500]);
5750

5851
$this->events->shouldReceive('fire')->with(Mockery::type(NotificationFailed::class));
5952

tests/MessageTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace NotificationChannels\PusherPushNotifications\Test;
44

55
use Illuminate\Support\Arr;
6-
use PHPUnit_Framework_TestCase;
7-
use NotificationChannels\PusherPushNotifications\PusherMessage;
6+
use Mockery\Adapter\Phpunit\MockeryTestCase;
87
use NotificationChannels\PusherPushNotifications\Exceptions\CouldNotCreateMessage;
8+
use NotificationChannels\PusherPushNotifications\PusherMessage;
99

10-
class MessageTest extends PHPUnit_Framework_TestCase
10+
class MessageTest extends MockeryTestCase
1111
{
1212
/** @var \NotificationChannels\PusherPushNotifications\PusherMessage */
1313
protected $message;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

@@ -111,7 +111,7 @@ public function it_can_set_the_icon()
111111
/** @test */
112112
public function it_will_throw_an_exception_when_an_unsupported_platform_is_used()
113113
{
114-
$this->setExpectedException(CouldNotCreateMessage::class);
114+
$this->expectException(CouldNotCreateMessage::class);
115115

116116
$this->message->platform('bla bla');
117117
}

0 commit comments

Comments
 (0)