Skip to content

Commit

Permalink
Unit test for sending email has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleon4 committed May 9, 2022
1 parent 5b46ffe commit c1def03
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 52 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MAIL_EMAIL="lion_framework@lion.com"
MAIL_PASSWORD=""
MAIL_USER_NAME=${APP_NAME}
MAIL_ENCRYPTION=false
MAIL_SEND_MAIL="lion_framework@lion.com"

RSA_PATH=""
RSA_URL_PATH=""
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@
},
"require": {
"php": ">=8.1",
"lion-framework/lion-mailer": "^1.5",
"lion-framework/lion-mailer": "^3.0",
"lion-framework/lion-security": "^6.2",
"lion-framework/lion-sql": "^4.0",
"lion-framework/lion-files": "^4.1",
"lion-framework/lion-command": "^1.4",
"lion-framework/lion-route": "^2.2",
"nesbot/carbon": "^2.57"
"nesbot/carbon": "^2.58"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php -r \"file_exists('test/.env') || copy('.env.example', 'test/.env');\""
]
},
"config": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions tests/Email/SendMailTest.php

This file was deleted.

47 changes: 47 additions & 0 deletions tests/SendMailTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Tests\Email;

use PHPUnit\Framework\TestCase;
use Dotenv\Dotenv;
use LionMailer\Mailer;
use LionMailer\DataMailer\Attach;
use App\Http\Request\Request;

class SendMailTest extends TestCase {

public function setUp(): void {
(Dotenv::createImmutable(__DIR__))->load();

Mailer::init([
'info' => [
'debug' => (int) $_ENV['MAIL_DEBUG'],
'host' => $_ENV['MAIL_HOST'],
'port' => (int) $_ENV['MAIL_PORT'],
'email' => $_ENV['MAIL_EMAIL'],
'password' => $_ENV['MAIL_PASSWORD'],
'user_name' => $_ENV['MAIL_USER_NAME'],
'encryption' => $_ENV['MAIL_ENCRYPTION'] === 'false' ? false : ($_ENV['MAIL_ENCRYPTION'] === 'true' ? true : false)
]
]);
}

public function testSendMailTest() {
$request = Mailer::send(
Attach::newAttach(
[$_ENV['MAIL_SEND_MAIL'], $_ENV['MAIL_USER_NAME']],
[$_ENV['MAIL_EMAIL'], $_ENV['MAIL_USER_NAME']],
null,
null
),
Mailer::newInfo(
'example',
'example',
'example'
)
);

$this->assertEquals('success', $request->status);
}

}

0 comments on commit c1def03

Please sign in to comment.