Skip to content

Commit

Permalink
Merge c21e9fa into 0b23f71
Browse files Browse the repository at this point in the history
  • Loading branch information
davedevelopment committed Feb 8, 2017
2 parents 0b23f71 + c21e9fa commit cffc0d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
21 changes: 16 additions & 5 deletions library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace Mockery\Adapter\Phpunit;

use Mockery;

/**
* Integrates Mockery into PHPUnit. Ensures Mockery expectations are verified
* for each test and are included by the assertion counter.
Expand All @@ -32,14 +34,23 @@ trait MockeryPHPUnitIntegration
*/
protected function assertPostConditions()
{
$this->addMockeryExpectationsToAssertionCount();
$this->closeMockery();

parent::assertPostConditions();
}

// Add Mockery expectations to assertion count.
if (($container = \Mockery::getContainer()) !== null) {
$this->addToAssertionCount($container->mockery_getExpectationCount());
protected function addMockeryExpectationsToAssertionCount()
{
$container = Mockery::getContainer();
if ($container != null) {
$count = $container->mockery_getExpectationCount();
$this->addToAssertionCount($count);
}
}

// Verify Mockery expectations.
\Mockery::close();
protected function closeMockery()
{
Mockery::close();
}
}
27 changes: 7 additions & 20 deletions library/Mockery/Adapter/Phpunit/MockeryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,16 @@

namespace Mockery\Adapter\Phpunit;

use Mockery;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;

abstract class MockeryTestCase extends \PHPUnit_Framework_TestCase
{
protected function assertPostConditions()
if (class_exists("PHPUnit_Framework_TestCase")) {
abstract class MockeryTestCase extends \PHPUnit_Framework_TestCase
{
$this->addMockeryExpectationsToAssertionCount();
$this->closeMockery();

parent::assertPostConditions();
use MockeryPHPUnitIntegration;
}

protected function addMockeryExpectationsToAssertionCount()
{
$container = Mockery::getContainer();
if ($container != null) {
$count = $container->mockery_getExpectationCount();
$this->addToAssertionCount($count);
}
}

protected function closeMockery()
} else {
abstract class MockeryTestCase extends \PHPUnit\Framework\TestCase
{
Mockery::close();
use MockeryPHPUnitIntegration;
}
}

0 comments on commit cffc0d9

Please sign in to comment.