function RowTest::testDestinationOrEmptyProperty
Tests checking for and removing destination properties that may be empty.
@covers ::hasEmptyDestinationProperty
@covers ::removeEmptyDestinationProperty
File
-
core/
modules/ migrate/ tests/ src/ Unit/ RowTest.php, line 300
Class
- RowTest
- @coversDefaultClass \Drupal\migrate\Row[[api-linebreak]] @group migrate
Namespace
Drupal\Tests\migrate\UnitCode
public function testDestinationOrEmptyProperty() : void {
$row = new Row($this->testValues, $this->testSourceIds);
// Set a destination.
$row->setDestinationProperty('nid', 2);
$this->assertTrue($row->hasDestinationProperty('nid'));
$this->assertFalse($row->hasEmptyDestinationProperty('nid'));
// Set an empty destination.
$row->setEmptyDestinationProperty('a_property_with_no_value');
$this->assertTrue($row->hasEmptyDestinationProperty('a_property_with_no_value'));
$this->assertFalse($row->hasDestinationProperty('a_property_with_no_value'));
// Removing an empty destination that is not actually empty has no effect.
$row->removeEmptyDestinationProperty('nid');
$this->assertTrue($row->hasDestinationProperty('nid'));
$this->assertFalse($row->hasEmptyDestinationProperty('nid'));
// Removing a destination that is actually empty has no effect.
$row->removeDestinationProperty('a_property_with_no_value');
$this->assertTrue($row->hasEmptyDestinationProperty('a_property_with_no_value'));
// Remove the empty destination.
$row->removeEmptyDestinationProperty('a_property_with_no_value');
$this->assertFalse($row->hasEmptyDestinationProperty('a_property_with_no_value'));
// Removing a destination that does not exist does not throw an error.
$this->assertFalse($row->hasEmptyDestinationProperty('not_a_property'));
$row->removeEmptyDestinationProperty('not_a_property');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.