This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from spaantje/add-tests
Add tests, Github Workflow and drop support for EOL Laravel Versions
- Loading branch information
Showing
9 changed files
with
216 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: run-tests | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
php: [7.3, 7.4, 8.0] | ||
laravel: [6.*, 8.*] | ||
stability: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 6.* | ||
testbench: ^4.14 | ||
- laravel: 8.* | ||
testbench: ^6.20 | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update | ||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
composer.phar | ||
composer.lock | ||
.DS_Store | ||
.phpunit.result.cache |
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,4 @@ | ||
preset: laravel | ||
|
||
disabled: | ||
- single_class_element_per_statement |
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<!--<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite>--> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<server name="APP_ENV" value="testing"/> | ||
<server name="BCRYPT_ROUNDS" value="4"/> | ||
<server name="CACHE_DRIVER" value="array"/> | ||
<server name="DB_CONNECTION" value="sqlite"/> | ||
<server name="DB_DATABASE" value=":memory:"/> | ||
<server name="MAIL_DRIVER" value="array"/> | ||
<server name="MAIL_MAILER" 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace ShvetsGroup\LaravelEmailDatabaseLog\Tests\Feature; | ||
|
||
use Illuminate\Support\Facades\Mail; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use ShvetsGroup\LaravelEmailDatabaseLog\Tests\TestCase; | ||
use ShvetsGroup\LaravelEmailDatabaseLog\Tests\Mail\TestMail; | ||
|
||
class LaravelEmailDatabaseTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** @test */ | ||
public function the_email_is_logged_to_the_database() | ||
{ | ||
Mail::to('email@example.com') | ||
->send(new TestMail()); | ||
|
||
$this->assertDatabaseHas('email_log', [ | ||
'date' => now()->format('Y-m-d H:i:s'), | ||
'from' => 'Example <hello@example.com>', | ||
'to' => 'email@example.com', | ||
'cc' => null, | ||
'bcc' => null, | ||
'subject' => 'The e-mail subject', | ||
'body' => '<p>Some random string.</p>', | ||
'attachments' => null, | ||
]); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace ShvetsGroup\LaravelEmailDatabaseLog\Tests\Mail; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class TestMail extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
/** | ||
* Create a new message instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
return $this | ||
->subject('The e-mail subject') | ||
->html('<p>Some random string.</p>'); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace ShvetsGroup\LaravelEmailDatabaseLog\Tests; | ||
|
||
use ShvetsGroup\LaravelEmailDatabaseLog\LaravelEmailDatabaseLogServiceProvider; | ||
|
||
class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
public function getEnvironmentSetUp($app) | ||
{ | ||
// import the migrations | ||
include_once __DIR__ . '/../src/database/migrations/2015_07_31_1_email_log.php'; | ||
include_once __DIR__ . '/../src/database/migrations/2016_09_21_001638_add_bcc_column_email_log.php'; | ||
include_once __DIR__ . '/../src/database/migrations/2017_11_10_001638_add_more_mail_columns_email_log.php'; | ||
include_once __DIR__ . '/../src/database/migrations/2018_05_11_115355_use_longtext_for_attachments.php'; | ||
|
||
// run the up() method of those migration classes | ||
(new \EmailLog)->up(); | ||
(new \AddBccColumnEmailLog)->up(); | ||
(new \AddMoreMailColumnsEmailLog)->up(); | ||
(new \UseLongtextForAttachments)->up(); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
LaravelEmailDatabaseLogServiceProvider::class, | ||
]; | ||
} | ||
} |