function FieldTypeDefaultsTest::testDefaults

Same name in this branch
  1. 9 core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest::testDefaults()
Same name in other branches
  1. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest::testDefaults()
  2. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldTypeDefaultsTest::testDefaults()
  3. 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest::testDefaults()
  4. 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldTypeDefaultsTest::testDefaults()
  5. 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest::testDefaults()
  6. 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldTypeDefaultsTest::testDefaults()

Tests various default cases.

@covers ::transform

File

core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php, line 29

Class

FieldTypeDefaultsTest
Tests D7 field formatter defaults.

Namespace

Drupal\Tests\field\Unit\Plugin\migrate\process\d7

Code

public function testDefaults() {
    // Assert common values are passed through without modification.
    $this->assertNull($this->plugin
        ->transform(NULL, $this->migrateExecutable, $this->row, 'property'));
    $this->assertEquals('string', $this->plugin
        ->transform('string', $this->migrateExecutable, $this->row, 'property'));
    $this->assertEquals(1234, $this->plugin
        ->transform(1234, $this->migrateExecutable, $this->row, 'property'));
    // Assert that an array will return the second item, which is the source
    // formatter type.
    $this->assertEquals('datetime_default', $this->plugin
        ->transform([
        'datetime',
        'datetime_default',
    ], $this->migrateExecutable, $this->row, 'property'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.