Skip to content

Commit

Permalink
Merge pull request #380 from davedevelopment/mockery-test-case
Browse files Browse the repository at this point in the history
Mockery test case
  • Loading branch information
davedevelopment committed Oct 7, 2014
2 parents aab7d1c + 3a60e44 commit a0a8d0e
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 0.9.3 (XXXX-XX-XX)

* Added a basic spy implementation
* Added `Mockery\Adapter\Phpunit\MockeryTestCase` for more reliable PHPUnit
integration

## 0.9.2 (2014-09-03)

Expand Down
30 changes: 30 additions & 0 deletions library/Mockery/Adapter/Phpunit/MockeryTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Mockery\Adapter\Phpunit;

use Mockery;

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

parent::assertPostConditions();
}

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

protected function closeMockery()
{
Mockery::close();
}
}
4 changes: 3 additions & 1 deletion tests/Mockery/AdhocTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

use Mockery\Adapter\Phpunit\MockeryTestCase;

/**
* Ad-hoc unit tests for various scenarios reported by users
*/
class Mockery_AdhocTest extends PHPUnit_Framework_TestCase
class Mockery_AdhocTest extends MockeryTestCase
{

public function setup()
Expand Down
3 changes: 2 additions & 1 deletion tests/Mockery/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/

use Mockery\Generator\MockConfigurationBuilder;
use Mockery\Adapter\Phpunit\MockeryTestCase;

class ContainerTest extends PHPUnit_Framework_TestCase
class ContainerTest extends MockeryTestCase
{

/** @var Mockery\Container */
Expand Down
3 changes: 2 additions & 1 deletion tests/Mockery/DemeterChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

use Mockery\Adapter\Phpunit\MockeryTestCase;

class DemeterChainTest extends \PHPUnit_Framework_TestCase
class DemeterChainTest extends MockeryTestCase
{
/** @var Mockery\Mock $this->mock */
private $mock;
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/ExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

class ExpectationTest extends PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class ExpectationTest extends MockeryTestCase
{

public function setup()
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/HamcrestExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

class HamcrestExpectationTest extends PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class HamcrestExpectationTest extends MockeryTestCase
{

public function setUp()
Expand Down
4 changes: 2 additions & 2 deletions tests/Mockery/MockClassWithFinalWakeupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

namespace test\Mockery;

use \PHPUnit_Framework_TestCase as TestCase;
use Mockery\Adapter\Phpunit\MockeryTestCase;

class MockClassWithFinalWakeupTest extends TestCase
class MockClassWithFinalWakeupTest extends MockeryTestCase
{

protected function setUp()
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/MockClassWithUnknownTypeHintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

namespace test\Mockery;

class MockClassWithUnknownTypeHintTest extends \PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class MockClassWithUnknownTypeHintTest extends MockeryTestCase
{
protected function setUp()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Mockery/MockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

/**
*/
class Mockery_MockTest extends PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class Mockery_MockTest extends MockeryTestCase
{

public function setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

class GeneratorTest extends \PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class GeneratorTest extends MockeryTestCase
{
/** @test */
public function shouldNotDuplicateDoublyInheritedMethods()
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/MockingProtectedMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

namespace test\Mockery;

class MockingProtectedMethodsTest extends \PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class MockingProtectedMethodsTest extends MockeryTestCase
{

public function setup()
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/NamedMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

class NamedMockTest extends PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class NamedMockTest extends MockeryTestCase
{
/** @test */
public function itCreatesANamedMock()
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/RecorderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

class RecorderTest extends PHPUnit_Framework_TestCase
use Mockery\Adapter\Phpunit\MockeryTestCase;

class RecorderTest extends MockeryTestCase
{

public function setup()
Expand Down

0 comments on commit a0a8d0e

Please sign in to comment.