Skip to content

Commit

Permalink
Use PHP attributes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iv-craig committed Apr 2, 2024
1 parent aec8d23 commit 8b9eadd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
11 changes: 6 additions & 5 deletions tests/CouldNotSendNotificationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace NotificationChannels\Interfax\Test;

use PHPUnit\Framework\Attributes\Test;
use NotificationChannels\Interfax\Exceptions\CouldNotSendNotification;
use NotificationChannels\Interfax\InterfaxMessage;

Expand All @@ -19,7 +20,7 @@ public function setUp(): void
->file('test-file.pdf');
}

/** @test */
#[Test]
public function it_can_get_the_exception_user()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
Expand All @@ -30,7 +31,7 @@ public function it_can_get_the_exception_user()
$this->assertInstanceOf(TestNotifiable::class, $exception->getUser());
}

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

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

/** @test */
#[Test]
public function it_can_get_a_custom_exception_message()
{
$exceptionMessage = 'This is a test.';
Expand All @@ -65,7 +66,7 @@ public function it_can_get_a_custom_exception_message()
$this->assertSame($exceptionMessage, $exception->getMessage());
}

/** @test */
#[Test]
public function it_can_get_the_exception_attributes()
{
$exception = CouldNotSendNotification::serviceRespondedWithAnError($this->message, [
Expand Down
15 changes: 8 additions & 7 deletions tests/InterfaxChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NotificationChannels\Interfax\Test;

use Illuminate\Notifications\Notification;
use PHPUnit\Framework\Attributes\Test;
use Interfax\Client as InterfaxClient;
use Interfax\Resource as InterfaxResource;
use Mockery;
Expand Down Expand Up @@ -35,7 +36,7 @@ public function setUp(): void
$this->channel = new InterfaxChannel($this->interfax);
}

/** @test */
#[Test]
public function it_can_send_notification_with_a_single_file()
{
$this->interfax->expects('deliver')
Expand All @@ -55,7 +56,7 @@ public function it_can_send_notification_with_a_single_file()
$this->channel->send(new TestNotifiable, new TestNotificationWithSingleFile);
}

/** @test */
#[Test]
public function it_can_send_notification_with_files()
{
$this->interfax->expects('deliver')
Expand All @@ -81,7 +82,7 @@ public function it_can_send_notification_with_files()
$this->channel->send(new TestNotifiable, new TestNotificationWithFiles);
}

/** @test */
#[Test]
public function it_can_send_notification_pdf_as_stream()
{
$this->interfax->expects('deliver')
Expand Down Expand Up @@ -110,7 +111,7 @@ public function it_can_send_notification_pdf_as_stream()
$this->channel->send(new TestNotifiable, new TestNotificationAsStreamPdf);
}

/** @test */
#[Test]
public function it_can_send_notification_html_as_stream()
{
$filename = 'test-file.html';
Expand Down Expand Up @@ -144,13 +145,13 @@ public function it_can_send_notification_html_as_stream()
$this->channel->send(new TestNotifiable, new TestNotificationAsStreamHtml);
}

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

/** @test */
#[Test]
public function it_can_refresh_the_file_response()
{
$this->resource
Expand All @@ -169,7 +170,7 @@ public function it_can_refresh_the_file_response()
$this->channel->send(new TestNotifiable, new TestNotificationWithRefresh);
}

/** @test */
#[Test]
public function it_can_throw_the_exception()
{
$this->expectException(CouldNotSendNotification::class);
Expand Down
13 changes: 7 additions & 6 deletions tests/InterfaxMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace NotificationChannels\Interfax\Test;

use PHPUnit\Framework\Attributes\Test;
use NotificationChannels\Interfax\InterfaxMessage;

class InterfaxMessageTest extends TestCase
{
/** @test */
#[Test]
public function it_should_check_the_status_via_refresh()
{
$message = (new InterfaxMessage)
Expand All @@ -17,7 +18,7 @@ public function it_should_check_the_status_via_refresh()
$this->assertTrue($message->shouldCheckStatus());
}

/** @test */
#[Test]
public function it_should_not_check_the_status_via_refresh_manual()
{
$message = (new InterfaxMessage)
Expand All @@ -28,7 +29,7 @@ public function it_should_not_check_the_status_via_refresh_manual()
$this->assertFalse($message->shouldCheckStatus());
}

/** @test */
#[Test]
public function it_should_not_check_the_status_via_refresh_default()
{
$message = (new InterfaxMessage)
Expand All @@ -38,7 +39,7 @@ public function it_should_not_check_the_status_via_refresh_default()
$this->assertFalse($message->shouldCheckStatus());
}

/** @test */
#[Test]
public function it_should_set_the_file_chunk_size_filename()
{
$this->increaseChunkSize();
Expand All @@ -53,7 +54,7 @@ public function it_should_set_the_file_chunk_size_filename()
$this->assertSame($this->chunkSize, $this->getChunkSize($delivery));
}

/** @test */
#[Test]
public function it_should_set_the_file_chunk_size_file_array()
{
$this->increaseChunkSize();
Expand All @@ -68,7 +69,7 @@ public function it_should_set_the_file_chunk_size_file_array()
$this->assertSame($this->chunkSize, $this->getChunkSize($delivery));
}

/** @test */
#[Test]
public function it_should_set_the_file_chunk_size_file_object()
{
$this->increaseChunkSize();
Expand Down

0 comments on commit 8b9eadd

Please sign in to comment.