EntityRevisionConverterTest.php in Drupal 8
File
core/modules/content_moderation/tests/src/Kernel/EntityRevisionConverterTest.php
View source
<?php
namespace Drupal\Tests\content_moderation\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\user\Traits\UserCreationTrait;
class EntityRevisionConverterTest extends KernelTestBase {
use UserCreationTrait;
public static $modules = [
'user',
'system',
'content_moderation',
'node',
'workflows',
];
protected function setUp() {
parent::setUp();
$this
->setUpCurrentUser();
$this
->installEntitySchema('node');
$this
->installSchema('node', 'node_access');
}
public function testDeprecatedLoadPendingRevisionFlag() {
NodeType::create([
'type' => 'article',
])
->save();
$node = Node::create([
'title' => 'test',
'type' => 'article',
]);
$node
->save();
$node
->isDefaultRevision(FALSE);
$node
->setNewRevision(TRUE);
$node
->save();
$converted = $this->container
->get('paramconverter.latest_revision')
->convert($node
->id(), [
'load_pending_revision' => TRUE,
'type' => 'entity:node',
], 'node', []);
$this
->assertEquals($converted
->getLoadedRevisionId(), $node
->getLoadedRevisionId());
}
}