DomainVariableSchemeTest.php in Domain Access 8
File
domain/tests/src/Kernel/DomainVariableSchemeTest.php
View source
<?php
namespace Drupal\Tests\domain\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\domain\Traits\DomainTestTrait;
class DomainVariableSchemeTest extends KernelTestBase {
use DomainTestTrait;
public static $modules = [
'domain',
];
public $key = 'example_com';
public $domainStorage;
public $baseHostname;
protected function setUp() {
parent::setUp();
$this
->domainCreateTestDomains();
$this->domainStorage = \Drupal::entityTypeManager()
->getStorage('domain');
}
public function testDomainScheme() {
$default_scheme = \Drupal::request()
->getScheme();
$alt_scheme = $default_scheme == 'https' ? 'http' : 'https';
$add_suffix = FALSE;
$domain = $this->domainStorage
->load($this->key);
$this
->assertTrue($domain
->getScheme($add_suffix) == $default_scheme);
$domain
->set('scheme', $alt_scheme);
$domain
->save();
$domain = $this->domainStorage
->load($this->key);
$this
->assertTrue($domain
->getScheme($add_suffix) == $alt_scheme);
$domain
->set('scheme', 'variable');
$domain
->save();
$this
->assertTrue($domain
->getScheme($add_suffix) == $default_scheme);
}
}