final class PreprocessModuleTest in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/preprocess_event_dispatcher/tests/src/Unit/PreprocessModuleTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\PreprocessModuleTest
Class PreprocessModuleTest.
@group preprocess_event_dispatcher
Hierarchy
- class \Drupal\Tests\preprocess_event_dispatcher\Unit\PreprocessModuleTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of PreprocessModuleTest
File
- modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ PreprocessModuleTest.php, line 16
Namespace
Drupal\Tests\preprocess_event_dispatcher\UnitView source
final class PreprocessModuleTest extends TestCase {
/**
* PreprocessEventService.
*
* @var \Drupal\preprocess_event_dispatcher\Service\PreprocessEventService|\Mockery\MockInterface
*/
private $service;
/**
* {@inheritdoc}
*/
public function setUp() : void {
$builder = new ContainerBuilder();
$this->service = Mockery::mock(PreprocessEventServiceInterface::class);
$builder
->set('preprocess_event.service', $this->service);
$builder
->compile();
Drupal::setContainer($builder);
}
/**
* Preprocess hook test.
*/
public function testPreprocessHook() : void {
$hook = $expectedHook = 'test';
$variables = [
'some' => 'variables',
];
$this->service
->expects('createAndDispatchKnownEvents')
->once()
->with($hook, $variables);
preprocess_event_dispatcher_preprocess($variables, $hook);
// Just test something so PHPUnit does not complain about no assertions,
// while Mockery asserts the service being called.
self::assertSame($expectedHook, $hook);
}
/**
* {@inheritdoc}
*/
public function tearDown() : void {
Mockery::close();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PreprocessModuleTest:: |
private | property | PreprocessEventService. | |
PreprocessModuleTest:: |
public | function | ||
PreprocessModuleTest:: |
public | function | ||
PreprocessModuleTest:: |
public | function | Preprocess hook test. |