Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/Mail/HelperTest.php
<?php | <?php | ||||
namespace Tests\Unit\Mail; | namespace Tests\Unit\Mail; | ||||
use App\Mail\Helper; | use App\Mail\Helper; | ||||
use App\User; | |||||
use Illuminate\Support\Facades\Mail; | use Illuminate\Support\Facades\Mail; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class HelperTest extends TestCase | class HelperTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | public function testSendMail(): void | ||||
// TODO: Test somehow exception case | // TODO: Test somehow exception case | ||||
} | } | ||||
/** | /** | ||||
* Test Helper::userEmails() | * Test Helper::userEmails() | ||||
*/ | */ | ||||
public function testUserEmails(): void | public function testUserEmails(): void | ||||
{ | { | ||||
$user = $this->getTestUser('mail-helper-test@kolabnow.com'); | $status = User::STATUS_ACTIVE | User::STATUS_LDAP_READY | User::STATUS_IMAP_READY; | ||||
$user = $this->getTestUser('mail-helper-test@kolabnow.com', ['status' => $status]); | |||||
// User with no mailbox and no external email | // User with no mailbox and no external email | ||||
list($to, $cc) = Helper::userEmails($user); | list($to, $cc) = Helper::userEmails($user); | ||||
$this->assertSame(null, $to); | $this->assertSame(null, $to); | ||||
$this->assertSame([], $cc); | $this->assertSame([], $cc); | ||||
list($to, $cc) = Helper::userEmails($user, true); | list($to, $cc) = Helper::userEmails($user, true); | ||||
Show All 33 Lines | public function testUserEmails(): void | ||||
$this->assertSame($user->email, $to); | $this->assertSame($user->email, $to); | ||||
$this->assertSame([], $cc); | $this->assertSame([], $cc); | ||||
list($to, $cc) = Helper::userEmails($user, true); | list($to, $cc) = Helper::userEmails($user, true); | ||||
$this->assertSame($user->email, $to); | $this->assertSame($user->email, $to); | ||||
$this->assertSame([], $cc); | $this->assertSame([], $cc); | ||||
// Use with mailbox, but not ready | |||||
$user->setSetting('external_email', 'external@test.com'); | |||||
$user->status = User::STATUS_ACTIVE | User::STATUS_LDAP_READY; | |||||
$user->save(); | |||||
list($to, $cc) = Helper::userEmails($user, true); | |||||
$this->assertSame(null, $to); | |||||
$this->assertSame(['external@test.com'], $cc); | |||||
} | } | ||||
} | } |