From 2359ec14f75df072b0561c5839c90a8ef16fd153 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 13 Feb 2020 17:20:32 +0800 Subject: [PATCH] MDL-67364 output: Add unit testing for editor_scss_to_css --- lib/tests/theme_config_test.php | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/tests/theme_config_test.php b/lib/tests/theme_config_test.php index 85945c41cd0..35f3df73c63 100644 --- a/lib/tests/theme_config_test.php +++ b/lib/tests/theme_config_test.php @@ -175,4 +175,42 @@ class core_theme_config_testcase extends advanced_testcase { $this->assertRegExp("/{$themerevision}_{$themesubrevision}/", $url->out(false)); } + + /** + * Confirm that editor_scss_to_css is correctly compiling for themes with no parent. + */ + public function test_editor_scss_to_css_root_theme() { + global $CFG; + + $this->resetAfterTest(); + $theme = theme_config::load('boost'); + $editorscss = $CFG->dirroot.'/theme/boost/scss/editor.scss'; + + $this->assertTrue(file_exists($editorscss)); + $compiler = new core_scss(); + $compiler->set_file($editorscss); + $cssexpected = $compiler->to_css(); + $cssactual = $theme->editor_scss_to_css(); + + $this->assertEquals($cssexpected, $cssactual); + } + + /** + * Confirm that editor_scss_to_css is compiling for a child theme not overriding its parent's editor SCSS. + */ + public function test_editor_scss_to_css_child_theme() { + global $CFG; + + $this->resetAfterTest(); + $theme = theme_config::load('classic'); + $editorscss = $CFG->dirroot.'/theme/boost/scss/editor.scss'; + + $this->assertTrue(file_exists($editorscss)); + $compiler = new core_scss(); + $compiler->set_file($editorscss); + $cssexpected = $compiler->to_css(); + $cssactual = $theme->editor_scss_to_css(); + + $this->assertEquals($cssexpected, $cssactual); + } }