Skip to content
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

#140: Global export mode not affect for email testing #159

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion src/Traits/MailsMockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ protected function assertFixture(array $expectedMailData, Mailable $mail, bool $
$data = (method_exists($mail, 'content')) ? $mail->content()->with : $mail->viewData;
$mailContent = view($view, $data)->render();

if ($exportMode) {
$globalExportMode = $this->globalExportMode ?? false;

if ($exportMode || $globalExportMode) {
$this->exportContent($mailContent, $expectedMailData['fixture']);
}

Expand Down
13 changes: 13 additions & 0 deletions tests/MailsMockTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ public function testMailWithExport()
$this->assertFileExists($this->getFixturePath('test_mail_with_export.html'));
}

public function testMailWithGlobalExportMode()
{
putenv('FAIL_EXPORT_JSON=false');

Mail::to('test@mail.com')->queue(new TestMail(['name' => 'John Smith']));

$this->assertMailEquals(TestMail::class, [
$this->mockedMail('test@mail.com', 'test_mail_with_global_export.html', 'Test Subject'),
]);

$this->assertFileExists($this->getFixturePath('test_mail_with_export.html'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you checking test_mail_with_export.html file, but asserting content with the test_mail_with_global_export.html?

}

public function testMailWithIncorrectSubject()
{
$this->expectException(ExpectationFailedException::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you using this fixture to check that globa export mode works fine and create file if it not exists. If you'll commit this file to git - test will always be successful completed even if global export mode will be broken

John Smith
</div>
Loading