function FieldDiscoveryTest::testGetAllFields

Same name in this branch
  1. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testGetAllFields()
Same name in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testGetAllFields()
  2. 9 core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\FieldDiscoveryTest::testGetAllFields()
  3. 10 core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testGetAllFields()
  4. 10 core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\FieldDiscoveryTest::testGetAllFields()
  5. 11.x core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testGetAllFields()
  6. 11.x core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\FieldDiscoveryTest::testGetAllFields()

Tests the getAllFields method.

@covers ::getAllFields

File

core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php, line 280

Class

FieldDiscoveryTest
Test FieldDiscovery Service against Drupal 7.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d7

Code

public function testGetAllFields() {
    $field_discovery_test = new FieldDiscoveryTestClass($this->fieldPluginManager, $this->migrationPluginManager, $this->logger);
    $actual_fields = $field_discovery_test->getAllFields('7');
    $this->assertSame([
        'comment',
        'node',
        'user',
        'taxonomy_term',
    ], array_keys($actual_fields));
    $this->assertArrayHasKey('test_vocabulary', $actual_fields['taxonomy_term']);
    $this->assertArrayHasKey('user', $actual_fields['user']);
    $this->assertArrayHasKey('test_content_type', $actual_fields['node']);
    $this->assertCount(7, $actual_fields['node']);
    $this->assertCount(7, $actual_fields['comment']);
    $this->assertCount(22, $actual_fields['node']['test_content_type']);
    foreach ($actual_fields as $entity_type_id => $bundles) {
        foreach ($bundles as $bundle => $fields) {
            foreach ($fields as $field_name => $field_info) {
                $this->assertArrayHasKey('field_definition', $field_info);
                $this->assertEquals($entity_type_id, $field_info['entity_type']);
                $this->assertEquals($bundle, $field_info['bundle']);
            }
        }
    }
}

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