Skip to content

Commit

Permalink
Fix Builder Proxy (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitasGailius authored Mar 30, 2020
1 parent ae2ccf8 commit b48238f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ public function __call(string $method, array $parameters)
return static::$extensions[$method]($this);
}

if (method_exists($this->process(), $method)) {
return $this->process()->{$method}(...$parameters);
if (method_exists($process = $this->process(), $method)) {
return $process->{$method}(...$parameters);
}

throw new BadMethodCallException(sprintf(
Expand Down
16 changes: 16 additions & 0 deletions tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ public function testDataWithMissingBinding()
$this->assertEquals("Hello, \n", $process->getOutput());
}

/**
* Test that missing methods are passed to the Proccess instance.
*
* @return void
*/
public function testBuilderProxy()
{
$builder = $this->builderWithMockedProccess(function ($mock) {
$mock->shouldReceive('getPid')
->once()
->andReturn(123);
});

$this->assertEquals(123, $builder->getPid());
}

/**
* Create a new builder instance with a mocked process instance.
*
Expand Down

0 comments on commit b48238f

Please sign in to comment.