ParagraphsFieldSettingsTest.php in Paragraphs 8
File
tests/src/Unit/migrate/ParagraphsFieldSettingsTest.php
View source
<?php
namespace Drupal\Tests\paragraphs\Unit\migrate;
use Drupal\paragraphs\Plugin\migrate\process\ParagraphsFieldSettings;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
class ParagraphsFieldSettingsTest extends MigrateProcessTestCase {
protected function setUp() : void {
$this->plugin = new ParagraphsFieldSettings([], 'paragraphs_field_settings', []);
parent::setUp();
}
public function testParagraphsFieldSettings() {
$this->row
->expects($this
->any())
->method('getSourceProperty')
->with('type')
->willReturn('paragraphs');
$value = $this->plugin
->transform([], $this->migrateExecutable, $this->row, 'settings');
$this
->assertEquals([
'target_type' => 'paragraph',
], $value);
}
public function testNonParagraphFieldSettings() {
$this->row
->expects($this
->any())
->method('getSourceProperty')
->with('type')
->willReturn('something_else');
$value = $this->plugin
->transform([], $this->migrateExecutable, $this->row, 'settings');
$this
->assertEmpty($value);
}
public function testTaxonomyParagraphFieldSettings() {
$this->row
->expects($this
->any())
->method('getSourceProperty')
->with('type')
->willReturn('taxonomy_term');
$value = $this->plugin
->transform([
'target_type' => 'some_preset_vaue',
], $this->migrateExecutable, $this->row, 'settings');
$this
->assertEquals([
'target_type' => 'some_preset_vaue',
], $value);
}
}