function MigrateNodeTest::assertEntity

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeTest::assertEntity()
  2. 8.9.x core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeTest::assertEntity()
  3. 10 core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeTest::assertEntity()

Asserts various aspects of a node.

@internal

Parameters

string $id: The node ID.

string $type: The node type.

string $langcode: The expected language code.

string $title: The expected title.

int $uid: The expected author ID.

bool $status: The expected status of the node.

int $created: The expected creation time.

int $changed: The expected modification time.

bool $promoted: Whether the node is expected to be promoted to the front page.

bool $sticky: Whether the node is expected to be sticky.

Overrides FileMigrationSetupTrait::assertEntity

1 call to MigrateNodeTest::assertEntity()
MigrateNodeTest::testNode in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
Tests node migration from Drupal 7 to 8.

File

core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php, line 111

Class

MigrateNodeTest
Tests node migration.

Namespace

Drupal\Tests\node\Kernel\Migrate\d7

Code

protected function assertEntity(int $id, string $type, string $langcode, string $title, int $uid, bool $status, int $created, int $changed, bool $promoted, bool $sticky) : void {
    
    /** @var \Drupal\node\NodeInterface $node */
    $node = Node::load($id);
    $this->assertInstanceOf(NodeInterface::class, $node);
    $this->assertEquals($type, $node->getType());
    $this->assertEquals($langcode, $node->langcode->value);
    $this->assertEquals($title, $node->getTitle());
    $this->assertEquals($uid, $node->getOwnerId());
    $this->assertEquals($status, $node->isPublished());
    $this->assertEquals($created, $node->getCreatedTime());
    if (isset($changed)) {
        $this->assertEquals($changed, $node->getChangedTime());
    }
    $this->assertEquals($promoted, $node->isPromoted());
    $this->assertEquals($sticky, $node->isSticky());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.