mockFailure example



  /** * Tests that entity displays are ignored appropriately. * * Entity displays should be ignored when they belong to node types which * were not migrated. */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend     // that it didn't occur, so record that in the map table.     $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_upload_entity_display should skip over the "story" node type config     // because, according to the map table, it didn't occur.     $migration = $this->getMigration('d6_upload_entity_display');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]);
  }

}
$map_row['source_row_status'], MigrateIdMapInterface::ROLLBACK_PRESERVE);

    foreach ($term_data_rows as $row) {
      /** @var \Drupal\taxonomy\Entity\Term $term */
      $term = Term::load($row['id']);
      $this->assertNotEmpty($term);
      $map_row = $term_id_map->getRowBySource(['id' => $row['id']]);
      $this->assertNotNull($map_row['destid1']);
    }

    // Add a failed row to test if this can be rolled back without errors.     $this->mockFailure($term_migration['id' => '4', 'vocab' => '2', 'name' => 'FAIL']);

    // Rollback and verify the entities are gone.     $term_executable->rollback();
    foreach ($term_data_rows as $row) {
      $term = Term::load($row['id']);
      if (in_array($row['id']$preserved_term_ids)) {
        $this->assertNotNull($term);
      }
      else {
        $this->assertNull($term);
      }
      


  /** * Tests that vocabulary displays are ignored appropriately. * * Vocabulary displays should be ignored when they belong to node types which * were not migrated. */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend     // that it didn't occur, so record that in the map table.     $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_vocabulary_entity_form_display should skip over the "story" node type     // config because, according to the map table, it didn't occur.     $migration = $this->getMigration('d6_vocabulary_entity_form_display');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]);
  }

}


  /** * Tests that vocabulary displays are ignored appropriately. * * Vocabulary displays should be ignored when they belong to node types which * were not migrated. */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend     // that it didn't occur, so record that in the map table.     $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_vocabulary_entity_display should skip over the "story" node type     // config because, according to the map table, it didn't occur.     $migration = $this->getMigration('d6_vocabulary_entity_display');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]);
  }

}


  /** * Tests that vocabulary field instances are ignored appropriately. * * Vocabulary field instances should be ignored when they belong to node * types which were not migrated. */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend     // that it didn't occur, so record that in the map table.     $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_vocabulary_field_instance should skip over the "story" node type     // config because, according to the map table, it didn't occur.     $migration = $this->getMigration('d6_vocabulary_field_instance');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]);
  }

}


  /** * Tests that entity displays are ignored appropriately. * * Entity displays should be ignored when they belong to node types which * were not migrated. */
  public function testSkipNonExistentNodeType() {
    // The "story" node type is migrated by d6_node_type but we need to pretend     // that it didn't occur, so record that in the map table.     $this->mockFailure('d6_node_type', ['type' => 'story']);

    // d6_upload_entity_form_display should skip over the "story" node type     // config because according to the map table, it didn't occur.     $migration = $this->getMigration('d6_upload_entity_form_display');

    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]);
  }

}
$this->assertCount(2, $node->field_vocabulary_2_i_1_);
    $this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
    $this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
  }

  /** * Tests that term relationships are ignored for un-migrated nodes. */
  public function testSkipNonExistentNode() {
    // Node 2 is migrated by d6_node__story, but we need to pretend that it     // failed, so record that in the map table.     $this->mockFailure('d6_node:story', ['nid' => 2, 'language' => 'en']);

    // d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,     // according to the map table, it failed.     $migration = $this->getMigration('d6_term_node:2');
    $this->executeMigration($migration);
    $this->assertNull($migration->getIdMap()->lookupDestinationIds(['vid' => 3])[0][0]);
  }

}
Home | Imprint | This part of the site doesn't use cookies.