Skip to content

Commit

Permalink
Merge pull request #16 from ivinteractive/main
Browse files Browse the repository at this point in the history
Add PHP 8.3 & Laravel 11 support;  Use PHP attributes in tests
  • Loading branch information
iv-craig authored Apr 2, 2024
2 parents 7a7e41a + d22fbc9 commit 3e793a3
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 48 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,40 @@ on:
jobs:
phpstan:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.3]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('composer.lock', '*/composer.lock') }}

- name: Install dependencies
run: composer update --prefer-source --no-interaction --no-progress
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php }}
php_extensions: gd
command: update

- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
path: src/
configuration: phpstan.neon
php_version: 8.2
php_version: ${{ matrix.php }}
php_extensions: gd
19 changes: 16 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.0, 8.1, 8.2]
php: [8.1, 8.2, 8.3]

name: Tests on PHP ${{ matrix.php }} - ${{ matrix.stability }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -25,8 +25,21 @@ jobs:
tools: composer:v2
coverage: none

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('composer.lock', '*/composer.lock') }}

- name: Install dependencies
run: composer update --prefer-source --no-interaction --no-progress
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php }}
php_extensions: gd
command: update

- name: Set ownership of vendor directory
run: sudo chown -R $(id -u):$(id -g) ./vendor

- name: Execute tests
run: vendor/bin/phpunit --no-coverage
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
}
],
"require": {
"php": "^8.0",
"illuminate/notifications": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"php": "^8.1",
"illuminate/notifications": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"interfax/interfax": "^2.0",
"psr/log": "^2.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"mpdf/mpdf": "^8.0",
"orchestra/testbench": "^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5.10|^10.0"
"phpunit/phpunit": "^10.0|^11.0"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 5 additions & 10 deletions tests/CouldNotSendNotificationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function setUp(): void
->file('test-file.pdf');
}

/** @test */
public function it_can_get_the_exception_user()
public function test_get_the_exception_user()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
'status' => 500,
Expand All @@ -30,8 +29,7 @@ public function it_can_get_the_exception_user()
$this->assertInstanceOf(TestNotifiable::class, $exception->getUser());
}

/** @test */
public function it_can_get_the_exception_metadata()
public function test_get_the_exception_metadata()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
'status' => 500,
Expand All @@ -41,8 +39,7 @@ public function it_can_get_the_exception_metadata()
$this->assertSame('Some sample metadata.', $exception->getMetadata()['key']);
}

/** @test */
public function it_can_get_the_default_exception_message()
public function test_get_the_default_exception_message()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
'status' => 500,
Expand All @@ -52,8 +49,7 @@ public function it_can_get_the_default_exception_message()
$this->assertSame('The fax failed to send via InterFAX.', $exception->getMessage());
}

/** @test */
public function it_can_get_a_custom_exception_message()
public function test_get_a_custom_exception_message()
{
$exceptionMessage = 'This is a test.';

Expand All @@ -65,8 +61,7 @@ public function it_can_get_a_custom_exception_message()
$this->assertSame($exceptionMessage, $exception->getMessage());
}

/** @test */
public function it_can_get_the_exception_attributes()
public function test_get_the_exception_attributes()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
'status' => 500,
Expand Down
21 changes: 7 additions & 14 deletions tests/InterfaxChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function setUp(): void
$this->channel = new InterfaxChannel($this->interfax);
}

/** @test */
public function it_can_send_notification_with_a_single_file()
public function test_send_notification_with_a_single_file()
{
$this->interfax->expects('deliver')
->once()
Expand All @@ -55,8 +54,7 @@ public function it_can_send_notification_with_a_single_file()
$this->channel->send(new TestNotifiable, new TestNotificationWithSingleFile);
}

/** @test */
public function it_can_send_notification_with_files()
public function test_send_notification_with_files()
{
$this->interfax->expects('deliver')
->once()
Expand All @@ -81,8 +79,7 @@ public function it_can_send_notification_with_files()
$this->channel->send(new TestNotifiable, new TestNotificationWithFiles);
}

/** @test */
public function it_can_send_notification_pdf_as_stream()
public function test_send_notification_pdf_as_stream()
{
$this->interfax->expects('deliver')
->with(Mockery::on(function ($output) {
Expand Down Expand Up @@ -110,8 +107,7 @@ public function it_can_send_notification_pdf_as_stream()
$this->channel->send(new TestNotifiable, new TestNotificationAsStreamPdf);
}

/** @test */
public function it_can_send_notification_html_as_stream()
public function test_send_notification_html_as_stream()
{
$filename = 'test-file.html';
$this->addFile($filename);
Expand Down Expand Up @@ -144,14 +140,12 @@ public function it_can_send_notification_html_as_stream()
$this->channel->send(new TestNotifiable, new TestNotificationAsStreamHtml);
}

/** @test */
public function it_can_return_early_when_no_fax_number_provided()
public function test_return_early_when_no_fax_number_provided()
{
$this->assertNull($this->channel->send(new TestNotifiableNotSendable, new TestNotificationWithFiles));
}

/** @test */
public function it_can_refresh_the_file_response()
public function test_refresh_the_file_response()
{
$this->resource
->expects('refresh')
Expand All @@ -169,8 +163,7 @@ public function it_can_refresh_the_file_response()
$this->channel->send(new TestNotifiable, new TestNotificationWithRefresh);
}

/** @test */
public function it_can_throw_the_exception()
public function test_throw_the_exception()
{
$this->expectException(CouldNotSendNotification::class);

Expand Down
18 changes: 6 additions & 12 deletions tests/InterfaxMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class InterfaxMessageTest extends TestCase
{
/** @test */
public function it_should_check_the_status_via_refresh()
public function test_check_the_status_via_refresh()
{
$message = (new InterfaxMessage)
->checkStatus()
Expand All @@ -17,8 +16,7 @@ public function it_should_check_the_status_via_refresh()
$this->assertTrue($message->shouldCheckStatus());
}

/** @test */
public function it_should_not_check_the_status_via_refresh_manual()
public function test_not_check_the_status_via_refresh_manual()
{
$message = (new InterfaxMessage)
->checkStatus(false)
Expand All @@ -28,8 +26,7 @@ public function it_should_not_check_the_status_via_refresh_manual()
$this->assertFalse($message->shouldCheckStatus());
}

/** @test */
public function it_should_not_check_the_status_via_refresh_default()
public function test_not_check_the_status_via_refresh_default()
{
$message = (new InterfaxMessage)
->user(new TestNotifiable)
Expand All @@ -38,8 +35,7 @@ public function it_should_not_check_the_status_via_refresh_default()
$this->assertFalse($message->shouldCheckStatus());
}

/** @test */
public function it_should_set_the_file_chunk_size_filename()
public function test_set_the_file_chunk_size_filename()
{
$this->increaseChunkSize();

Expand All @@ -53,8 +49,7 @@ public function it_should_set_the_file_chunk_size_filename()
$this->assertSame($this->chunkSize, $this->getChunkSize($delivery));
}

/** @test */
public function it_should_set_the_file_chunk_size_file_array()
public function test_set_the_file_chunk_size_file_array()
{
$this->increaseChunkSize();

Expand All @@ -68,8 +63,7 @@ public function it_should_set_the_file_chunk_size_file_array()
$this->assertSame($this->chunkSize, $this->getChunkSize($delivery));
}

/** @test */
public function it_should_set_the_file_chunk_size_file_object()
public function test_set_the_file_chunk_size_file_object()
{
$this->increaseChunkSize();
$client = new \Interfax\Client;
Expand Down

0 comments on commit 3e793a3

Please sign in to comment.