EntityRevisionConverterTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Drupal\Tests\content_moderation\Kernel;
  3. use Drupal\KernelTests\KernelTestBase;
  4. use Drupal\node\Entity\Node;
  5. use Drupal\node\Entity\NodeType;
  6. /**
  7. * @coversDefaultClass \Drupal\content_moderation\ParamConverter\EntityRevisionConverter
  8. * @group content_moderation
  9. * @group legacy
  10. */
  11. class EntityRevisionConverterTest extends KernelTestBase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static $modules = [
  16. 'user',
  17. 'system',
  18. 'content_moderation',
  19. 'node',
  20. 'workflows',
  21. ];
  22. /**
  23. * {@inheritdoc}
  24. */
  25. protected function setUp() {
  26. parent::setUp();
  27. $this->installEntitySchema('node');
  28. $this->installEntitySchema('user');
  29. $this->installSchema('system', 'sequences');
  30. $this->installSchema('node', 'node_access');
  31. }
  32. /**
  33. * @covers ::convert
  34. * @expectedDeprecationMessage The load_pending_revision flag has been deprecated. You should use load_latest_revision instead.
  35. */
  36. public function testDeprecatedLoadPendingRevisionFlag() {
  37. NodeType::create([
  38. 'type' => 'article',
  39. ])->save();
  40. $node = Node::create([
  41. 'title' => 'test',
  42. 'type' => 'article',
  43. ]);
  44. $node->save();
  45. $node->isDefaultRevision(FALSE);
  46. $node->setNewRevision(TRUE);
  47. $node->save();
  48. $converted = $this->container->get('paramconverter.latest_revision')->convert($node->id(), [
  49. 'load_pending_revision' => TRUE,
  50. 'type' => 'entity:node',
  51. ], 'node', []);
  52. $this->assertEquals($converted->getLoadedRevisionId(), $node->getLoadedRevisionId());
  53. }
  54. }