eb080c841010c8d6d96a93d6ad47b55e7502c649
[yaffs-website] / web / core / modules / field / tests / src / Unit / Plugin / migrate / process / d7 / FieldTypeDefaultsTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d7;
4
5 use Drupal\field\Plugin\migrate\process\d7\FieldTypeDefaults;
6 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
7
8 /**
9  * Tests D7 field formatter defaults.
10  *
11  * @coversDefaultClass \Drupal\field\Plugin\migrate\process\d7\FieldTypeDefaults
12  * @group field
13  */
14 class FieldTypeDefaultsTest extends MigrateProcessTestCase {
15
16   /**
17    * {@inheritdoc}
18    */
19   protected function setUp() {
20     parent::setUp();
21     $this->plugin = new FieldTypeDefaults([], 'd7_field_type_defaults', []);
22   }
23
24   /**
25    * Tests various default cases.
26    *
27    * @covers ::transform
28    */
29   public function testDefaults() {
30     // Assert common values are passed through without modification.
31     $this->assertNull($this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'property'));
32     $this->assertEquals('string', $this->plugin->transform('string', $this->migrateExecutable, $this->row, 'property'));
33     $this->assertEquals(1234, $this->plugin->transform(1234, $this->migrateExecutable, $this->row, 'property'));
34     // Assert that an array will return the second item, which is the source
35     // formatter type.
36     $this->assertEquals('datetime_default', $this->plugin->transform(['datetime', 'datetime_default'], $this->migrateExecutable, $this->row, 'property'));
37   }
38
39 }