assertRevision example

$this->assertInstanceOf(NodeInterface::class$revision);
    $this->assertSame($title$revision->getTitle());
    $this->assertSame($langcode$revision->language()->getId());
    $this->assertSame($log$revision->revision_log->value);
    $this->assertSame($timestamp(int) $revision->getRevisionCreationTime());
  }

  /** * Tests the migration of node revisions with translated nodes. */
  public function testNodeRevisions() {
    $this->assertRevision(1, 'en', 'An English Node', NULL, 1441032132);
    $this->assertRevision(2, 'en', 'The thing about Deep Space 9 (1st rev)', 'DS9 1st rev', 1564543588);
    $this->assertRevision(4, 'is', 'is - The thing about Firefly (1st rev)', 'is - Firefly 1st rev', 1478755274);
    $this->assertRevision(6, 'en', 'Comments are closed :-(', NULL, 1504715414);
    $this->assertRevision(7, 'en', 'Comments are open :-)', NULL, 1504715432);
    $this->assertRevision(8, 'en', 'The number 47', NULL, 1552126363);

    // Test that the revision translation are not migrated and there should not     // be a revision with id of 9.     $ids = [3, 5, 9];
    foreach ($ids as $id) {
      $this->assertNull($this->nodeStorage->loadRevision($id));
    }
$this->assertEquals($this->expectedNodeFieldDataTable()$db->select('node_field_data', 'nr')
      ->fields('nr')
      ->orderBy('nid')
      ->orderBy('vid')
      ->orderBy('langcode')
      ->execute()
      ->fetchAll(\PDO::FETCH_ASSOC));

    // Load and test each revision.     $data = $this->expectedRevisionEntityData()[0];
    foreach ($this->expectedNodeFieldRevisionTable() as $key => $revision) {
      $this->assertRevision($revision$data[$key]);
    }

    // Test the migration of node and user reference fields.     foreach ([2, 3] as $revision_id) {
      $revision = $this->nodeStorage->loadRevision($revision_id);
      $this->assertCount(1, $revision->field_node_reference);
      $this->assertSame('5', $revision->field_node_reference->target_id);

      $this->assertCount(1, $revision->field_user_reference);
      $this->assertSame('Bob', $revision->field_user_reference[0]->entity->getAccountName());
    }

    
->fields('nr')
      ->orderBy('nid')
      ->orderBy('vid')
      ->orderBy('langcode')
      ->execute()
      ->fetchAll(\PDO::FETCH_ASSOC));

    // Now load and test each revision, including the field 'field_text_plain'     // which has text reflecting the revision.     $data = $this->expectedRevisionEntityData()[0];
    foreach ($this->expectedNodeFieldRevisionTable() as $key => $revision) {
      $this->assertRevision($revision$data[$key]);
    }

    // Test the order in multi-value fields.     $revision = $this->nodeStorage->loadRevision(21);
    $this->assertSame([
      ['target_id' => '15'],
      ['target_id' => '16'],
    ]$revision->get('field_company')->getValue());
  }

  /** * Asserts various aspects of a node revision. * * @param array $revision * An array of revision data matching a node_field_revision table row. * @param array $data * An array of revision data. * * @internal */
/** * Tests node migration from Drupal 7 to 8. */
  public function testNode() {
    // Confirm there are only classic node migration map tables. This shows     // that only the classic migration ran.     $results = $this->nodeMigrateMapTableCount('7');
    $this->assertSame(9, $results['node']);
    $this->assertSame(0, $results['node_complete']);

    $this->assertEntity(1, 'test_content_type', 'en', 'An English Node', '2', TRUE, '1421727515', '1441032132', TRUE, FALSE);
    $this->assertRevision(1, 'An English Node', '1', NULL, '1441032132');

    $node = Node::load(1);
    $this->assertNotEmpty($node->field_boolean->value);
    $this->assertEquals('99-99-99-99', $node->field_phone->value);
    $this->assertSame('2015-01-20T04:15:00', $node->field_date->value);
    $this->assertSame('2015-01-20', $node->field_date_without_time->value);
    $this->assertSame('2015-01-20', $node->field_datetime_without_time->value);
    $this->assertEquals(1, $node->field_float->value);
    $this->assertEquals('5', $node->field_integer->value);
    $this->assertEquals('Some more text', $node->field_text_list[0]->value);
    $this->assertEquals('7', $node->field_integer_list[0]->value);
    
/** @var \Drupal\node\NodeInterface $node */
    $this->assertSame('1', $node->id());
    $this->assertSame('2001', $node->getRevisionId());
    $this->assertSame('und', $node->langcode->value);
    $this->assertSame('Test title rev 3', $node->getTitle());
    $this->assertSame('body test rev 3', $node->body->value);
    $this->assertSame('teaser test rev 3', $node->body->summary);
    $this->assertSame('2', $node->getRevisionUser()->id());
    $this->assertSame('modified rev 3', $node->revision_log->value);
    $this->assertSame('1420861423', $node->getRevisionCreationTime());

    $this->assertRevision(1, 'und', 'Test title', NULL, 1390095702);
    $this->assertRevision(3, 'und', 'Test title rev 3', NULL, 1420718386);
    $this->assertRevision(4, 'und', 'Test page title rev 4', NULL, 1390095701);
    $this->assertRevision(5, 'und', 'Test title rev 2', 'modified rev 2', 1390095703);
    $this->assertRevision(6, 'und', 'Node 4', NULL, 1390095701);
    $this->assertRevision(7, 'und', 'Node 5', NULL, 1390095701);
    $this->assertRevision(8, 'und', 'Node 6', NULL, 1390095701);
    $this->assertRevision(9, 'und', 'Node 7', NULL, 1390095701);
    $this->assertRevision(10, 'und', 'Node 8', NULL, 1390095701);
    $this->assertRevision(11, 'und', 'Node 9', NULL, 1390095701);
    $this->assertRevision(12, 'und', 'Once upon a time', NULL, 1444671588);
    $this->assertRevision(13, 'en', 'The Real McCoy', NULL, 1444238808);
    
Home | Imprint | This part of the site doesn't use cookies.