-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathZenTest.php
43 lines (38 loc) · 1.29 KB
/
ZenTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
class ZenTest extends LocalWebTestCase
{
// Use dependency injection to mock the Curl object.
public function testCanFetchZenFromGitHub()
{
$expected = 'Never sniff a gift fish.';
$curl = $this->getMock('\Curl');
$curl->expects($this->any())
->method('get')
->will($this->returnValue((object) array(
'headers' => array('Status-Code' => 200),
'body' => $expected
)));
$this->app->curl = function ($c) use ($curl) {
return $curl;
};
$this->client->get('/zen');
$this->assertEquals(200, $this->client->response->status());
$this->assertEquals($expected, $this->client->response->body());
}
public function testZenResponseWhenGitHubFails()
{
$curl = $this->getMock('\Curl');
$curl->expects($this->any())
->method('get')
->will($this->returnValue((object) array(
'headers' => array('Status-Code' => 503),
'body' => ''
)));
$this->app->curl = function ($c) use ($curl) {
return $curl;
};
$this->client->get('/zen');
$this->assertEquals(502, $this->client->response->status());
}
}
/* End of file ZenTest.php */