Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 50 additions & 44 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
name: run-tests

on:
push:
pull_request:
push:
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [ 8.4 8.3, 8.2 ]
laravel: [ '10.*', '11.*', '12.*' ]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4, 8.3, 8.2]
laravel: ["10.*", "11.*", "12.*", "13.*"]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 13.*
testbench: 11.*
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
exclude:
- laravel: 13.*
php: 8.2

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer require "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"php": "^8.2",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "^7.1",
"illuminate/notifications": "^10.0 || ^11.0 || ^12.0",
"illuminate/support": "^10.0 || ^11.0 || ^12.0"
"illuminate/notifications": "^10.0 || ^11.0 || ^12.0 || ^13.0",
"illuminate/support": "^10.0 || ^11.0 || ^12.0 || ^13.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.6",
"mockery/mockery": "^1.5",
"orchestra/testbench": "^8.0 || ^9.0 || ^10.0",
"orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0",
"phpunit/phpunit": "^10.5 || ^11.0"
},
"config": {
Expand Down
18 changes: 13 additions & 5 deletions tests/CmsmsChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@
use NotificationChannels\Cmsms\CmsmsChannel;
use NotificationChannels\Cmsms\CmsmsClient;
use NotificationChannels\Cmsms\CmsmsMessage;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class CmsmsChannelTest extends TestCase
{
public static $latestResponse;

private TestNotification $notification;
private TestNotifiable $notifiable;
private Client $guzzle;
private CmsmsClient $client;
private CmsmsChannel $channel;

public function setUp(): void
{
parent::setUp();
Expand All @@ -30,17 +40,15 @@ public function tearDown(): void
parent::tearDown();
}

/** @test */
#[Test]
public function it_can_be_instantiated()
{
$this->assertInstanceOf(CmsmsClient::class, $this->client);
$this->assertInstanceOf(CmsmsChannel::class, $this->channel);
}

/**
* @test
* @doesNotPerformAssertions
*/
#[Test]
#[DoesNotPerformAssertions]
public function it_shares_message()
{
$this->client->shouldReceive('send')->once();
Expand Down
40 changes: 22 additions & 18 deletions tests/CmsmsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@
use NotificationChannels\Cmsms\Events\SMSSentSuccessfullyEvent;
use NotificationChannels\Cmsms\Exceptions\CouldNotSendNotification;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\Attributes\Test;

class CmsmsClientTest extends TestCase
{
public static $latestResponse;

private Client $guzzle;
private CmsmsClient $client;
private CmsmsMessage $message;

public function setUp(): void
{
parent::setUp();
Expand All @@ -30,17 +38,15 @@ public function tearDown(): void
parent::tearDown();
}

/** @test */
#[Test]
public function it_can_be_instantiated()
{
$this->assertInstanceOf(CmsmsClient::class, $this->client);
$this->assertInstanceOf(CmsmsMessage::class, $this->message);
}

/**
* @test
* @doesNotPerformAssertions
*/
#[Test]
#[DoesNotPerformAssertions]
public function it_can_send_message()
{
$this->guzzle
Expand All @@ -51,16 +57,14 @@ public function it_can_send_message()
$this->client->send($this->message, '00301234');
}

/**
* @test
* @doesNotPerformAssertions
*/
#[Test]
#[DoesNotPerformAssertions]
public function it_sets_a_default_originator_if_none_is_set()
{
$message = Mockery::mock(CmsmsMessage::create('Message body'));
$message->shouldReceive('originator')
->once()
->with($this->app['config']['services.cmsms.originator']);
->once()
->with($this->app['config']['services.cmsms.originator']);

$this->guzzle
->shouldReceive('request')
Expand All @@ -70,7 +74,7 @@ public function it_sets_a_default_originator_if_none_is_set()
$this->client->send($message, '00301234');
}

/** @test */
#[Test]
public function it_throws_exception_on_error_response()
{
$this->expectException(CouldNotSendNotification::class);
Expand All @@ -83,7 +87,7 @@ public function it_throws_exception_on_error_response()
$this->client->send($this->message, '00301234');
}

/** @test */
#[Test]
public function it_includes_multipart_data()
{
$message = clone $this->message;
Expand All @@ -99,7 +103,7 @@ public function it_includes_multipart_data()
$this->assertEquals(6, $messageJsonObject->messages->msg[0]->maximumNumberOfMessageParts);
}

/** @test */
#[Test]
public function it_includes_reference_data()
{
$message = clone $this->message;
Expand All @@ -113,7 +117,7 @@ public function it_includes_reference_data()
$this->assertEquals('ABC', $messageJsonObject->messages->msg[0]->reference);
}

/** @test */
#[Test]
public function it_includes_encoding_detection_type_data_in_body()
{
$message = clone $this->message;
Expand All @@ -128,7 +132,7 @@ public function it_includes_encoding_detection_type_data_in_body()
$this->assertEquals('0', $messageJsonObject->messages->msg[0]->dcs);
}

/** @test */
#[Test]
public function it_includes_encoding_detection_type_data_in_message()
{
$message = clone $this->message;
Expand All @@ -142,7 +146,7 @@ public function it_includes_encoding_detection_type_data_in_message()
$this->assertEquals('1', $messageJsonObject->messages->msg[0]->dcs);
}

/** @test */
#[Test]
public function it_dispatches_a_success_event()
{
Event::fake();
Expand All @@ -157,7 +161,7 @@ public function it_dispatches_a_success_event()
Event::assertDispatched(SMSSentSuccessfullyEvent::class);
}

/** @test */
#[Test]
public function it_dispatches_a_failure_event()
{
Event::fake();
Expand Down
Loading