defineFunction() public méthode

Defines the mock function.
public defineFunction ( )
Exemple #1
0
 /**
  * Defines the mocked function in the given namespace.
  *
  * In most cases you don't have to call this method. enable() is doing this
  * for you. But if the mock is defined after the first call in the
  * tested class, the tested class doesn't resolve to the mock. This is
  * documented in Bug #68541. You therefore have to define the namespaced
  * function before the first call. Defining the function has no side
  * effects as you still have to enable the mock. If the function was
  * already defined this method does nothing.
  *
  * @see enable()
  * @link https://bugs.php.net/bug.php?id=68541 Bug #68541
  */
 public function define()
 {
     $fqfn = $this->getFQFN();
     if (function_exists($fqfn)) {
         return;
     }
     $functionGenerator = new MockFunctionGenerator($this);
     $functionGenerator->defineFunction();
 }