assertEntity example

$this->assertSame($label$entity->label());
    $this->assertSame('node', $entity->getTargetEntityTypeId());
  }

  /** * Tests the migrated comment types. */
  public function testMigration() {
    $this->installConfig(['comment']);
    $this->executeMigration('d6_comment_type');

    $this->assertEntity('comment_node_article', 'Article comment');
    $this->assertEntity('comment_node_company', 'Company comment');
    $this->assertEntity('comment_node_employee', 'Employee comment');
    $this->assertEntity('comment_node_event', 'Event comment');
    $this->assertEntity('comment_forum', 'Forum topic comment');
    $this->assertEntity('comment_node_page', 'Page comment');
    $this->assertEntity('comment_node_sponsor', 'Sponsor comment');
    $this->assertEntity('comment_node_story', 'Story comment');
    $this->assertEntity('comment_node_test_event', 'Migrate test event comment');
    $this->assertEntity('comment_node_test_page', 'Migrate test page comment');
    $this->assertEntity('comment_node_test_planet', 'Migrate test planet comment');
    $this->assertEntity('comment_node_test_story', 'Migrate test story comment');
    
$entity = Vocabulary::load($id);
    $this->assertInstanceOf(VocabularyInterface::class$entity);
    $this->assertSame($expected_label$entity->label());
    $this->assertSame($expected_description$entity->getDescription());
    $this->assertSame($expected_weight(int) $entity->get('weight'));
  }

  /** * Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration. */
  public function testTaxonomyVocabulary() {
    $this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', 0);
    $this->assertEntity('forums', 'Sujet de discussion', 'Forum navigation vocabulary', -10);
    $this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', 0);
    $this->assertEntity('vocabulary_name_much_longer_th', 'vocabulary name clearly different than machine name and much longer than thirty two characters', 'description of vocabulary name much longer than thirty two characters', 0);
  }

}
$handler_settings = $field->getSetting('handler_settings');
    $this->assertArrayHasKey('target_bundles', $handler_settings);
    foreach ($handler_settings['target_bundles'] as $target_bundle) {
      $this->assertContains($target_bundle$target_bundles);
    }
  }

  /** * Tests migrating D7 field instances to field_config entities. */
  public function testFieldInstances() {
    $this->assertEntity('comment.comment_node_page.comment_body', 'Comment', 'text_long', TRUE, FALSE);
    $this->assertEntity('node.page.body', 'Body', 'text_with_summary', FALSE, FALSE);
    $this->assertEntity('comment.comment_node_article.comment_body', 'Comment', 'text_long', TRUE, FALSE);
    $this->assertEntity('node.article.body', 'Body', 'text_with_summary', FALSE, TRUE);
    $this->assertEntity('node.article.field_tags', 'Tags', 'entity_reference', FALSE, FALSE);
    $this->assertEntity('node.article.field_image', 'Image', 'image', FALSE, TRUE);
    $this->assertEntity('comment.comment_node_blog.comment_body', 'Comment', 'text_long', TRUE, FALSE);
    $this->assertEntity('node.blog.body', 'Body', 'text_with_summary', FALSE, TRUE);
    $this->assertEntity('node.blog.field_file_mfw', 'file_mfw', 'file', FALSE, TRUE);
    $this->assertEntity('node.blog.field_image_miw', 'image_miw', 'image', FALSE, TRUE);
    $this->assertEntity('comment.comment_node_book.comment_body', 'Comment', 'text_long', TRUE, FALSE);
    $this->assertEntity('node.book.body', 'Body', 'text_with_summary', FALSE, FALSE);
    

  protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('d6_action');
  }

  /** * Tests Drupal 6 action migration to Drupal 8. */
  public function testActions() {
    // Test default actions.     $this->assertEntity('node_publish_action', 'Publish post', 'node', []);
    $this->assertEntity('node_make_sticky_action', 'Make post sticky', 'node', []);
    $this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
    $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);

    // Test advanced actions.     $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
    $this->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', ["owner_uid" => "2"]);
    $this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
    $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
    $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
      "recipient" => "test@example.com",
      
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
    $this->assertSame($title$shortcut->getTitle());
    $this->assertSame($weight(int) $shortcut->getWeight());
    $this->assertSame($url$shortcut->getUrl()->toString());
  }

  /** * Tests the shortcut migration. */
  public function testShortcutMigration() {
    // Check if the 4 shortcuts were migrated correctly.     $this->assertEntity(1, 'Add content', -20, '/node/add');
    $this->assertEntity(2, 'Find content', -19, '/admin/content');
    $this->assertEntity(3, 'Help', -49, '/admin/help');
    $this->assertEntity(4, 'People', -50, '/admin/people');
  }

}


    $this->assertArrayHasKey($tid$this->treeData[$vid], "Term $tid exists in taxonomy tree");
    $term = $this->treeData[$vid][$tid];
    $this->assertEquals($parent_idsarray_filter($term->parents), "Term $tid has correct parents in taxonomy tree");
  }

  /** * Tests the Drupal 6 i18n localized taxonomy term to Drupal 8 migration. */
  public function testTranslatedLocalizedTaxonomyTerms() {
    $this->assertEntity(14, 'en', 'Talos IV', 'vocabulary_name_much_longer_th', 'The home of Captain Christopher Pike.', NULL, 0, []);
    $this->assertEntity(15, 'en', 'Vulcan', 'vocabulary_name_much_longer_th', NULL, NULL, 0, []);

    /** @var \Drupal\taxonomy\TermInterface $entity */
    $entity = Term::load(14);
    $this->assertTrue($entity->hasTranslation('fr'));
    $translation = $entity->getTranslation('fr');
    $this->assertSame('fr - Talos IV', $translation->label());
    $this->assertSame('fr - The home of Captain Christopher Pike.', $translation->getDescription());

    $this->assertTrue($entity->hasTranslation('zu'));
    $translation = $entity->getTranslation('zu');
    
'd7_language_content_menu_settings',
      'd7_menu_links',
      'd7_menu_links_localized',
    ]);
  }

  /** * Tests migration of menu link localized translations. */
  public function testMenuLinkLocalized() {
    // A translate and localize menu, menu-test-menu.     $this->assertEntity(468, 'en', 'Yahoo', 'menu-test-menu', 'english description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0);
    $this->assertEntity(468, 'fr', 'fr - Yahoo', 'menu-test-menu', 'fr - description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0);
    $this->assertEntity(468, 'is', 'is - Yahoo', 'menu-test-menu', 'is - description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0);
  }

}
'path' => 'public://sites/default/files/cube.jpeg',
      'size' => '3620',
      'base_path' => 'public://',
      'plugin_id' => 'd7_file',
    ];
  }

  /** * Tests that all expected files are migrated. */
  public function testFileMigration() {
    $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', 3620, 1421727515, 1421727515, '1');
    // Ensure temporary file was not migrated.     $this->assertNull(File::load(4));
  }

}

  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(static::$modules);
    $this->executeMigration('d7_image_styles');
  }

  /** * Tests the image styles migration. */
  public function testImageStylesMigration() {
    $this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'][['width' => 55, 'height' => 55, 'anchor' => 'center-center'][]]);
    $this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'][['width' => 55, 'height' => 100]['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => FALSE]]);
    $this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'][['width' => 150, 'height' => NULL, 'upscale' => FALSE]['width' => 50, 'height' => 50, 'anchor' => 'left-top']]);
  }

  /** * Asserts various aspects of an ImageStyle entity. * * @param string $id * The expected image style ID. * @param string $label * The expected image style label. * @param array $expected_effect_plugins * An array of expected plugins attached to the image style entity * @param array $expected_effect_config * An array of expected configuration for each effect in the image style */
