Skip to content

Commit

Permalink
Laravel 6.0 & PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaoda committed Sep 11, 2019
1 parent fab4c23 commit 078960f
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 61 deletions.
20 changes: 9 additions & 11 deletions .travis.yml
@@ -1,22 +1,20 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- '7.2'
- '7.3'

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- phpunit --coverage-text --coverage-clover=coverage.clover
- ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

All notable changes to `gitter` will be documented in this file

## 2.0.0 - 2019-09-11

- Laravel 6.0 & PHP 7.2

## 1.0.1 - 2017-02-23

- Updated to support Laravel 5.4
Expand Down
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -27,12 +27,18 @@ This package makes it easy to send notifications using [Gitter.im](//gitter.im)

## Installation

You can install the package via composer:
Install this package with Composer:

```bash
composer require laravel-notification-channels/gitter
```

If you're using Laravel 5.x you'll also need to specify a version constraint:

```bash
composer require laravel-notification-channels/gitter -v 1.0.1
```

### Setting up the Gitter service

In order to send message to Gitter rooms, you need to obtain [Personal Access Token or application token](https://developer.gitter.im/apps).
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -13,16 +13,16 @@
}
],
"require": {
"php": ">=5.6.4",
"php": "^7.2",
"guzzlehttp/guzzle": "^6.2",
"illuminate/queue": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
"illuminate/notifications": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*"
"illuminate/queue": "5.1 - 5.8|^6.0",
"illuminate/notifications": "5.1 - 5.8|^6.0",
"illuminate/support": "5.1 - 5.8|^6.0"

},
"require-dev": {
"phpunit/phpunit": "~5.2",
"mockery/mockery": "^0.9.5"
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.2"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 8 additions & 7 deletions phpunit.xml
Expand Up @@ -8,9 +8,10 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="Gitter Test Suite">
<testsuite name="laravel-notification-channels/gitter Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand All @@ -20,10 +21,10 @@
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="tap" target="build/report.tap" />
<log type="junit" target="build/report.junit.xml" />
<log type="coverage-html" target="build/coverage" />
<log type="coverage-text" target="build/coverage.txt" />
<log type="coverage-clover" target="build/logs/clover.xml" />
</logging>
</phpunit>
19 changes: 7 additions & 12 deletions src/GitterChannel.php
Expand Up @@ -12,7 +12,7 @@ class GitterChannel
{
protected $baseUrl = 'https://api.gitter.im/v1/rooms';

/** @var \GuzzleHttp\Client */
/** @var HttpClient */
protected $httpClient;

public function __construct(HttpClient $client)
Expand All @@ -23,15 +23,15 @@ public function __construct(HttpClient $client)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @param mixed $notifiable
* @param Notification $notification
*
* @throws \NotificationChannels\Gitter\Exceptions\CouldNotSendNotification
* @return void
*/
public function send($notifiable, Notification $notification)
public function send($notifiable, Notification $notification): void
{
/** @var GitterMessage $message */
$message = $notification->toGitter($notifiable);
$message = $notification->{'toGitter'}($notifiable);

if (empty($message->room)) {
$message->room($notifiable->routeNotificationFor('gitter'));
Expand All @@ -40,12 +40,7 @@ public function send($notifiable, Notification $notification)
$this->sendMessage($message);
}

/**
* @param GitterMessage $message
*
* @throws CouldNotSendNotification
*/
protected function sendMessage(GitterMessage $message)
protected function sendMessage(GitterMessage $message): void
{
if (empty($message->room)) {
throw CouldNotSendNotification::missingRoom();
Expand Down
10 changes: 5 additions & 5 deletions src/GitterMessage.php
Expand Up @@ -40,9 +40,9 @@ public static function create($content = '')
/**
* Create a new instance of GitterMessage.
*
* @param $content
* @param string $content
*/
public function __construct($content = '')
public function __construct(string $content = '')
{
$this->content($content);
}
Expand All @@ -54,7 +54,7 @@ public function __construct($content = '')
*
* @return $this
*/
public function room($roomId)
public function room(string $roomId)
{
$this->room = $roomId;

Expand All @@ -68,7 +68,7 @@ public function room($roomId)
*
* @return $this
*/
public function from($accessToken)
public function from(string $accessToken)
{
$this->from = $accessToken;

Expand All @@ -82,7 +82,7 @@ public function from($accessToken)
*
* @return $this
*/
public function content($content)
public function content(string $content)
{
$this->content = $content;

Expand Down
14 changes: 6 additions & 8 deletions tests/GitterChannelTest.php
Expand Up @@ -5,20 +5,20 @@
use Mockery;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Illuminate\Notifications\Notification;
use NotificationChannels\Gitter\GitterChannel;
use NotificationChannels\Gitter\GitterMessage;
use NotificationChannels\Gitter\Exceptions\CouldNotSendNotification;

class GitterChannelTest extends \PHPUnit_Framework_TestCase
class GitterChannelTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
Mockery::close();
}

/** @test */
public function it_can_send_a_notification()
public function test_it_can_send_a_notification(): void
{
$client = Mockery::mock(Client::class);

Expand All @@ -35,17 +35,15 @@ public function it_can_send_a_notification()
$channel->send(new TestNotifiable(), new TestNotification());
}

/** @test */
public function it_does_not_send_a_message_when_room_missed()
public function test_it_does_not_send_a_message_when_room_missed(): void
{
$this->expectException(CouldNotSendNotification::class);

$channel = new GitterChannel(new Client());
$channel->send(new TestNotifiable(), new TestNotificationWithMissedRoom());
}

/** @test */
public function it_does_not_send_a_message_when_from_missed()
public function test_it_does_not_send_a_message_when_from_missed(): void
{
$this->expectException(CouldNotSendNotification::class);

Expand Down
18 changes: 7 additions & 11 deletions tests/GitterMessageTest.php
Expand Up @@ -2,44 +2,40 @@

namespace NotificationChannels\Gitter\Test;

use PHPUnit\Framework\TestCase;
use NotificationChannels\Gitter\GitterMessage;

class GitterMessageTest extends \PHPUnit_Framework_TestCase
class GitterMessageTest extends TestCase
{
/** @test */
public function it_can_accept_a_content_when_constructing_a_message()
public function test_it_can_accept_a_content_when_constructing_a_message(): void
{
$message = new GitterMessage('hello');

$this->assertEquals('hello', $message->content);
}

/** @test */
public function it_can_accept_a_content_when_creating_a_message()
public function test_it_can_accept_a_content_when_creating_a_message(): void
{
$message = GitterMessage::create('hello');

$this->assertEquals('hello', $message->content);
}

/** @test */
public function it_can_set_the_content()
public function test_it_can_set_the_content(): void
{
$message = (new GitterMessage())->content('hello');

$this->assertEquals('hello', $message->content);
}

/** @test */
public function it_can_set_the_room()
public function test_it_can_set_the_room(): void
{
$message = (new GitterMessage())->room('room');

$this->assertEquals('room', $message->room);
}

/** @test */
public function it_can_set_the_from()
public function test_it_can_set_the_from(): void
{
$message = (new GitterMessage())->from('token');

Expand Down

0 comments on commit 078960f

Please sign in to comment.