class PanelsDisplayVariantTest in Panels 8.3
Same name and namespace in other branches
- 8.4 tests/src/Unit/PanelsDisplayVariantTest.php \Drupal\Tests\panels\Unit\PanelsDisplayVariantTest
@coversDefaultClass \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant @group Panels
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\panels\Unit\PanelsDisplayVariantTest
Expanded class hierarchy of PanelsDisplayVariantTest
File
- tests/
src/ Unit/ PanelsDisplayVariantTest.php, line 29 - Contains \Drupal\Tests\panels\Unit\PanelsDisplayVariantTest.
Namespace
Drupal\Tests\panels\UnitView source
class PanelsDisplayVariantTest extends UnitTestCase {
/**
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* @var \Drupal\Core\Plugin\Context\ContextHandlerInterface
*/
protected $contextHandler;
/**
* @var \Drupal\Component\Uuid\UuidInterface
*/
protected $uuidGenerator;
/**
* @var \Drupal\Core\Utility\Token
*/
protected $token;
/**
* @var \Drupal\Core\Condition\ConditionManager
*/
protected $conditionManager;
/**
* @var \Drupal\Core\Block\BlockManager
*/
protected $blockManager;
/**
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* @var \Drupal\panels\Plugin\DisplayBuilder\DisplayBuilderManagerInterface
*/
protected $builderManager;
/**
* @var \Drupal\layout_plugin\Plugin\Layout\LayoutPluginManagerInterface
*/
protected $layoutManager;
/**
* @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface
*/
protected $layout;
/**
* @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant
*/
protected $variant;
public function setUp() {
$this->account = $this
->prophesize(AccountInterface::class);
$this->contextHandler = $this
->prophesize(ContextHandlerInterface::class);
$this->uuidGenerator = $this
->prophesize(UuidInterface::class);
$this->token = $this
->prophesize(Token::class);
$this->blockManager = $this
->prophesize(BlockManager::class);
$this->conditionManager = $this
->prophesize(ConditionManager::class);
$this->moduleHandler = $this
->prophesize(ModuleHandlerInterface::class);
$this->builderManager = $this
->prophesize(DisplayBuilderManagerInterface::class);
$this->layoutManager = $this
->prophesize(LayoutPluginManagerInterface::class);
$this->layout = $this
->prophesize(LayoutInterface::class);
$this->layoutManager
->createInstance(Argument::type('string'), Argument::type('array'))
->willReturn($this->layout
->reveal());
$this->variant = new PanelsDisplayVariant([], '', [], $this->contextHandler
->reveal(), $this->account
->reveal(), $this->uuidGenerator
->reveal(), $this->token
->reveal(), $this->blockManager
->reveal(), $this->conditionManager
->reveal(), $this->moduleHandler
->reveal(), $this->builderManager
->reveal(), $this->layoutManager
->reveal());
}
/**
* @covers ::submitConfigurationForm
*/
public function testSubmitConfigurationForm() {
$values = [
'page_title' => "Go hang a salami, I'm a lasagna hog!",
];
$form = [];
$form_state = (new FormState())
->setValues($values);
$this->variant
->submitConfigurationForm($form, $form_state);
$configuration = $this->variant
->getConfiguration();
$this
->assertSame($values['page_title'], $configuration['page_title']);
}
/**
* @covers ::getLayout
*/
public function testGetLayout() {
$this
->assertSame($this->layout
->reveal(), $this->variant
->getLayout());
}
/**
* @covers ::getRegionNames
*/
public function testGetRegionNames() {
$region_names = [
'Foo',
'Bar',
'Baz',
];
$this->layout
->getPluginDefinition()
->willReturn([
'region_names' => $region_names,
]);
$this
->assertSame($region_names, $this->variant
->getRegionNames());
}
/**
* @covers ::access
*/
public function testAccessNoBlocksConfigured() {
$this
->assertFalse($this->variant
->access());
}
/**
* @covers ::defaultConfiguration
*/
public function testDefaultConfiguration() {
$defaults = $this->variant
->defaultConfiguration();
$this
->assertSame('', $defaults['layout']);
$this
->assertSame('', $defaults['page_title']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
protected | property | ||
PanelsDisplayVariantTest:: |
public | function |
Overrides UnitTestCase:: |
|
PanelsDisplayVariantTest:: |
public | function | @covers ::access | |
PanelsDisplayVariantTest:: |
public | function | @covers ::defaultConfiguration | |
PanelsDisplayVariantTest:: |
public | function | @covers ::getLayout | |
PanelsDisplayVariantTest:: |
public | function | @covers ::getRegionNames | |
PanelsDisplayVariantTest:: |
public | function | @covers ::submitConfigurationForm | |
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. |