class BlockDisplayVariantTest in Chaos Tool Suite (ctools) 8.3
Same name in this branch
- 8.3 tests/src/Unit/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Unit\BlockDisplayVariantTest
- 8.3 tests/src/Kernel/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Kernel\BlockDisplayVariantTest
Tests the block display variant plugin.
@coversDefaultClass \Drupal\ctools\Plugin\DisplayVariant\BlockDisplayVariant
@group CTools
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\ctools\Unit\BlockDisplayVariantTest
Expanded class hierarchy of BlockDisplayVariantTest
File
- tests/
src/ Unit/ BlockDisplayVariantTest.php, line 22
Namespace
Drupal\Tests\ctools\UnitView source
class BlockDisplayVariantTest extends UnitTestCase {
/**
* Tests the submitConfigurationForm() method.
*
* @covers ::submitConfigurationForm
*
* @dataProvider providerTestSubmitConfigurationForm
*/
public function testSubmitConfigurationForm($values) {
$account = $this
->prophesize(AccountInterface::class);
$context_handler = $this
->prophesize(ContextHandlerInterface::class);
$uuid_generator = $this
->prophesize(UuidInterface::class);
$token = $this
->prophesize(Token::class);
$block_manager = $this
->prophesize(BlockManager::class);
$condition_manager = $this
->prophesize(ConditionManager::class);
$display_variant = new class([], '', [], $context_handler
->reveal(), $account
->reveal(), $uuid_generator
->reveal(), $token
->reveal(), $block_manager
->reveal(), $condition_manager
->reveal()) extends BlockDisplayVariant {
/**
* {@inheritdoc}
*/
public function build() {
return [];
}
public function getRegionNames() {
return [
'top' => 'Top',
'bottom' => 'Bottom',
];
}
};
$form = [];
$form_state = (new FormState())
->setValues($values);
$display_variant
->submitConfigurationForm($form, $form_state);
$this
->assertSame($values['label'], $display_variant
->label());
}
/**
* Provides data for testSubmitConfigurationForm().
*/
public function providerTestSubmitConfigurationForm() {
$data = [];
$data[] = [
[
'label' => 'test_label1',
],
];
$data[] = [
[
'label' => 'test_label2',
'blocks' => [
'foo1' => [],
],
],
];
$data[] = [
[
'label' => 'test_label3',
'blocks' => [
'foo1' => [],
'foo2' => [],
],
],
];
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockDisplayVariantTest:: |
public | function | Provides data for testSubmitConfigurationForm(). | |
BlockDisplayVariantTest:: |
public | function | Tests the submitConfigurationForm() method. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |