whitelabel-8.x-2.x-dev/tests/src/Functional/WhiteLabelThemeNegotiatorTest.php
tests/src/Functional/WhiteLabelThemeNegotiatorTest.php
<?php
namespace Drupal\Tests\whitelabel\Functional;
/**
* Tests theme negotiation with White label.
*
* @group whitelabel
*/
class WhiteLabelThemeNegotiatorTest extends WhiteLabelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->container->get('theme_installer')->install(['claro']);
$this->config('whitelabel.settings')
->set('site_name', FALSE)
->set('site_name_display', FALSE)
->set('site_slogan', FALSE)
->set('site_logo', FALSE)
->set('site_colors', FALSE)
->set('site_theme', FALSE)
->set('site_admin_theme', NULL)
->save();
}
/**
* Test to see if the admin configured WL theme is applied.
*/
public function testAdminWhiteLabelTheme() {
$this->config('whitelabel.settings')
->set('site_admin_theme', 'claro')
->save();
$this->whiteLabel
->setTheme(NULL)
->save();
$body = $this->drupalGet('<front>');
$this->assertStringNotContainsString('claro', $body);
// Apply white label.
$this->setCurrentWhiteLabel($this->whiteLabel);
$body = $this->drupalGet('<front>');
$this->assertStringContainsString('claro', $body);
// Remove white label.
$this->unsetWhiteLabel();
$body = $this->drupalGet('<front>');
$this->assertStringNotContainsString('claro', $body);
}
/**
* Test to see if the WL specific theme is applied.
*/
public function testWhiteLabelDefinedTheme() {
$this->config('whitelabel.settings')
->set('site_theme', TRUE)
->save();
$this->whiteLabel
->setTheme('claro')
->save();
$body = $this->drupalGet('<front>');
$this->assertStringNotContainsString('claro', $body);
// Apply white label.
$this->setCurrentWhiteLabel($this->whiteLabel);
$body = $this->drupalGet('<front>');
$this->assertStringContainsString('claro', $body);
// Unset white label.
$this->unsetWhiteLabel();
$body = $this->drupalGet('<front>');
$this->assertStringNotContainsString('claro', $body);
}
/**
* Test to see if no white label is applied if site_theme is FALSE.
*/
public function testWhiteLabelDefinedThemeNotEnabled() {
$this->config('whitelabel.settings')
->set('site_theme', FALSE)
->save();
$this->whiteLabel
->setTheme('claro')
->save();
// Apply white label.
$this->setCurrentWhiteLabel($this->whiteLabel);
$body = $this->drupalGet('<front>');
// Make sure it does NOT contain any references to claro.
$this->assertStringNotContainsString('claro', $body);
}
}
