trait DestinationCategoryTestTrait in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Plugin/migrate/DestinationCategoryTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\Plugin\migrate\DestinationCategoryTestTrait
- 3.1.x tests/src/Kernel/Plugin/migrate/DestinationCategoryTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\Plugin\migrate\DestinationCategoryTestTrait
Class DestinationCategoryTestTrait.
Hierarchy
- trait \Drupal\Tests\commerce_migrate\Kernel\Plugin\migrate\DestinationCategoryTestTrait
3 files declare their use of DestinationCategoryTestTrait
- DestinationCategoryTest.php in modules/
magento/ tests/ src/ Kernel/ Plugin/ migrate/ DestinationCategoryTest.php - DestinationCategoryTest.php in modules/
woocommerce/ tests/ src/ Kernel/ Plugin/ migrate/ DestinationCategoryTest.php - DestinationCategoryTest.php in modules/
shopify/ tests/ src/ Kernel/ Plugin/ migrate/ DestinationCategoryTest.php
File
- tests/
src/ Kernel/ Plugin/ migrate/ DestinationCategoryTestTrait.php, line 20
Namespace
Drupal\Tests\commerce_migrate\Kernel\Plugin\migrateView source
trait DestinationCategoryTestTrait {
/**
* Asserts that all migrations are tagged as either Configuration or Content.
*
* @param \Drupal\migrate\Plugin\MigrationInterface[] $migrations
* The migrations.
*/
protected function assertCategories(array $migrations) {
foreach ($migrations as $id => $migration) {
$object_classes = class_parents($migration
->getDestinationPlugin());
$object_classes[] = get_class($migration
->getDestinationPlugin());
// Ensure that the destination plugin is an instance of at least one of
// the expected classes.
if (in_array('Configuration', $migration
->getMigrationTags(), TRUE)) {
$this
->assertNotEmpty(array_intersect($object_classes, $this
->getConfigurationClasses()), "The migration {$id} is tagged as Configuration.");
}
elseif (in_array('Content', $migration
->getMigrationTags(), TRUE)) {
$this
->assertNotEmpty(array_intersect($object_classes, $this
->getContentClasses()), "The migration {$id} is tagged as Content.");
}
else {
$this
->fail("The migration {$id} is not tagged as either 'Content' or 'Configuration'.");
}
}
}
/**
* Get configuration classes.
*
* Configuration migrations should have a destination plugin that is an
* instance of one of the following classes.
*
* @return array
* The configuration class names.
*/
protected function getConfigurationClasses() {
return [
Color::class,
Config::class,
EntityConfigBase::class,
ThemeSettings::class,
ComponentEntityDisplayBase::class,
ShortcutSetUsers::class,
];
}
/**
* Get content classes.
*
* Content migrations should have a destination plugin that is an instance
* of one of the following classes.
*
* @return array
* The content class names.
*/
protected function getContentClasses() {
return [
EntityContentBase::class,
UrlAlias::class,
BlockedIP::class,
NodeCounter::class,
UserData::class,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DestinationCategoryTestTrait:: |
protected | function | Asserts that all migrations are tagged as either Configuration or Content. | |
DestinationCategoryTestTrait:: |
protected | function | Get configuration classes. | |
DestinationCategoryTestTrait:: |
protected | function | Get content classes. |