DescriptionTraitTest.php in Examples for Developers 8
File
tests/src/Kernel/DescriptionTraitTest.php
View source
<?php
namespace Drupal\Tests\examples\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\examples_description_test\Controller\SampleExampleController;
class DescriptionTraitTest extends KernelTestBase {
public static $modules = [
'examples',
'examples_description_test',
];
public function testTemplateFile() {
$sample_controller = SampleExampleController::create($this->container);
$ref_get_path = new \ReflectionMethod($sample_controller, 'getDescriptionTemplatePath');
$ref_get_path
->setAccessible(TRUE);
$this
->assertFileExists($ref_get_path
->invoke($sample_controller));
$render_array = $sample_controller
->description();
$output = (string) $this->container
->get('renderer')
->renderPlain($render_array);
$this
->assertContains('Template loaded!', $output);
$this
->assertContains('Used in module: examples_description_test.', $output);
$this
->assertContains('Our slogan for today: We aim to please.', $output);
}
}