Commit 3ddb6b94 authored by catch's avatar catch

Issue #3046676 by claudiu.cristea: Convert block_content...

Issue #3046676 by claudiu.cristea: Convert block_content RevisionRelationshipsTest into a Kernel test
parent 61d89c67
<?php <?php
namespace Drupal\Tests\block_content\Functional\Views; namespace Drupal\Tests\block_content\Kernel\Views;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContent;
use Drupal\Tests\views\Functional\ViewTestBase; use Drupal\block_content\Entity\BlockContentType;
use Drupal\views\Views; use Drupal\KernelTests\KernelTestBase;
use Drupal\views\Tests\ViewResultAssertionTrait;
use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/** /**
* Tests the integration of block_content_revision table of block_content module. * Tests the integration of block_content_revision table.
* *
* @group block_content * @group block_content
*/ */
class RevisionRelationshipsTest extends ViewTestBase { class RevisionRelationshipsTest extends KernelTestBase {
use ViewResultAssertionTrait;
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
public static $modules = ['block_content' , 'block_content_test_views']; protected static $modules = [
'block_content',
'block_content_test_views',
'system',
'user',
'views',
];
/** /**
* Views used by this test. * Views used by this test.
* *
* @var array * @var array
*/ */
public static $testViews = ['test_block_content_revision_id', 'test_block_content_revision_revision_id']; public static $testViews = [
'test_block_content_revision_id',
'test_block_content_revision_revision_id',
];
/**
* Create a block_content with revision and rest result count for both views.
*/
public function testBlockContentRevisionRelationship() {
$this->installEntitySchema('block_content');
ViewTestData::createTestViews(static::class, ['block_content_test_views']);
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
BlockContentType::create([ BlockContentType::create([
'id' => 'basic', 'id' => 'basic',
'label' => 'basic', 'label' => 'basic',
'revision' => TRUE, 'revision' => TRUE,
]); ]);
ViewTestData::createTestViews(get_class($this), ['block_content_test_views']);
}
/**
* Create a block_content with revision and rest result count for both views.
*/
public function testBlockContentRevisionRelationship() {
$block_content = BlockContent::create([ $block_content = BlockContent::create([
'info' => $this->randomMachineName(), 'info' => $this->randomMachineName(),
'type' => 'basic', 'type' => 'basic',
...@@ -60,8 +68,8 @@ public function testBlockContentRevisionRelationship() { ...@@ -60,8 +68,8 @@ public function testBlockContentRevisionRelationship() {
]; ];
// Here should be two rows. // Here should be two rows.
$view_id = Views::getView('test_block_content_revision_id'); $view = Views::getView('test_block_content_revision_id');
$this->executeView($view_id, [$block_content->id()]); $view->preview(NULL, [$block_content->id()]);
$resultset_id = [ $resultset_id = [
[ [
'revision_id' => '1', 'revision_id' => '1',
...@@ -74,11 +82,11 @@ public function testBlockContentRevisionRelationship() { ...@@ -74,11 +82,11 @@ public function testBlockContentRevisionRelationship() {
'block_content_field_data_block_content_field_revision_id' => '1', 'block_content_field_data_block_content_field_revision_id' => '1',
], ],
]; ];
$this->assertIdenticalResultset($view_id, $resultset_id, $column_map); $this->assertIdenticalResultset($view, $resultset_id, $column_map);
// There should be only one row with active revision 2. // There should be only one row with active revision 2.
$view_revision_id = Views::getView('test_block_content_revision_revision_id'); $view_revision = Views::getView('test_block_content_revision_revision_id');
$this->executeView($view_revision_id, [$block_content->id()]); $view_revision->preview(NULL, [$block_content->id()]);
$resultset_revision_id = [ $resultset_revision_id = [
[ [
'revision_id' => '2', 'revision_id' => '2',
...@@ -86,7 +94,7 @@ public function testBlockContentRevisionRelationship() { ...@@ -86,7 +94,7 @@ public function testBlockContentRevisionRelationship() {
'block_content_field_data_block_content_field_revision_id' => '1', 'block_content_field_data_block_content_field_revision_id' => '1',
], ],
]; ];
$this->assertIdenticalResultset($view_revision_id, $resultset_revision_id, $column_map); $this->assertIdenticalResultset($view_revision, $resultset_revision_id, $column_map);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment