Skip to content

Commit 9c60ae6

Browse files
committed
test: add valid drupal hookmap test
1 parent 48ddb11 commit 9c60ae6

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* Verify agent behavior on valid hookImplementationsMap */
8+
9+
namespace Drupal\Core\Extension {
10+
interface ModuleHandlerInterface
11+
{
12+
public function invokeAllWith($hook_str, $callback);
13+
}
14+
class ModuleHandler implements ModuleHandlerInterface
15+
{
16+
protected array $hookImplementationsMap = array(
17+
'hookname' => array('classname' => array('methodname' => 'modulename')),
18+
'hookname_b' => array('classname_b' => array('methodname_b' => 'modulename_b')),
19+
'hookname_c' => array('classname_c' => array('methodname_c' => 'modulename_c')),
20+
);
21+
22+
// to avoid editor warnings
23+
public function invokeAllWith($hook_str, $callback)
24+
{
25+
return null;
26+
}
27+
28+
// for debugging purposes
29+
public function dump()
30+
{
31+
var_dump($this->hookImplementationsMap);
32+
}
33+
}
34+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Verify agent behavior on valid hookImplementationsMap
9+
*/
10+
11+
/*INI
12+
newrelic.framework = drupal8
13+
*/
14+
15+
/*EXPECT_TRACED_ERRORS null */
16+
17+
/*EXPECT_ERROR_EVENTS null */
18+
19+
/*EXPECT
20+
*/
21+
22+
require_once __DIR__ . '/mock_module_handler_valid.php';
23+
24+
// This specific API is needed for us to instrument the ModuleHandler
25+
class Drupal
26+
{
27+
public function moduleHandler()
28+
{
29+
return new Drupal\Core\Extension\ModuleHandler();
30+
}
31+
}
32+
33+
// Create module handler
34+
$drupal = new Drupal();
35+
$handler = $drupal->moduleHandler();

0 commit comments

Comments
 (0)