Skip to content
Snippets Groups Projects
Verified Commit 0d176b28 authored by Dave Long's avatar Dave Long
Browse files

Issue #3415557 by Spokje, catch: Convert RowPluginTest into a Kernel test

(cherry picked from commit 929da61e)
parent 527ae8a2
Branches
Tags
14 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument
Pipeline #82078 passed with warnings
Pipeline: drupal

#82085

    Pipeline: drupal

    #82082

      <?php
      namespace Drupal\Tests\node\Functional\Views;
      namespace Drupal\Tests\node\Kernel\Views;
      use Drupal\node\Entity\NodeType;
      use Drupal\Tests\node\Traits\NodeCreationTrait;
      use Drupal\Tests\user\Traits\UserCreationTrait;
      use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
      use Drupal\views\Tests\ViewTestData;
      use Drupal\views\Views;
      /**
      ......@@ -10,45 +15,61 @@
      * @group node
      * @see \Drupal\node\Plugin\views\row\NodeRow
      */
      class RowPluginTest extends NodeTestBase {
      class RowPluginTest extends ViewsKernelTestBase {
      use NodeCreationTrait;
      use UserCreationTrait;
      /**
      * Modules to enable.
      * Views used by this test.
      *
      * @var array
      * @var string[]
      */
      protected static $modules = ['node'];
      public static $testViews = ['test_node_row_plugin'];
      /**
      * {@inheritdoc}
      */
      protected $defaultTheme = 'stark';
      /**
      * Views used by this test.
      *
      * @var array
      */
      public static $testViews = ['test_node_row_plugin'];
      protected static $modules = [
      'field',
      'filter',
      'node',
      'node_test_views',
      'text',
      'user',
      ];
      /**
      * Contains all nodes used by this test.
      *
      * @var array
      * @var \Drupal\node\Entity\Node[]
      */
      protected $nodes;
      protected array $nodes;
      /**
      * {@inheritdoc}
      */
      protected function setUp($import_test_views = TRUE, $modules = ['node_test_views']): void {
      parent::setUp($import_test_views, $modules);
      protected function setUp($import_test_views = TRUE): void {
      parent::setUp($import_test_views);
      $this->installEntitySchema('user');
      $this->installEntitySchema('node');
      $this->installSchema('node', ['node_access']);
      $this->installConfig(['field', 'filter', 'node']);
      ViewTestData::createTestViews(static::class, ['node_test_views']);
      \Drupal::currentUser()->setAccount($this->createUser(['access content']));
      $this->drupalCreateContentType(['type' => 'article']);
      $node_type = NodeType::create([
      'type' => 'article',
      'name' => 'Article',
      ]);
      $node_type->save();
      node_add_body_field($node_type);
      // Create two nodes.
      for ($i = 0; $i < 2; $i++) {
      $this->nodes[] = $this->drupalCreateNode(
      $this->nodes[] = $this->createNode(
      [
      'type' => 'article',
      'body' => [
      ......@@ -66,7 +87,7 @@ protected function setUp($import_test_views = TRUE, $modules = ['node_test_views
      /**
      * Tests the node row plugin.
      */
      public function testRowPlugin() {
      public function testRowPlugin(): void {
      /** @var \Drupal\Core\Render\RendererInterface $renderer */
      $renderer = $this->container->get('renderer');
      $view = Views::getView('test_node_row_plugin');
      ......@@ -89,7 +110,7 @@ public function testRowPlugin() {
      $output = $renderer->renderRoot($output);
      foreach ($this->nodes as $node) {
      $this->assertStringContainsString($node->body->summary, $output, 'Make sure the teaser appears in the output of the view.');
      $this->assertStringNotContainsString($node->body->value, $output, 'Make sure the full text does not appears in the output of the view if teaser is set as viewmode.');
      $this->assertStringNotContainsString($node->body->value, $output);
      }
      }
      ......
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment