-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vagrant
committed
Nov 23, 2019
1 parent
a25a75e
commit 6e17030
Showing
9 changed files
with
231 additions
and
67 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
vendor | ||
.lock | ||
composer.lock | ||
.phpunit.result.cache | ||
tests/_report |
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 |
---|---|---|
@@ -1,30 +1,35 @@ | ||
?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap = "vendor/autoload.php" | ||
backupGlobals = "false" | ||
backupStaticAttributes = "false" | ||
colors = "true" | ||
convertErrorsToExceptions = "true" | ||
convertNoticesToExceptions = "true" | ||
convertWarningsToExceptions = "true" | ||
processIsolation = "false" | ||
stopOnFailure = "false" | ||
syntaxCheck = "false"> | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="MultiMail Test Suite"> | ||
<directory>tests</directory> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./tests/</directory> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<server name="APP_ENV" value="testing"/> | ||
<server name="BCRYPT_ROUNDS" value="4"/> | ||
<server name="CACHE_DRIVER" value="array"/> | ||
<server name="MAIL_DRIVER" value="array"/> | ||
<server name="QUEUE_CONNECTION" value="sync"/> | ||
<server name="SESSION_DRIVER" value="array"/> | ||
</php> | ||
|
||
</phpunit> |
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 was deleted.
Oops, something went wrong.
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,42 @@ | ||
<?php | ||
|
||
namespace IWasHereFirst2\LaravelMultiMail\Tests; | ||
|
||
use IWasHereFirst2\LaravelMultiMail\MultiMailServiceProvider; | ||
|
||
class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* add the package provider | ||
* | ||
* @param $app | ||
* @return array | ||
*/ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [MultiMailServiceProvider::class]; | ||
} | ||
|
||
/** | ||
* Define environment setup. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* @return void | ||
*/ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
|
||
// Setup default database to use sqlite :memory: | ||
$app['config']->set('database.default', 'testbench'); | ||
$app['config']->set('database.connections.testbench', [ | ||
'driver' => 'sqlite', | ||
'database' => ':memory:', | ||
'prefix' => '', | ||
]); | ||
} | ||
} |
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 @@ | ||
{{__('nom')}} |
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,98 @@ | ||
<?php | ||
|
||
namespace IWasHereFirst2\LaravelMultiMail\Tests\Unit; | ||
|
||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Support\Facades\View; | ||
use IWasHereFirst2\LaravelMultiMail\Facades\MultiMail; | ||
use IWasHereFirst2\LaravelMultiMail\Tests\TestCase; | ||
use Swift_Events_EventListener; | ||
use Swift_Message; | ||
|
||
class MultiMailTest extends TestCase | ||
{ | ||
const FROM = '[email protected]'; | ||
|
||
protected $emails; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
MultiMail::registerPlugin(new TestingMailEventListener($this)); | ||
} | ||
|
||
/** @test */ | ||
public function check_if_mail_is_sendable() | ||
{ | ||
$to = '[email protected]'; | ||
$cc = '[email protected]'; | ||
$locale = 'de'; | ||
$from = static::FROM; | ||
$bcc = ['[email protected]', '[email protected]']; | ||
$pendingMail = MultiMail::to($to) | ||
->cc($cc) | ||
->locale($locale) | ||
->from($from) | ||
->bcc($bcc) | ||
->send(new TestMail()); | ||
|
||
$this->assertEquals(1, count($this->emails)); | ||
} | ||
|
||
/** | ||
* Define environment setup. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* @return void | ||
*/ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
|
||
// Setup default database to use sqlite :memory: | ||
$app['config']->set('multimail.emails', | ||
['[email protected]' => [ | ||
'pass' => 'fakepass', | ||
'username' => 'fakeusername', | ||
'from' => 'Who knows', | ||
]]); | ||
$app['config']->set('multimail.provider.default', [ | ||
'driver' => 'log', | ||
]); | ||
|
||
View::addLocation(__DIR__ . '/Fixtures'); | ||
} | ||
|
||
public function addEmail(Swift_Message $email) | ||
{ | ||
$this->emails[] = $email; | ||
} | ||
} | ||
|
||
class TestMail extends Mailable | ||
{ | ||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
return $this->view('view'); | ||
} | ||
} | ||
|
||
class TestingMailEventListener implements Swift_Events_EventListener | ||
{ | ||
protected $test; | ||
|
||
public function __construct($test) | ||
{ | ||
$this->test = $test; | ||
} | ||
|
||
public function beforeSendPerformed($event) | ||
{ | ||
$this->test->addEmail($event->getMessage()); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace IWasHereFirst2\LaravelMultiMail\Tests\Unit; | ||
|
||
use IWasHereFirst2\LaravelMultiMail\Facades\MultiMail; | ||
use IWasHereFirst2\LaravelMultiMail\Tests\TestCase; | ||
|
||
class PendingMailTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function check_if_object_chaining_works() | ||
{ | ||
$to = '[email protected]'; | ||
$cc = '[email protected]'; | ||
$locale = 'de'; | ||
$from = '[email protected]'; | ||
$bcc = ['[email protected]', '[email protected]']; | ||
|
||
$pendingMail = MultiMail::to($to) | ||
->cc($cc) | ||
->locale($locale) | ||
->from($from) | ||
->bcc($bcc); | ||
|
||
$pendingMail2 = MultiMail::locale($locale) | ||
->from($from) | ||
->to($to) | ||
->cc($cc) | ||
->bcc($bcc); | ||
|
||
$this->assertEquals($pendingMail, $pendingMail2); | ||
} | ||
} |