-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laravel 10 #14
Merged
Merged
Laravel 10 #14
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
services: | ||
php: | ||
image: php:8.3-fpm # Or any other version you want | ||
volumes: | ||
- ./:/var/www/html # Mount the current directory to the container | ||
working_dir: /var/www/html | ||
ports: | ||
- "8088:80" | ||
depends_on: | ||
- composer | ||
networks: | ||
- newsletter-driver-network | ||
|
||
composer: | ||
image: composer:latest | ||
volumes: | ||
- ./:/var/www/html # Same mount so composer can install dependencies | ||
working_dir: /var/www/html | ||
networks: | ||
- newsletter-driver-network | ||
entrypoint: ['composer'] | ||
|
||
networks: | ||
newsletter-driver-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Lundalogik\NewsletterDriver\Tests\Unit; | ||
|
||
use Lundalogik\NewsletterDriver\Newsletter\SendTransactionMailBatchArgs; | ||
use Lundalogik\NewsletterDriver\Newsletter\TransactionMail; | ||
use PHPUnit\Framework\TestCase; | ||
use Lundalogik\NewsletterDriver\Transport\NewsletterTransport; | ||
use Mockery; | ||
use Spatie\TemporaryDirectory\Exceptions\PathAlreadyExists; | ||
use Spatie\TemporaryDirectory\TemporaryDirectory; | ||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface; | ||
use Symfony\Component\Mime\Email; | ||
|
||
class NewsletterTransportTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @throws PathAlreadyExists | ||
* @throws TransportExceptionInterface | ||
*/ | ||
public function test_it_can_send_full_email_with_attachments(): void | ||
{ | ||
$tempDir = (new TemporaryDirectory()) | ||
->deleteWhenDestroyed() | ||
->create(); | ||
|
||
$tmpPath = $tempDir->path('test.txt'); | ||
file_put_contents($tmpPath, 'this is a test'); | ||
|
||
$message = new Email(); | ||
$message->from('noreply@lime-forms.com') | ||
->to('albin.hallen@lime.tech') | ||
->subject('Test from laravel-newsletter-driver') | ||
->html("<p>This is a test email from laravel-newsletter-driver</p>") | ||
->attachFromPath($tmpPath, 'test.txt'); | ||
|
||
$api = Mockery::mock(TransactionMail::class); | ||
|
||
/** @phpstan-ignore-next-line */ | ||
$api->shouldReceive('sendBatch') | ||
->once() | ||
->with(Mockery::on(function ($args) use ($message) { | ||
$this->assertInstanceOf(SendTransactionMailBatchArgs::class, $args); | ||
|
||
$batchArgs = $args->toArray(); | ||
$firstBatch = (object) $batchArgs['SendTransactionMailArgs'][0]; | ||
|
||
$this->assertEquals($firstBatch->RecipientEmail, $message->getTo()[0]->getAddress()); | ||
$this->assertEquals($firstBatch->RecipientName, $message->getTo()[0]->getName()); | ||
$this->assertEquals($firstBatch->FromEmail, $message->getFrom()[0]->getAddress()); | ||
$this->assertEquals($firstBatch->FromName, $message->getFrom()[0]->getName()); | ||
$this->assertEquals($firstBatch->Subject, $message->getSubject()); | ||
$this->assertNotEmpty($firstBatch->HtmlContent); | ||
|
||
$firstBatchAttachments = $batchArgs['BatchAttachments']; | ||
$this->assertEquals('test.txt', $firstBatchAttachments[0]['FileNameWithExtension']); | ||
|
||
return 1 === count($batchArgs['SendTransactionMailArgs']); | ||
}))->andReturn(); | ||
|
||
/** @phpstan-ignore-next-line */ | ||
(new NewsletterTransport($api))->send($message); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running
dependency-version: [prefer-lowest, prefer-stable]
, the versions don't use the same schema so need to migrate it before running