class LegacyHookTest
Tests the LegacyHook attribute.
@group Hook
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait
- class \Drupal\Tests\system\Functional\Extension\LegacyHookTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of LegacyHookTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Extension/ LegacyHookTest.php, line 14
Namespace
Drupal\Tests\system\Functional\ExtensionView source
class LegacyHookTest extends BrowserTestBase {
protected static $modules = [
'legacy_hook_test',
];
protected $defaultTheme = 'stark';
public function testLegacyHook() : void {
// Calling legacy_hook_test1 leads to a fatal error so there's no need
// for asserts to show it does not get called.
\Drupal::moduleHandler()->invokeAll('test1');
// Verify the module actually exists and works even with one LegacyHook.
$result = \Drupal::moduleHandler()->invokeAll('test2');
$this->assertSame([
'ok',
], $result);
\Drupal::moduleHandler()->invoke('legacy_hook_test', 'test1');
$result = \Drupal::moduleHandler()->invoke('legacy_hook_test', 'test2');
$this->assertSame('ok', $result);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.