Skip to content

Commit

Permalink
testExposeAllMethodsWillExposeAllMethods
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchance committed Dec 21, 2014
1 parent 8825f46 commit 45f191e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Concise/Mock/MockBuilder.php
Expand Up @@ -11,8 +11,6 @@
use ReflectionClass;
use Closure;
use Concise\Validation\ArgumentChecker;
use ReflectionException;
use ReflectionMethod;

class MockBuilder
{
Expand Down Expand Up @@ -516,6 +514,12 @@ public function getClassName()
*/
public function exposeAll()
{
$reflection = new ReflectionClass($this->className);
foreach ($reflection->getMethods() as $method) {
if (!$method->isFinal() && !$method->isPrivate()) {
$this->expose($method->getName());
}
}
return $this;
}
}
14 changes: 13 additions & 1 deletion tests/Concise/Mock/BuilderExposeTest.php
Expand Up @@ -82,8 +82,20 @@ public function testExposeTwoMethodsWithArraySyntax(MockBuilder $builder, $type)
* @group #189
* @dataProvider allBuilders
*/
public function testExposeAllCanBeChained(MockBuilder $builder)
public function testExposeAllCanBeChained(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$this->assert($builder->exposeAll(), is_the_same_as, $builder);
}

/**
* @group #189
* @dataProvider allBuilders
*/
public function testExposeAllMethodsWillExposeAllMethods(MockBuilder $builder, $type)
{
$this->youCannotExposeAMethodOnAMockThatIsNotNice($type);
$mock = $builder->exposeAll()->get();
$this->assert($mock->mySecretMethod(), equals, 'abc');
}
}

0 comments on commit 45f191e

Please sign in to comment.