TamperConfigSchemaTest.php in Tamper 8
File
tests/src/Kernel/TamperConfigSchemaTest.php
View source
<?php
namespace Drupal\Tests\tamper\Kernel;
use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\KernelTests\KernelTestBase;
use Drupal\tamper\SourceDefinition;
use Drupal\tamper\TamperInterface;
use Drupal\tamper\TamperPluginCollection;
class TamperConfigSchemaTest extends KernelTestBase {
public static $modules = [
'entity_test',
'tamper',
'tamper_test',
];
protected $entity;
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('entity_test_bundle');
$this->entity = EntityTestBundle::create([
'id' => 'test',
'label' => 'Test label',
'description' => 'My test description',
]);
$this->entity
->save();
}
public function testCreateInstance() {
$tamper_manager = \Drupal::service('plugin.manager.tamper');
$plugin_collection = new TamperPluginCollection($tamper_manager, new SourceDefinition([]), []);
foreach ($tamper_manager
->getDefinitions() as $plugin_id => $plugin_definition) {
$plugin_collection
->addInstanceId($plugin_id, [
'id' => $plugin_id,
]);
$tamper = $plugin_collection
->get($plugin_id);
$this
->assertInstanceOf(TamperInterface::class, $tamper);
$this->entity
->setThirdPartySetting('tamper_test', 'tampers', $plugin_collection
->getConfiguration());
$this->entity
->save();
}
}
}