You are here

public function TestRevisionHandler::testCreateRevision in Feeds Paragraphs 8

@covers ::createRevision

File

tests/src/Unit/TestRevisionHandler.php, line 104

Class

TestRevisionHandler
@group Feeds Paragraphs @coversDefaultClass \Drupal\feeds_para_mapper\RevisionHandler

Namespace

Drupal\Tests\feeds_para_mapper\Unit

Code

public function testCreateRevision() {
  $revHandler = $this
    ->getMockBuilder(RevisionHandler::class)
    ->disableOriginalConstructor()
    ->setMethods(array(
    'updateParentRevision',
  ))
    ->getMock();
  $revHandler
    ->expects($this
    ->atLeastOnce())
    ->method('updateParentRevision')
    ->with($this
    ->isInstanceOf(Paragraph::class));
  $method = $this
    ->getMethod($revHandler, 'createRevision');
  $paragraph = end($this->entityHelper->paragraphs);
  $bool = Argument::type('bool');
  $paragraph
    ->setNewRevision($bool)
    ->willReturn(null);
  $paragraph
    ->isDefaultRevision($bool)
    ->willReturn(null);
  $method
    ->invoke($revHandler, $paragraph
    ->reveal());
  $paragraph
    ->setNewRevision($bool)
    ->shouldHaveBeenCalled();
  $paragraph
    ->isDefaultRevision($bool)
    ->shouldHaveBeenCalled();
  $paragraph
    ->save()
    ->shouldHaveBeenCalled();
}