You are here

public function ConfigEntityRevisionsRevertFormBaseTest::publishedVersionOfRevisionGeneratedCorrectly in Config Entity Revisions 1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/ConfigEntityRevisionsRevertFormBaseTest.php \Drupal\Tests\config_entity_revisions\Unit\ConfigEntityRevisionsRevertFormBaseTest::publishedVersionOfRevisionGeneratedCorrectly()
  2. 8 tests/src/Unit/ConfigEntityRevisionsRevertFormBaseTest.php \Drupal\Tests\config_entity_revisions\Unit\ConfigEntityRevisionsRevertFormBaseTest::publishedVersionOfRevisionGeneratedCorrectly()

Check that preparation of a published revision does all it should.

@test

File

tests/src/Unit/ConfigEntityRevisionsRevertFormBaseTest.php, line 394

Class

ConfigEntityRevisionsRevertFormBaseTest

Namespace

Drupal\Tests\config_entity_revisions\Unit

Code

public function publishedVersionOfRevisionGeneratedCorrectly() {
  $this->instance = $this
    ->getMockInstance(324);
  $revision = $this->mockNewRevision;
  $revision
    ->setNewRevision()
    ->shouldNotBeCalled();
  $revision
    ->isDefaultRevision(Argument::type('bool'))
    ->shouldBeCalled()
    ->should(function ($calls) {
    if (!$calls || !$calls[0]
      ->getArguments()[0]) {
      throw new \Exception("isDefaultRevision wasn't set to TRUE.");
    }
  });
  $revision
    ->setRevisionUserId(Argument::type('int'))
    ->shouldNotBeCalled();
  $revision
    ->setRevisionCreationTime(Argument::type('int'))
    ->shouldNotBeCalled();
  $revision
    ->setChangedTime(Argument::type('int'))
    ->shouldNotBeCalled();
  $revision
    ->setPublished()
    ->shouldBeCalled();
  $key_value_pairs = [];
  $revision
    ->set(Argument::type('string'), Argument::any())
    ->will(function ($arguments) use (&$key_value_pairs) {
    $key_value_pairs[$arguments[0]] = $arguments[1];
  });
  $this->instance
    ->prepareToPublishCurrentRevision($revision
    ->reveal());
  $this
    ->assertEquals([
    'moderation_state' => 'published',
  ], $key_value_pairs);
}