public function PreExistingTermImportExportTest::testTermImportExport in Acquia Content Hub 8.2
Performs taxonomy terms import and runs assertions.
File
- tests/
src/ Kernel/ PreExistingTermImportExportTest.php, line 100
Class
- PreExistingTermImportExportTest
- Tests preexisting entity export and imports.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
public function testTermImportExport() {
// We're not going to use this expectation.
$this
->importFixture(0);
/** @var \Drupal\Core\Entity\EntityRepositoryInterface $repository */
$repository = $this->container
->get('entity.repository');
/** @var \Drupal\Core\Entity\ContentEntityInterface $node */
if (version_compare(\Drupal::VERSION, '8.8.0', '>=')) {
$node = $repository
->loadEntityByUuid('node', '40253012-2a03-47c1-86b8-87e4d0adf091');
}
else {
$node = $repository
->loadEntityByUuid('node', '1264093e-bdad-41a7-a059-1904a5e6d8d6');
}
$values = $this
->handleFieldValues($node
->get('field_custom_category'));
$this
->assertEquals($values[0]['target_id'], $this->terms[2]
->uuid());
// Make sure there is only one single term with the same name in the system.
$term_name = $this->terms[2]
->label();
$terms = $this->entityTypeManager
->getStorage('taxonomy_term')
->loadByProperties([
'name' => $term_name,
]);
$this
->assertEquals(1, count($terms));
}