Example #1
0
 /**
  * Modifies the event handler to include an expectation of an event NOT
  * being added by the plugin being tested. Note that this must be called
  * BEFORE executing plugin code that may initiate the event.
  *
  * @param string $type Event type
  * @param array  $args Optional enumerated array of event arguments
  *
  * @return void
  */
 protected function assertDoesNotEmitEvent($type, array $args = array())
 {
     // Ugly hack to get around an issue in PHPUnit
     // @link http://github.com/sebastianbergmann/phpunit-mock-objects/issues/issue/5#issue/5/comment/343524
     $callback = create_function('$plugin, $type, $args', 'if (get_class($plugin) == "' . $this->pluginClass . '"
         && $type == "' . $type . '"
         && $args == "' . var_export($args, true) . '") {
             trigger_error("Instance of ' . $this->pluginClass . ' unexpectedly emitted event of type ' . $type . '", E_USER_ERROR);
         }');
     $this->events->expects($this->any())->method('addEvent')->will($this->returnCallback($callback));
 }