59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Settings tests.
|
|
*
|
|
* @package LogoSoup\Tests
|
|
*/
|
|
|
|
use LogoSoup\Settings;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Tests settings sanitization.
|
|
*/
|
|
class SettingsTest extends TestCase {
|
|
/**
|
|
* Test invalid layout falls back to default.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function test_sanitize_rejects_unknown_layout() {
|
|
$sanitized = Settings::sanitize(
|
|
array(
|
|
'default_layout' => 'not-real',
|
|
'default_speed' => 300,
|
|
'default_gray' => 1,
|
|
)
|
|
);
|
|
|
|
$this->assertSame( 'carousel', $sanitized['default_layout'] );
|
|
$this->assertSame( 80, $sanitized['default_speed'] );
|
|
$this->assertTrue( $sanitized['default_gray'] );
|
|
}
|
|
|
|
/**
|
|
* Test advanced normalization options are sanitized.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function test_sanitize_normalization_options() {
|
|
$sanitized = Settings::sanitize(
|
|
array(
|
|
'base_size' => 400,
|
|
'scale_factor' => '1.37',
|
|
'density_aware' => 1,
|
|
'density_factor' => '4.2',
|
|
'crop_to_content' => 1,
|
|
'align_by' => 'visual-center-y',
|
|
)
|
|
);
|
|
|
|
$this->assertSame( 160, $sanitized['base_size'] );
|
|
$this->assertSame( 1.37, $sanitized['scale_factor'] );
|
|
$this->assertTrue( $sanitized['density_aware'] );
|
|
$this->assertSame( 1.0, $sanitized['density_factor'] );
|
|
$this->assertTrue( $sanitized['crop_to_content'] );
|
|
$this->assertSame( 'visual-center-y', $sanitized['align_by'] );
|
|
}
|
|
}
|