Consolidate settings normalization tests
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Service\Settings;
|
||||
|
||||
use MintyPHP\Repository\Settings\SettingRepositoryInterface;
|
||||
use MintyPHP\Service\Settings\SettingsMetadataGateway;
|
||||
use MintyPHP\Service\Settings\SettingsSmtpGateway;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SettingsSmtpGatewayTest extends TestCase
|
||||
{
|
||||
public function testGetSmtpSecureReturnsNullForNone(): void
|
||||
{
|
||||
$settings = $this->createMock(SettingRepositoryInterface::class);
|
||||
$settings->method('getValue')->willReturnCallback(static function (string $key): ?string {
|
||||
if ($key === 'smtp_secure') {
|
||||
return 'none';
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
$gateway = new SettingsSmtpGateway(new SettingsMetadataGateway($settings));
|
||||
$this->assertNull($gateway->getSmtpSecure());
|
||||
}
|
||||
|
||||
public function testSetSmtpSecureRejectsInvalidValue(): void
|
||||
{
|
||||
$settings = $this->createMock(SettingRepositoryInterface::class);
|
||||
$settings->expects($this->never())->method('set');
|
||||
|
||||
$gateway = new SettingsSmtpGateway(new SettingsMetadataGateway($settings));
|
||||
$this->assertFalse($gateway->setSmtpSecure('starttls'));
|
||||
}
|
||||
|
||||
public function testSetSmtpHostPersistsNullForEmptyString(): void
|
||||
{
|
||||
$settings = $this->createMock(SettingRepositoryInterface::class);
|
||||
$settings->expects($this->once())
|
||||
->method('set')
|
||||
->with('smtp_host', null, 'setting.smtp_host')
|
||||
->willReturn(true);
|
||||
|
||||
$gateway = new SettingsSmtpGateway(new SettingsMetadataGateway($settings));
|
||||
$this->assertTrue($gateway->setSmtpHost(' '));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user