You are here

public function CreateNewRevisionTest::testNewRevision in Acquia Content Hub 8.2

Tests CreateNewRevision event subscriber.

@covers ::onPreEntitySave

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Kernel/EventSubscriber/PreEntitySave/CreateNewRevisionTest.php, line 50

Class

CreateNewRevisionTest
Test that new revisions are handled correctly in PreEntitySave event.

Namespace

Drupal\Tests\acquia_contenthub\Kernel\EventSubscriber\PreEntitySave

Code

public function testNewRevision() {

  // Create a test content type.
  $this
    ->createContentType();

  // Create a test node.
  $node = $this
    ->createNode();
  $settings = $this->clientFactory
    ->getClient()
    ->getSettings();
  $cdf = new CDFObject('drupal8_content_entity', $node
    ->uuid(), date('c'), date('c'), $settings
    ->getUuid());
  $event = new PreEntitySaveEvent($node, new DependencyStack(), $cdf);
  $this->createNewRevision
    ->onPreEntitySave($event);
  $entity = $event
    ->getEntity();
  $this
    ->assertTrue($entity
    ->isNewRevision());
}