BlockSettingsTest.php

Same filename in other branches
  1. 10 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php
  2. 11.x core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php

Namespace

Drupal\Tests\block\Unit\Plugin\migrate\process

File

core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php

View source
<?php

namespace Drupal\Tests\block\Unit\Plugin\migrate\process;

use Drupal\block\Plugin\migrate\process\BlockSettings;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockSettings
 * @group block
 */
class BlockSettingsTest extends UnitTestCase {
    
    /**
     * Tests the blocks settings process plugin.
     *
     * @param array $value
     *   The source value for the plugin.
     * @param array $expected
     *   The expected result.
     *
     * @covers ::transform
     *
     * @dataProvider providerTestTransform
     */
    public function testTransform($value, $expected) {
        $executable = $this->prophesize(MigrateExecutableInterface::class)
            ->reveal();
        if (empty($row)) {
            $row = $this->prophesize(Row::class)
                ->reveal();
        }
        $plugin = new BlockSettings([], 'block_settings', [], 'foo');
        $actual = $plugin->transform($value, $executable, $row, 'foo');
        $this->assertSame($expected, $actual);
    }
    
    /**
     * Provides data for testTransform.
     */
    public function providerTestTransform() {
        return [
            'title set' => [
                [
                    'custom',
                    0,
                    'foo',
                    'title',
                ],
                [
                    'label' => 'title',
                    'label_display' => 'visible',
                ],
            ],
            'title empty' => [
                [
                    'custom',
                    0,
                    'foo',
                    '',
                ],
                [
                    'label' => '',
                    'label_display' => '0',
                ],
            ],
            'title <none>' => [
                [
                    'custom',
                    0,
                    'foo',
                    '<none>',
                ],
                [
                    'label' => '<none>',
                    'label_display' => '0',
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
BlockSettingsTest @coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockSettings @group block

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