Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / test / kernel.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/test/kernel.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/test/kernel.twig
new file mode 100644 (file)
index 0000000..dc8c776
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+namespace Drupal\Tests\{{ machine_name }}\Kernel;
+
+use Drupal\block\Entity\Block;
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * Test description.
+ *
+ * @group {{ machine_name }}
+ */
+class {{ class }} extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['block', 'system', 'user'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->container
+      ->get('entity_type.manager')
+      ->getStorage('block')
+      ->create([
+        'id' => 'test_block',
+        'theme' => 'stark',
+        'plugin' => 'system_powered_by_block',
+      ])
+      ->save();
+  }
+
+  /**
+   * Test callback.
+   */
+  public function testBlockRendering() {
+    $entity = Block::load('test_block');
+
+    $build = \Drupal::entityTypeManager()
+      ->getViewBuilder($entity->getEntityTypeId())
+      ->view($entity);
+
+    $content = $this
+      ->container
+      ->get('renderer')
+      ->renderRoot($build);
+
+    $this->assertTrue(
+      strpos(strip_tags($content), 'Powered by Drupal') !== FALSE,
+      'Valid block content was found.'
+    );
+  }
+
+}