EckEntityExceptionTest.php in Entity Construction Kit (ECK) 8
File
tests/src/Kernel/Plugin/migrate/source/d7/EckEntityExceptionTest.php
View source
<?php
namespace Drupal\Tests\eck\Kernel\Plugin\migrate\source;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateException;
use Drupal\Tests\eck\Kernel\Migrate\d7\MigrateEckTestBase;
class EckEntityExceptionTest extends MigrateEckTestBase {
public static $modules = [
'eck',
];
protected $migrationPluginManager;
public function setUp() {
parent::setUp();
$this->migrationPluginManager = \Drupal::service('plugin.manager.migration');
}
public function testEckEntityCheckRequirements() {
$this
->expectException(RequirementsException::class);
$this
->expectExceptionMessage("ECK table for 'does_not_exist' does not exist");
$migration = $this
->getMigration('d7_eck');
$definition = $migration
->getPluginDefinition();
$definition['source'] = [
'plugin' => 'd7_eck_entity',
'entity_type' => 'does_not_exist',
'bundle' => 'simple_entity',
];
$migration = $this->migrationPluginManager
->createInstance('d7_eck:simple_entity:simple_entity', $definition);
$migration
->getSourcePlugin()
->checkRequirements();
}
public function testEckEntityConstructor($entity_type, $bundle, $exception_message) {
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage($exception_message);
$migration = $this
->getMigration('d7_eck:simple_entity:simple_entity');
$definition = $migration
->getPluginDefinition();
$definition['source'] = [
'plugin' => 'd7_eck_entity',
'entity_type' => $entity_type,
'bundle' => $bundle,
];
$migration = $this->migrationPluginManager
->createInstance('d7_eck:simple_entity:simple_entity', $definition);
$migration
->getSourcePlugin();
}
public function providerTestEckEntityConstructor() {
return [
'entity array' => [
[],
'string',
"The entity_type must be a string",
],
];
}
}