phpmock\MockBuilder::setFunctionProvider PHP Method

setFunctionProvider() public method

Use this method if you want to set the mocked behaviour with a {@link FunctionProvider}. Alternatively, you can use {@link setFunction()} to set it with a callable.
See also: setFunction()
public setFunctionProvider ( phpmock\functions\FunctionProvider $provider ) : MockBuilder
$provider phpmock\functions\FunctionProvider The mock function provider.
return MockBuilder
    public function setFunctionProvider(FunctionProvider $provider)
    {
        return $this->setFunction($provider->getCallable());
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Tests build().
  *
  * @test
  */
 public function testBuild()
 {
     $builder = new MockBuilder();
     $builder->setNamespace(__NAMESPACE__)->setName("time")->setFunction(function () {
         return 1234;
     });
     $mock = $builder->build();
     $mock->enable();
     $this->assertEquals(1234, time());
     $mock->disable();
     $builder->setFunctionProvider(new FixedValueFunction(123));
     $mock = $builder->build();
     $mock->enable();
     $this->assertEquals(123, time());
     $mock->disable();
 }
All Usage Examples Of phpmock\MockBuilder::setFunctionProvider