You are here

public function PublicationDatePreExistingContentTest::testWithExistingContent in Publication Date 8.2

File

tests/src/Functional/PublicationDatePreExistingContentTest.php, line 57

Class

PublicationDatePreExistingContentTest
Tests the integration on node forms.

Namespace

Drupal\Tests\publication_date\Functional

Code

public function testWithExistingContent() {

  // Unpublished by default

  /** @var \Drupal\node\NodeInterface $node */
  $node = Node::create([
    'type' => 'test1',
    'title' => $this
      ->randomString(),
  ]);
  $node
    ->save();
  \Drupal::service('module_installer')
    ->install([
    'publication_date',
  ]);

  // Load node from database again after installation.
  $node = Node::load($node
    ->id());
  $node
    ->save();
  $this
    ->assertEqual($node->published_at->value, PUBLICATION_DATE_DEFAULT);
  $node
    ->setPublished()
    ->save();
  $this
    ->assertNotNull($node->published_at->value);
  $this
    ->assertNotEqual($node->published_at->value, PUBLICATION_DATE_DEFAULT);
}