Created
December 21, 2012 14:28
-
-
Save anonymous/4353149 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 foo { | |
interface client | |
{ | |
public function execute($query, array $params); | |
} | |
class api | |
{ | |
protected $client; | |
public function __construct(client $client) | |
{ | |
$this->client = $client; | |
} | |
public function doSomething($query) | |
{ | |
$datas = $this->client->execute($query, array('foo' => 'bar')); | |
return true; | |
} | |
} | |
} | |
namespace tests\units\foo { | |
use mageekguy\atoum as atoum; | |
use foo\api as testedClass; | |
class api extends atoum\test | |
{ | |
public function testdoSomething() | |
{ | |
$this | |
->if($client = new \mock\foo\client()) | |
->and($client->getMockController()->execute = array(42)) | |
->and($api = new testedClass($client)) | |
->then | |
->boolean($api->doSomething('str'))->isTrue() | |
->mock($client) | |
->call('execute')->withArguments('some query')->once() | |
->boolean($api->doSomething('some query'))->isTrue() | |
; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment