Skip to content

Commit

Permalink
test: Fix SMPT Account Test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Apr 8, 2024
1 parent c30af84 commit 1659bcc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
29 changes: 15 additions & 14 deletions tests/webfiori/tests/mail/SMTPAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace webfiori\tests\mail;

use PHPUnit\Framework\TestCase;
use webfiori\email\AccountOption;
use webfiori\email\SMTPAccount;
/**
* A test class for testing the class 'webfiori\framework\mail\SMTPAccount'.
Expand All @@ -26,13 +27,13 @@ public function test00() {
*/
public function test01() {
$acc = new SMTPAccount([
'user' => '[email protected]',
'pass' => '123456',
'port' => 25,
'server-address' => 'mail.examplex.com',
'sender-name' => 'Example Sender',
'sender-address' => '[email protected]',
'account-name' => 'no-reply'
AccountOption::USERNAME => '[email protected]',
AccountOption::PASSWORD => '123456',
AccountOption::PORT => 25,
AccountOption::SERVER_ADDRESS => 'mail.examplex.com',
AccountOption::SENDER_NAME => 'Example Sender',
AccountOption::SENDER_ADDRESS => '[email protected]',
AccountOption::NAME => 'no-reply'
]);
$this->assertSame(25,$acc->getPort());
$this->assertEquals('[email protected]',$acc->getAddress());
Expand All @@ -47,13 +48,13 @@ public function test01() {
*/
public function test02() {
$acc = new SMTPAccount([
'username' => '[email protected]',
'password' => '123456',
'port' => 25,
'server-address' => 'mail.examplex.com',
'sender-name' => 'Example Sender',
'sender-address' => '[email protected]',
'account-name' => 'no-reply'
AccountOption::USERNAME => '[email protected]',
AccountOption::PASSWORD => '123456',
AccountOption::PORT => 25,
AccountOption::SERVER_ADDRESS => 'mail.examplex.com',
AccountOption::SENDER_NAME => 'Example Sender',
AccountOption::SENDER_ADDRESS => '[email protected]',
AccountOption::NAME => 'no-reply'
]);
$this->assertSame(25,$acc->getPort());
$this->assertEquals('[email protected]',$acc->getAddress());
Expand Down
6 changes: 3 additions & 3 deletions webfiori/email/SMTPAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ public function __construct(array $options = []) {
}

if (isset($options[AccountOption::SENDER_NAME])) {
$this->setSenderName($options[AccountOption::SERVER_ADDRESS]);
$this->setSenderName($options[AccountOption::SENDER_NAME]);
} else {
$this->setSenderName('');
}

if (isset($options[AccountOption::SERVER_ADDRESS])) {
$this->setAddress($options[AccountOption::SERVER_ADDRESS]);
if (isset($options[AccountOption::SENDER_ADDRESS])) {
$this->setAddress($options[AccountOption::SENDER_ADDRESS]);
} else {
$this->setAddress('');
}
Expand Down

0 comments on commit 1659bcc

Please sign in to comment.