I want to avoid the SettingsController becoming some kind of a god class so in this step, I extracted themejson-related stuff to an extra class. In the future, we should also move methods for manipulating CSS to a helper. [MAILPOET-5741]
36 lines
1.5 KiB
PHP
36 lines
1.5 KiB
PHP
<?php declare(strict_types = 1);
|
|
|
|
namespace unit\EmailEditor\Engine\Renderer;
|
|
|
|
use MailPoet\EmailEditor\Engine\SettingsController;
|
|
use MailPoet\EmailEditor\Engine\ThemeController;
|
|
|
|
class SettingsControllerTest extends \MailPoetUnitTest {
|
|
public function testItGetsMainLayoutStyles(): void {
|
|
$settingsController = new SettingsController($this->makeEmpty(ThemeController::class));
|
|
$layoutStyles = $settingsController->getEmailLayoutStyles();
|
|
verify($layoutStyles)->arrayHasKey('width');
|
|
verify($layoutStyles)->arrayHasKey('background');
|
|
verify($layoutStyles)->arrayHasKey('padding');
|
|
}
|
|
|
|
public function testItGetsCorrectLayoutWidthWithoutPadding(): void {
|
|
$settingsController = new SettingsController($this->makeEmpty(ThemeController::class));
|
|
$layoutWidth = $settingsController->getLayoutWidthWithoutPadding();
|
|
// default width is 660px and if we subtract padding from left and right we must get the correct value
|
|
$expectedWidth = (int)SettingsController::EMAIL_WIDTH - (int)SettingsController::FLEX_GAP * 2;
|
|
verify($layoutWidth)->equals($expectedWidth . 'px');
|
|
}
|
|
|
|
public function testItConvertsStylesToString(): void {
|
|
$settingsController = new SettingsController($this->makeEmpty(ThemeController::class));
|
|
$styles = [
|
|
'width' => '600px',
|
|
'background' => '#ffffff',
|
|
'padding-left' => '15px',
|
|
];
|
|
$string = $settingsController->convertStylesToString($styles);
|
|
verify($string)->equals('width:600px;background:#ffffff;padding-left:15px;');
|
|
}
|
|
}
|