You are here

public function ParagraphsProcessOnValueTest::testProcess in Paragraphs 8

Test processing if conditions are met.

File

tests/src/Unit/migrate/ParagraphsProcessOnValueTest.php, line 53

Class

ParagraphsProcessOnValueTest
Test class for the paragraphs_process_on_value process plugin.

Namespace

Drupal\Tests\paragraphs\Unit\migrate

Code

public function testProcess() {
  $migration = $this
    ->getMigration();
  $get = new Get([
    'source' => 'theValue',
  ], 'get', []);
  $migration
    ->expects($this
    ->any())
    ->method('getProcessPlugins')
    ->willReturn([
    'destination' => [
      $get,
    ],
  ]);
  $this->row
    ->expects($this
    ->any())
    ->method('getSourceProperty')
    ->with('source')
    ->willReturn('expected');
  $event_dispatcher = $this
    ->createMock(EventDispatcherInterface::class);
  $message = $this
    ->createMock(MigrateMessageInterface::class);
  $migrate_executable = new MigrateExecutable($migration, $message, $event_dispatcher);
  $value = $this->plugin
    ->transform('Initial Value', $migrate_executable, $this->row, 'destination');
  $this
    ->assertEquals('Final Value', $value);
}