FieldTypeDefaultsTest.php

Same filename in this branch
  1. 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
Same filename and directory in other branches
  1. 9 core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
  2. 9 core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php
  3. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/FieldTypeDefaultsTest.php
  4. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
  5. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php
  6. 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
  7. 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldTypeDefaultsTest.php

Namespace

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

File

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

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d7;

use Drupal\field\Plugin\migrate\process\d7\FieldTypeDefaults;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;

/**
 * Tests D7 field formatter defaults.
 *
 * @coversDefaultClass \Drupal\field\Plugin\migrate\process\d7\FieldTypeDefaults
 * @group field
 */
class FieldTypeDefaultsTest extends MigrateProcessTestCase {
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->plugin = new FieldTypeDefaults([], 'd7_field_type_defaults', []);
    }
    
    /**
     * Tests various default cases.
     *
     * @covers ::transform
     */
    public function testDefaults() : void {
        // 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'));
    }

}

Classes

Title Deprecated Summary
FieldTypeDefaultsTest Tests D7 field formatter defaults.

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