Created
August 9, 2011 03:57
-
-
Save fivestar/1133376 to your computer and use it in GitHub Desktop.
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 | |
class Client | |
{ | |
public function load($file) { | |
return $this->getContents($file); | |
} | |
protected function getContents($file) | |
{ | |
return file_get_contents($file); | |
} | |
} |
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 | |
require __DIR__.'/../Client.php'; | |
class ClientTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testLoad() | |
{ | |
$client = $this->getClientMock(); | |
$this->assertEquals('Hello, yudoufu', $client->load('http://yudoufu.com/test')); | |
} | |
protected function getClientMock() | |
{ | |
$client = $this->getMock('Client', array('getContents')); | |
$client->expects($this->any()) | |
->method('getContents') | |
->will($this->returnValue('Hello, yudoufu')) | |
; | |
return $client; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment