You are here

protected function DefaultContentTest::doPostInstallTests in Default Content for D8 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/DefaultContentTest.php \Drupal\Tests\default_content\Functional\DefaultContentTest::doPostInstallTests()

Makes assertions post the install of the default_content_test module.

2 calls to DefaultContentTest::doPostInstallTests()
DefaultContentTest::testImport in tests/src/Functional/DefaultContentTest.php
Test importing default content.
DefaultContentTest::testImportViaConfigImporter in tests/src/Functional/DefaultContentTest.php
Test importing default content via ConfigImporter.

File

tests/src/Functional/DefaultContentTest.php, line 85

Class

DefaultContentTest
Test import of default content.

Namespace

Drupal\Tests\default_content\Functional

Code

protected function doPostInstallTests() {

  // Login as admin.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([], NULL, TRUE));

  // Ensure the content contained in the default_content_test module has been
  // created correctly.
  $node = $this
    ->getNodeByTitle('Imported node');
  $this
    ->assertEquals($node->body->value, 'Crikey it works!');
  $this
    ->assertEquals($node
    ->getType(), 'page');
  $this
    ->assertSame('2', $node
    ->getOwnerId(), 'The node created is owned by user 2');
  $node = $this
    ->getNodeByTitle('Imported node with owned by user 1');
  $this
    ->assertSame('1', $node
    ->getOwnerId(), 'The node created is owned by user 1');
  $node = $this
    ->getNodeByTitle('Imported node with owned by user that does not exist');
  $this
    ->assertSame('1', $node
    ->getOwnerId(), 'The node created is owned by user 1');
  $terms = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term')
    ->loadMultiple();
  $term = reset($terms);
  $this
    ->assertNotEmpty($term);
  $this
    ->assertEquals($term->name->value, 'A tag');
  $term_id = $node->field_tags->target_id;
  $this
    ->assertNotEmpty($term_id);
}