BlockDisplayVariantTest.php in Chaos Tool Suite (ctools) 8.3
File
tests/src/Kernel/BlockDisplayVariantTest.php
View source
<?php
namespace Drupal\Tests\ctools\Kernel;
use Drupal\ctools\Event\BlockVariantEvent;
use Drupal\ctools\Event\BlockVariantEvents;
use Drupal\ctools_block_display_test\Plugin\DisplayVariant\BlockDisplayVariant;
use Drupal\KernelTests\KernelTestBase;
use Prophecy\Argument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class BlockDisplayVariantTest extends KernelTestBase {
protected static $modules = [
'ctools',
'ctools_block_display_test',
'system',
'user',
];
public function testBlockDisplayVariantEvents() {
$event_dispatcher = $this
->prophesize(EventDispatcherInterface::class);
$this->container
->set('event_dispatcher', $event_dispatcher
->reveal());
$variant = BlockDisplayVariant::create($this->container, [], 'foobar', []);
$event = Argument::type(BlockVariantEvent::class);
$event_dispatcher
->dispatch(BlockVariantEvents::ADD_BLOCK, $event)
->shouldBeCalled();
$event_dispatcher
->dispatch(BlockVariantEvents::UPDATE_BLOCK, $event)
->shouldBeCalled();
$event_dispatcher
->dispatch(BlockVariantEvents::DELETE_BLOCK, $event)
->shouldBeCalled();
$block_id = $variant
->addBlock([
'id' => 'system_powered_by_block',
]);
$variant
->updateBlock($block_id, []);
$variant
->removeBlock($block_id);
}
}