$this->assertSame($expected_available_menus$entity->getThirdPartySetting('menu_ui', 'available_menus'));
    $this->assertSame($expected_parent$entity->getThirdPartySetting('menu_ui', 'parent'));
  }

  /** * Tests Drupal 7 node type to Drupal 8 migration. */
  public function testNodeType() {
    $expected_available_menus = ['main-menu'];
    $expected_parent = 'main-menu:0:';

    $this->assertEntity('article', 'Article', 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.', 'Help text for articles', TRUE, FALSE, $expected_available_menus$expected_parent, "Body");
    $this->assertEntity('blog', 'Blog entry', 'Use for multi-user blogs. Every user gets a personal blog.', 'Blog away, good sir!', TRUE, FALSE, $expected_available_menus$expected_parent, 'Body');
    // book's display_submitted flag is not set, so it will default to TRUE.     $this->assertEntity('book', 'Book page', '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.', '', TRUE, TRUE, $expected_available_menus$expected_parent, "Body");
    $this->assertEntity('forum', 'Forum topic', 'A <em>forum topic</em> starts a new discussion thread within a forum.', 'No name-calling, no flame wars. Be nice.', TRUE, FALSE, $expected_available_menus$expected_parent, 'Body');
    $this->assertEntity('page', 'Basic page', "Use <em>basic pages</em> for your static content, such as an 'About us' page.", 'Help text for basic pages', FALSE, FALSE, $expected_available_menus$expected_parent, "Body");
    // Test the 32 character type name exists.     $this->assertEntity('a_thirty_two_character_type_name', 'Test long name', '', '', TRUE, FALSE, NULL, NULL, "Body");

    // This node type does not carry a body field.     $expected_available_menus = [
      'main-menu',
      
$navigation_menu = Menu::load($id);
    $this->assertSame($id$navigation_menu->id());
    $this->assertSame($language$navigation_menu->language()->getId());
    $this->assertSame($label$navigation_menu->label());
    $this->assertSame($description$navigation_menu->getDescription());
  }

  /** * Tests the Drupal 7 menu to Drupal 8 migration. */
  public function testMenu() {
    $this->assertEntity('main', 'und', 'Main menu', 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.');
    $this->assertEntity('admin', 'und', 'Management', 'The <em>Management</em> menu contains links for administrative tasks.');
    $this->assertEntity('menu-test-menu', 'und', 'Test Menu', 'Test menu description.');
    $this->assertEntity('tools', 'und', 'Navigation', 'The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.');
    $this->assertEntity('account', 'und', 'User menu', 'The <em>User</em> menu contains links related to the user\'s account, as well as the \'Log out\' link.');
    $this->assertEntity('menu-fixedlang', 'is', 'FixedLang', '');

    // Test that we can re-import using the ConfigEntityBase destination.     Database::getConnection('default', 'migrate')
      ->update('menu_custom')
      ->fields(['title' => 'Home Navigation'])
      ->condition('menu_name', 'navigation')
      
$this->assertSame($default_mode$entity->getSetting('default_mode'));
    $this->assertSame($per_page$entity->getSetting('per_page'));
    $this->assertSame($anonymous$entity->getSetting('anonymous'));
    $this->assertSame($form_location$entity->getSetting('form_location'));
    $this->assertSame($preview$entity->getSetting('preview'));
  }

  /** * Tests the migrated field instance values. */
  public function testMigration() {
    $this->assertEntity('article', 'comment_node_article', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('company', 'comment_node_company', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('employee', 'comment_node_employee', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('event', 'comment_node_event', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('forum', 'comment_forum', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('page', 'comment_node_page', 0, 1, 50, 0, FALSE, 1);
    $this->assertEntity('sponsor', 'comment_node_sponsor', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('story', 'comment_node_story', 2, 0, 70, 1, FALSE, 0);
    $this->assertEntity('test_event', 'comment_node_test_event', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('test_page', 'comment_node_test_page', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('test_planet', 'comment_node_test_planet', 2, 1, 50, 0, FALSE, 1);
    $this->assertEntity('test_story', 'comment_node_test_story', 2, 1, 50, 0, FALSE, 1);
  }
$override = BaseFieldOverride::load($id);
    $this->assertInstanceOf(BaseFieldOverride::class$override);
    /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $override */
    $this->assertSame($label$override->getLabel());
  }

  /** * Tests migration of node title field overrides. */
  public function testMigration() {
    // Forum title labels are overridden to 'Subject'.     $this->assertEntity('node.forum.title', 'Subject');
    // Other content types use the default of 'Title' and are not overridden.     $no_override_node_type = [
      'article',
      'blog',
      'book',
      'page',
      'test_content_type',
    ];
    foreach ($no_override_node_type as $type) {
      $override = BaseFieldOverride::load("node.$type.title");
      $this->assertNotInstanceOf(BaseFieldOverride::class$override);
    }
$this->assertSame($default_mode$entity->getSetting('default_mode'));
    $this->assertSame($per_page$entity->getSetting('per_page'));
    $this->assertSame($anonymous$entity->getSetting('anonymous'));
    $this->assertSame($form_location$entity->getSetting('form_location'));
    $this->assertSame($preview$entity->getSetting('preview'));
  }

  /** * Tests the migrated fields. */
  public function testMigration() {
    $this->assertEntity('page', 'comment_node_page', 0, 1, 50, 0, TRUE, 1);
    $this->assertEntity('article', 'comment_node_article', 2, 1, 50, 0, TRUE, 1);
    $this->assertEntity('blog', 'comment_node_blog', 2, 1, 50, 0, TRUE, 1);
    $this->assertEntity('book', 'comment_node_book', 2, 1, 50, 0, TRUE, 1);
    $this->assertEntity('forum', 'comment_forum', 2, 1, 50, 0, TRUE, 1);
    $this->assertEntity('test_content_type', 'comment_node_test_content_type', 2, 1, 30, 0, TRUE, 1);
    $this->assertEntity('et', 'comment_node_et', 2, 1, 50, 0, FALSE, 1);
  }

}
$this->assertSame($name$file->getFilename());
    $this->assertSame($size(int) $file->getSize());
    $this->assertSame($uri$file->getFileUri());
    $this->assertSame($type$file->getMimeType());
    $this->assertSame($uid(int) $file->getOwnerId());
  }

  /** * Tests the Drupal 6 files to Drupal 8 migration. */
  public function testFiles() {
    $this->assertEntity(1, 'Image1.png', 39325, 'public://image-1.png', 'image/png', 1);
    $this->assertEntity(2, 'Image2.jpg', 1831, 'public://image-2.jpg', 'image/jpeg', 1);
    $this->assertEntity(3, 'image-3.jpg', 1831, 'public://image-3.jpg', 'image/jpeg', 1);
    $this->assertEntity(4, 'html-1.txt', 19, 'public://html-1.txt', 'text/plain', 1);
    // Ensure temporary file was not migrated.     $this->assertNull(File::load(6));

    $map_table = $this->getMigration('d6_file')->getIdMap()->mapTableName();
    $map = \Drupal::database()
      ->select($map_table, 'm')
      ->fields('m', ['sourceid1', 'destid1'])
      ->execute()
      
Home | Imprint | This part of the site doesn't use cookies.