From c1def0348804bd070cfaa431c6b2d4e16bb65a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Le=C3=B3n?= <56183278+Sleon4@users.noreply.github.com> Date: Mon, 9 May 2022 11:09:37 -0500 Subject: [PATCH] Unit test for sending email has been updated --- .env.example | 1 + composer.json | 7 +++--- composer.lock | 14 +++++------ tests/Email/SendMailTest.php | 42 -------------------------------- tests/SendMailTest.php | 47 ++++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 52 deletions(-) delete mode 100644 tests/Email/SendMailTest.php create mode 100644 tests/SendMailTest.php diff --git a/.env.example b/.env.example index eab396a0..2e6b8086 100644 --- a/.env.example +++ b/.env.example @@ -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="" diff --git a/composer.json b/composer.json index bd4c80b4..194b07ef 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/composer.lock b/composer.lock index fa75fe69..ad124d19 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "222225cb327ad869f31d49f3ab3d0cda", + "content-hash": "6e4689503963a90e1c878068b296d6f0", "packages": [ { "name": "firebase/php-jwt", @@ -208,16 +208,16 @@ }, { "name": "lion-framework/lion-mailer", - "version": "v1.6", + "version": "v3.0", "source": { "type": "git", "url": "https://github.com/Sleon4/Lion-Mailer.git", - "reference": "3e9573a2008a89df962fceca20bee4ed24cc8950" + "reference": "fa1eada86273908dc5663a14ab6d81c2ef168c5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Sleon4/Lion-Mailer/zipball/3e9573a2008a89df962fceca20bee4ed24cc8950", - "reference": "3e9573a2008a89df962fceca20bee4ed24cc8950", + "url": "https://api.github.com/repos/Sleon4/Lion-Mailer/zipball/fa1eada86273908dc5663a14ab6d81c2ef168c5f", + "reference": "fa1eada86273908dc5663a14ab6d81c2ef168c5f", "shasum": "" }, "require": { @@ -243,9 +243,9 @@ "description": "Library created for easy email sending based on PHPMailer.", "support": { "issues": "https://github.com/Sleon4/Lion-Mailer/issues", - "source": "https://github.com/Sleon4/Lion-Mailer/tree/v1.6" + "source": "https://github.com/Sleon4/Lion-Mailer/tree/v3.0" }, - "time": "2022-05-03T16:11:10+00:00" + "time": "2022-05-09T15:11:58+00:00" }, { "name": "lion-framework/lion-route", diff --git a/tests/Email/SendMailTest.php b/tests/Email/SendMailTest.php deleted file mode 100644 index e17243e0..00000000 --- a/tests/Email/SendMailTest.php +++ /dev/null @@ -1,42 +0,0 @@ - [ - 'debug' => 0, - 'host' => 'smtp.office365.com', - 'port' => 587, - 'email' => 'example-dev@outlook.com', - 'password' => 'attach-user', - 'user_name' => 'LION FRAMEWORK', - 'encryption' => false - ] - ]); - } - - public function testSendMailTest() { - $request = Mailer::send( - new Attach( - ['sergioleon4004@hotmail.com', 'Sergio León'], - ['example-dev@outlook.com', 'LION FRAMEWORK'], - null, - null, - null, - 'Example testCase', - 'Example testCase', - 'Example testCase' - ) - ); - - $this->assertEquals('success', $request->status); - } - -} \ No newline at end of file diff --git a/tests/SendMailTest.php b/tests/SendMailTest.php new file mode 100644 index 00000000..966c1025 --- /dev/null +++ b/tests/SendMailTest.php @@ -0,0 +1,47 @@ +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); + } + +} \ No newline at end of file