Skip to content

Commit

Permalink
Properly test strategy build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhayon committed Aug 4, 2017
1 parent 6f3b103 commit a048e27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Moka/Tests/MokaMockingStrategyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class MokaMockingStrategyTestCase extends TestCase
{
const FQCN_EMPTY = '';
const FQCN_INVALID = 'Foo Bar';
const FQCN_NONEXISTENT_TEMPLATE = 'Foo_%s';
const FQCN_NONEXISTENT_TEMPLATE = 'Foo_%d';

/**
* @var MockingStrategyInterface
Expand Down
1 change: 1 addition & 0 deletions tests/Strategy/IncompleteMockingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class IncompleteMockingStrategy extends AbstractMockingStrategy

protected function doBuild(string $fqcn)
{
throw new \Exception();
}

protected function doDecorateWithMethod($mock, MethodStub $stub)
Expand Down
10 changes: 9 additions & 1 deletion tests/Strategy/MockingStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Tests\Strategy;

use Moka\Exception\MissingDependencyException;
use Moka\Exception\MockNotCreatedException;
use Moka\Exception\NotImplementedException;
use PHPUnit\Framework\TestCase;

Expand All @@ -24,12 +25,19 @@ public function testGetMockTypeFailure()
$strategy->getMockType();
}

public function testBuildFailure()
{
$strategy = new BareMockingStrategy();

$this->expectException(MockNotCreatedException::class);
$strategy->build(\stdClass::class);
}

public function testCallFailure()
{
$strategy = new BareMockingStrategy();

$this->expectException(\Error::class);

$strategy->call(new \stdClass(), 'foo');
}
}

0 comments on commit a048e27

Please sign in to comment.