Add test for mailman type

This commit is contained in:
philipp lang 2023-06-07 21:32:56 +02:00 committed by Philipp Lang
parent 0dcb3b7d5b
commit c653a4b0c1
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace Tests\Feature\Mailgateway;
use App\Mailgateway\Types\MailmanType;
use App\Mailman\Support\MailmanService;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Phake;
use Tests\TestCase;
class MailmanTypeTest extends TestCase
{
use DatabaseTransactions;
public function testItChecksForWorks(): void
{
$this->withoutExceptionHandling();
$this->stubIo(MailmanService::class, function ($mock) {
Phake::when($mock)->setCredentials('https://example.com', 'user', 'secret')->thenReturn($mock);
Phake::when($mock)->check()->thenReturn(true);
});
$type = new MailmanType([
'url' => 'https://example.com',
'user' => 'user',
'password' => 'secret',
]);
$this->assertTrue($type->works());
}
public function testItCanReturnFalse(): void
{
$this->withoutExceptionHandling();
$this->stubIo(MailmanService::class, function ($mock) {
Phake::when($mock)->setCredentials('https://example.com', 'user', 'secret')->thenReturn($mock);
Phake::when($mock)->check()->thenReturn(false);
});
$type = new MailmanType([
'url' => 'https://example.com',
'user' => 'user',
'password' => 'secret',
]);
$this->assertFalse($type->works());
}
}