Skip to content
Snippets Groups Projects
Commit 5c8c3a1f authored by Ken Mortimer's avatar Ken Mortimer Committed by Ken Mortimer
Browse files

Issue #3282374 by mortim07: Add NULL destination plugin

parent e46119f5
No related branches found
No related tags found
No related merge requests found
<?php
declare(strict_types=1);
namespace Drupal\data_pipelines\Plugin\DatasetDestination;
use Drupal\Core\Form\FormStateInterface;
use Drupal\data_pipelines\Destination\DatasetDestinationPluginBase;
use Drupal\data_pipelines\Entity\DatasetInterface;
use Drupal\data_pipelines\Entity\DestinationInterface;
/**
* A class that provides Null as a destination plugin.
*
* @DatasetDestination(
* id="null",
* label="Null",
* description="Does nothing with the dataset."
* )
*/
class NullDestination extends DatasetDestinationPluginBase {
/**
* {@inheritdoc}
*/
public function viewSettings(): array {
return [];
}
/**
* {@inheritdoc}
*/
public function saveDataSet(DatasetInterface $dataset, DestinationInterface $destination): bool {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function deleteDataSet(DatasetInterface $dataset, DestinationInterface $destination): bool {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state): array {
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void {
}
}
<?php
declare(strict_types=1);
namespace Drupal\Tests\data_pipelines\Unit\Plugin\DatasetDestination;
use Drupal\data_pipelines\Entity\Dataset;
use Drupal\data_pipelines\Entity\Destination;
use Drupal\data_pipelines\Plugin\DatasetDestination\NullDestination;
use Drupal\Tests\data_pipelines\Kernel\DatasetKernelTestBase;
/**
* A class to test the Null destination plugin.
*
* @group data_pipelines
* @coversDefaultClass \Drupal\data_pipelines\Plugin\DatasetDestination\NullDestination
*/
class NullDestinationTest extends DatasetKernelTestBase {
/**
* @covers ::saveDataSet
* @covers ::deleteDataSet
*/
public function testSaveDataDeleteData() {;
$destination_plugin = new NullDestination([], 'null', []);
$dataset = Dataset::create(['source' => 'csv:text']);
$destination = Destination::create();
$this->assertTrue($destination_plugin->saveDataSet($dataset, $destination));
$this->assertTrue($destination_plugin->deleteDataSet($dataset, $destination));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment