CurrentThemeConditionTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
View source
<?php
namespace Drupal\system\Tests\Condition;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\simpletest\KernelTestBase;
class CurrentThemeConditionTest extends KernelTestBase {
public static $modules = array(
'system',
'theme_test',
);
protected function setUp() {
parent::setUp();
$this
->installSchema('system', array(
'router',
));
}
public function testCurrentTheme() {
\Drupal::service('theme_handler')
->install(array(
'test_theme',
));
$manager = \Drupal::service('plugin.manager.condition');
$condition = $manager
->createInstance('current_theme');
$condition
->setConfiguration(array(
'theme' => 'test_theme',
));
$condition_negated = $manager
->createInstance('current_theme');
$condition_negated
->setConfiguration(array(
'theme' => 'test_theme',
'negate' => TRUE,
));
$this
->assertEqual($condition
->summary(), SafeMarkup::format('The current theme is @theme', array(
'@theme' => 'test_theme',
)));
$this
->assertEqual($condition_negated
->summary(), SafeMarkup::format('The current theme is not @theme', array(
'@theme' => 'test_theme',
)));
$this
->assertFalse($condition
->execute());
$this
->assertTrue($condition_negated
->execute());
$this
->config('system.theme')
->set('default', 'test_theme')
->save();
\Drupal::theme()
->resetActiveTheme();
$this
->assertTrue($condition
->execute());
$this
->assertFalse($condition_negated
->execute());
}
}