comparison vendor/chi-teck/drupal-code-generator/templates/d8/test/kernel.twig @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\{{ machine_name }}\Kernel; 3 namespace Drupal\Tests\{{ machine_name }}\Kernel;
4 4
5 use Drupal\block\Entity\Block;
6 use Drupal\KernelTests\KernelTestBase; 5 use Drupal\KernelTests\KernelTestBase;
7 6
8 /** 7 /**
9 * Test description. 8 * Test description.
10 * 9 *
13 class {{ class }} extends KernelTestBase { 12 class {{ class }} extends KernelTestBase {
14 13
15 /** 14 /**
16 * {@inheritdoc} 15 * {@inheritdoc}
17 */ 16 */
18 public static $modules = ['block', 'system', 'user']; 17 public static $modules = ['{{ machine_name }}'];
19 18
20 /** 19 /**
21 * {@inheritdoc} 20 * {@inheritdoc}
22 */ 21 */
23 protected function setUp() { 22 protected function setUp() {
24 parent::setUp(); 23 parent::setUp();
25 $this->container 24 // Mock required services here.
26 ->get('entity_type.manager')
27 ->getStorage('block')
28 ->create([
29 'id' => 'test_block',
30 'theme' => 'stark',
31 'plugin' => 'system_powered_by_block',
32 ])
33 ->save();
34 } 25 }
35 26
36 /** 27 /**
37 * Test callback. 28 * Test callback.
38 */ 29 */
39 public function testBlockRendering() { 30 public function testSomething() {
40 $entity = Block::load('test_block'); 31 $result = $this->container->get('transliteration')->transliterate('Друпал');
41 32 $this->assertEquals('Drupal', $result);
42 $build = \Drupal::entityTypeManager()
43 ->getViewBuilder($entity->getEntityTypeId())
44 ->view($entity);
45
46 $content = $this
47 ->container
48 ->get('renderer')
49 ->renderRoot($build);
50
51 $this->assertTrue(
52 strpos(strip_tags($content), 'Powered by Drupal') !== FALSE,
53 'Valid block content was found.'
54 );
55 } 33 }
56 34
57 } 35 }