DrupalKernelSiteTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/DrupalKernel/DrupalKernelSiteTest.php
View source
<?php
namespace Drupal\system\Tests\DrupalKernel;
use Drupal\Core\Site\Settings;
use Drupal\simpletest\KernelTestBase;
class DrupalKernelSiteTest extends KernelTestBase {
public function testServicesYml() {
$container_yamls = Settings::get('container_yamls');
$container_yamls[] = $this->siteDirectory . '/services.yml';
$this
->settingsSet('container_yamls', $container_yamls);
$this
->assertFalse($this->container
->has('site.service.yml'));
$this
->assertIdentical(get_class($this->container
->get('cache.backend.database')), 'Drupal\\Core\\Cache\\DatabaseBackendFactory');
$class = __CLASS__;
$doc = <<<EOD
services:
# Add a new service.
site.service.yml:
class: {<span class="php-variable">$class</span>}
# Swap out a core service.
cache.backend.database:
class: Drupal\\Core\\Cache\\MemoryBackendFactory
EOD;
file_put_contents($this->siteDirectory . '/services.yml', $doc);
$this->container
->get('kernel')
->rebuildContainer();
$this
->assertTrue($this->container
->has('site.service.yml'));
$this
->assertIdentical(get_class($this->container
->get('cache.backend.database')), 'Drupal\\Core\\Cache\\MemoryBackendFactory');
}
}