Commit c67b625a authored by Johan Cwiklinski's avatar Johan Cwiklinski
Browse files

Merge branch '9.5/bugfixes'

parents e85f4146 a1f2e1a7
......@@ -134,11 +134,11 @@ jobs:
- {php-version: "7.2", db-image: "mariadb:10.5", always: false}
- {php-version: "7.3", db-image: "mariadb:10.5", always: false}
- {php-version: "7.4", db-image: "mariadb:10.5", always: false}
- {php-version: "7.4", db-image: "mariadb:10.1", always: false}
- {php-version: "7.4", db-image: "mysql:5.6", always: false}
- {php-version: "7.4", db-image: "mysql:8.0", always: false}
- {php-version: "7.4", db-image: "percona:5.6", always: false}
- {php-version: "7.4", db-image: "percona:8.0", always: false}
- {php-version: "8.0", db-image: "mariadb:10.1", always: false}
- {php-version: "8.0", db-image: "mysql:5.6", always: false}
- {php-version: "8.0", db-image: "mysql:8.0", always: false}
- {php-version: "8.0", db-image: "percona:5.6", always: false}
- {php-version: "8.0", db-image: "percona:8.0", always: false}
env:
# Skip jobs that should not be always run on pull requests or on push on tier repository (to limit workers usage).
# No jobs will be skipped on nightly build, manual dispatch or push on main branches (master and */bugfixes) or tags.
......
......@@ -2322,8 +2322,7 @@ class Entity extends CommonTreeDropdown {
$custom_css_code = self::getUsedConfig(
'enable_custom_css',
$this->fields['id'],
'custom_css_code',
''
'custom_css_code'
);
if (empty($custom_css_code)) {
......
......@@ -382,4 +382,133 @@ class Entity extends DbTestCase {
$this->string(\Entity::getUsedConfig($field, $child_2))->isEqualTo($value."_child_2");
}
protected function customCssProvider() {
$root_id = getItemByTypeName('Entity', 'Root entity', true);
$child_id = getItemByTypeName('Entity', '_test_child_1', true);
return [
[
// Do not output custom CSS if not enabled
'entity_id' => $root_id,
'root_enable_custom_css' => 0,
'root_custom_css_code' => 'body { color:blue; }',
'child_enable_custom_css' => 0,
'child_custom_css_code' => '',
'expected' => '',
],
[
// Output custom CSS if enabled
'entity_id' => $root_id,
'root_enable_custom_css' => 1,
'root_custom_css_code' => 'body { color:blue; }',
'child_enable_custom_css' => 0,
'child_custom_css_code' => '',
'expected' => '<style>body { color:blue; }</style>',
],
[
// Do not output custom CSS if empty
'entity_id' => $root_id,
'root_enable_custom_css' => 1,
'root_custom_css_code' => '',
'child_enable_custom_css' => 0,
'child_custom_css_code' => '',
'expected' => '',
],
[
// Do not output custom CSS from parent if disabled in parent
'entity_id' => $child_id,
'root_enable_custom_css' => 0,
'root_custom_css_code' => 'body { color:blue; }',
'child_enable_custom_css' => \Entity::CONFIG_PARENT,
'child_custom_css_code' => '',
'expected' => '',
],
[
// Do not output custom CSS from parent if empty
'entity_id' => $child_id,
'root_enable_custom_css' => 1,
'root_custom_css_code' => '',
'child_enable_custom_css' => \Entity::CONFIG_PARENT,
'child_custom_css_code' => '',
'expected' => '',
],
[
// Output custom CSS from parent
'entity_id' => $child_id,
'root_enable_custom_css' => 1,
'root_custom_css_code' => 'body { color:blue; }',
'child_enable_custom_css' => \Entity::CONFIG_PARENT,
'child_custom_css_code' => '',
'expected' => '<style>body { color:blue; }</style>',
],
[
// Do not output custom CSS from entity itself if disabled
'entity_id' => $child_id,
'root_enable_custom_css' => 0,
'root_custom_css_code' => '',
'child_enable_custom_css' => 0,
'child_custom_css_code' => 'body { color:blue; }',
'expected' => '',
],
[
// Do not output custom CSS from entity itself if empty
'entity_id' => $child_id,
'root_enable_custom_css' => 1,
'root_custom_css_code' => '',
'child_enable_custom_css' => 1,
'child_custom_css_code' => '',
'expected' => '',
],
[
// Output custom CSS from entity itself
'entity_id' => $child_id,
'root_enable_custom_css' => 0,
'root_custom_css_code' => '',
'child_enable_custom_css' => 1,
'child_custom_css_code' => 'body { color:blue; }',
'expected' => '<style>body { color:blue; }</style>',
],
];
}
/**
* @dataProvider customCssProvider
*/
public function testGetCustomCssTag(
int $entity_id,
int $root_enable_custom_css,
string $root_custom_css_code,
int $child_enable_custom_css,
string $child_custom_css_code,
string $expected
): void {
$this->login();
$entity = new \Entity();
// Define configuration values
$update = $entity->update(
[
'id' => getItemByTypeName('Entity', 'Root entity', true),
'enable_custom_css' => $root_enable_custom_css,
'custom_css_code' => $root_custom_css_code
]
);
$this->boolean($update)->isTrue();
$update = $entity->update(
[
'id' => getItemByTypeName('Entity', '_test_child_1', true),
'enable_custom_css' => $child_enable_custom_css,
'custom_css_code' => $child_custom_css_code
]
);
$this->boolean($update)->isTrue();
// Validate method result
$this->boolean($entity->getFromDB($entity_id))->isTrue();
$this->string($entity->getCustomCssTag())->isEqualTo($expected);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment