You are here

class ModuleStub in Authenticated User Page Caching (Authcache) 7.2

Helper class representing a stub-module.

Hierarchy

Expanded class hierarchy of ModuleStub

File

tests/HookStub.inc, line 10
Defines some helper classes for stubbing and recording hook invocations.

View source
class ModuleStub {
  protected $name;

  /**
   * Construct a new module stub-helper.
   *
   * @param string $name
   *   The name of an existing stub-module, e.g., mymodule_test
   */
  public function __construct($name) {
    $this->name = $name;
  }

  /**
   * Install a stub for a hook-implementation.
   *
   * @param string $hookname
   *   The name of the hook (without the module prefix). E.g. form_alter, if
   *   the stub-module has an implementation of hook_form_alter.
   *
   * @param any $return
   *   The result which should be returned when the hook is invoked.
   *
   * @return HookStubProxy
   *   A proxy object representing the stubbed hook.
   */
  public function hook($hookname, $return = NULL) {
    return HookStub::on($this->name . '_' . $hookname, $return);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ModuleStub::$name protected property
ModuleStub::hook public function Install a stub for a hook-implementation.
ModuleStub::__construct public function Construct a new module stub-helper.