public function SkipImportedTest::testSkipImportedPlugin in Entity Share 8.3
Test the "Skip imported" Import Processor plugin.
Test in enabled and disabled state.
File
- modules/
entity_share_client/ tests/ src/ Functional/ SkipImportedTest.php, line 95
Class
- SkipImportedTest
- Functional test class to test import plugin "Skip imported".
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
public function testSkipImportedPlugin() {
// Test that entities can be pulled with plugin "Skip imported" enabled.
$this
->pullEveryChannels();
$this
->checkCreatedEntities();
// Clean up imported content.
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
$recreated_node = $this
->loadEntity('node', 'es_test');
$recreated_node
->delete();
// Test if plugin "Skip imported" skips entities not modified on remote.
// Initial pull should import all entities (ie. one entity).
$this
->pullChannel('node_es_test_en');
$imported_entities = $this->importService
->getRuntimeImportContext()
->getImportedEntities();
$imported_entities_en = $imported_entities['en'] ?? [];
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
$this
->assertEquals(count($imported_entities_en), 1);
// The repeated pull (without any modifications on remote) should
// import no entities.
$this
->pullChannel('node_es_test_en');
$imported_entities = $this->importService
->getRuntimeImportContext()
->getImportedEntities();
$imported_entities_en = $imported_entities['en'] ?? [];
$this
->assertEquals(count($imported_entities_en), 0);
// Clean up imported content.
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
$recreated_node = $this
->loadEntity('node', 'es_test');
$recreated_node
->delete();
// Test behavior when plugin "Skip imported" is not enabled.
$this
->removePluginFromImportConfig('skip_imported');
// Initial pull should import all entities (ie. one entity).
$this
->pullChannel('node_es_test_en');
$imported_entities = $this->importService
->getRuntimeImportContext()
->getImportedEntities();
$imported_entities_en = $imported_entities['en'] ?? [];
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
$this
->assertEquals(count($imported_entities_en), 1);
// The repeated pull should import all entities (ie. one entity) as the
// skip imported plugin is disabled.
$this
->pullChannel('node_es_test_en');
$imported_entities = $this->importService
->getRuntimeImportContext()
->getImportedEntities();
$imported_entities_en = $imported_entities['en'] ?? [];
$this
->assertEquals(count($imported_entities_en), 1);
}