class BlockDisplayVariantTest
Same name in this branch
- 4.0.x tests/src/Kernel/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Kernel\BlockDisplayVariantTest
Same name in other branches
- 8.x-3.x tests/src/Unit/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Unit\BlockDisplayVariantTest
- 8.x-3.x 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 \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\ctools\Unit\BlockDisplayVariantTest extends \Drupal\Tests\UnitTestCase uses \Prophecy\PhpUnit\ProphecyTrait
Expanded class hierarchy of BlockDisplayVariantTest
File
-
tests/
src/ Unit/ BlockDisplayVariantTest.php, line 23
Namespace
Drupal\Tests\ctools\UnitView source
class BlockDisplayVariantTest extends UnitTestCase {
use ProphecyTrait;
/**
* 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
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|---|
BlockDisplayVariantTest::providerTestSubmitConfigurationForm | public | function | Provides data for testSubmitConfigurationForm(). | ||
BlockDisplayVariantTest::testSubmitConfigurationForm | public | function | Tests the submitConfigurationForm() method. | ||
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | ||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | ||
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | ||
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | ||
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | ||
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | ||
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. | |
UnitTestCase::$root | protected | property | The app root. | 1 | |
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | ||
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | ||
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | ||
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | ||
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | ||
UnitTestCase::setUp | protected | function | 358 | ||
UnitTestCase::setUpBeforeClass | public static | function | |||
UnitTestCase::__get | public | function |