You are here

public function ConfigEntityRevisionsRevertFormBaseTest::applyRevisionChangeCallsRightFunctionAndSaves in Config Entity Revisions 8

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

Check that applyRevisionChange invokes the right fn and seeks to save.

@test

File

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

Class

ConfigEntityRevisionsRevertFormBaseTest
Test ability to revert (form) configurations.

Namespace

Drupal\Tests\config_entity_revisions\Unit

Code

public function applyRevisionChangeCallsRightFunctionAndSaves() {

  // Older revision -> revert called.
  $this->instance = $this
    ->getMockInstance(300, 'ConfigEntityRevisionsRevertFormTest2');
  $revision = $this->mockOldRevision;
  $revision
    ->save()
    ->shouldBeCalled();
  $this->instance
    ->applyRevisionChange();
  $this
    ->assertTrue($this->instance
    ->get('prepareRevertedRevisionCalled'));
  $this
    ->assertFalse($this->instance
    ->get('prepareToPublishCurrentRevisionCalled'));

  // Newer revision -> publish called.
  $this->instance = $this
    ->getMockInstance(324, 'ConfigEntityRevisionsRevertFormTest2');
  $revision = $this->mockNewRevision;
  $revision
    ->save()
    ->shouldBeCalled();
  $this->instance
    ->applyRevisionChange();
  $this
    ->assertFalse($this->instance
    ->get('prepareRevertedRevisionCalled'));
  $this
    ->assertTrue($this->instance
    ->get('prepareToPublishCurrentRevisionCalled'));
}