You are here

public function MigrateExecutableTest::testImportWithValidRowNoDestinationValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testImportWithValidRowNoDestinationValues()

Tests the import method with a valid row.

File

core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php, line 172
Contains \Drupal\Tests\migrate\Unit\MigrateExecutableTest.

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\Tests\migrate\Unit\MigrateExecutableTest @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testImportWithValidRowNoDestinationValues() {
  $source = $this
    ->getMockSource();
  $row = $this
    ->getMockBuilder('Drupal\\migrate\\Row')
    ->disableOriginalConstructor()
    ->getMock();
  $row
    ->expects($this
    ->once())
    ->method('getSourceIdValues')
    ->will($this
    ->returnValue(array(
    'id' => 'test',
  )));
  $source
    ->expects($this
    ->once())
    ->method('current')
    ->will($this
    ->returnValue($row));
  $this->executable
    ->setSource($source);
  $this->migration
    ->expects($this
    ->once())
    ->method('getProcessPlugins')
    ->will($this
    ->returnValue(array()));
  $destination = $this
    ->getMock('Drupal\\migrate\\Plugin\\MigrateDestinationInterface');
  $destination
    ->expects($this
    ->once())
    ->method('import')
    ->with($row, array(
    'test',
  ))
    ->will($this
    ->returnValue(array()));
  $this->migration
    ->expects($this
    ->once())
    ->method('getDestinationPlugin')
    ->will($this
    ->returnValue($destination));
  $this->idMap
    ->expects($this
    ->once())
    ->method('saveIdMapping')
    ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL);
  $this->idMap
    ->expects($this
    ->once())
    ->method('messageCount')
    ->will($this
    ->returnValue(0));
  $this->idMap
    ->expects($this
    ->once())
    ->method('saveMessage');
  $this->idMap
    ->expects($this
    ->once())
    ->method('lookupDestinationId')
    ->with(array(
    'id' => 'test',
  ))
    ->will($this
    ->returnValue(array(
    'test',
  )));
  $this->message
    ->expects($this
    ->once())
    ->method('display')
    ->with('New object was not saved, no error provided');
  $this
    ->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable
    ->import());
}