class BlockDisplayVariantTest
Same name in this branch
- 8.x-3.x tests/src/Kernel/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Kernel\BlockDisplayVariantTest
Same name in other branches
- 4.0.x tests/src/Unit/BlockDisplayVariantTest.php \Drupal\Tests\ctools\Unit\BlockDisplayVariantTest
- 4.0.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, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
- 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 static 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 static | 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. | ||
UnitTestCase::$randomGenerator | protected | property | The random generator. | ||
UnitTestCase::$root | protected | property | The app root. | 1 | |
UnitTestCase::assertArrayEquals | Deprecated | protected | function | Asserts if two arrays are equal by sorting them first. | |
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::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | ||
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | ||
UnitTestCase::randomMachineName | public | function | Generates a unique random string containing letters and numbers. | ||
UnitTestCase::setUp | protected | function | 338 | ||
UnitTestCase::setUpBeforeClass | public static | function |