Created
March 14, 2012 17:40
-
-
Save brianium/2038141 to your computer and use it in GitHub Desktop.
mocking interfaces in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test\Unit\Domain\Repositories; | |
use Domain\Repositories; | |
use Domain\Entities\InputConfig; | |
use Infrastructure\Reflection\Reflection; | |
class IInputConfigRepositoryTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function setUp() { | |
$this->mock = $this->getMockBuilder('Domain\Repositories\IInputConfigRepository') | |
->disableOriginalConstructor() | |
->getMock(); | |
} | |
public function tearDown() { | |
$this->mock = null; | |
} | |
public function testFindMethod() { | |
$return = new InputConfig(); | |
Reflection::setProtectedVar($return,'input_num',1); | |
$this->mock->expects($this->any()) | |
->method('find') | |
->with($this->equalTo(1)) | |
->will($this->returnValue($return)); | |
$this->assertEquals(1,$this->mock->find(1)->getInputNum()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment