Skip to content

Commit e9b4a48

Browse files
committed
finalizing joindin unit testing
1 parent 3217d0f commit e9b4a48

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

application/data/db/zftest-test.db

0 Bytes
Binary file not shown.

tests/library/Zftest/Service/JoindinTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ class Zftest_Service_JoindinTest extends PHPUnit_Framework_TestCase
77
protected function setUp()
88
{
99
$this->_joindin = new Zftest_Service_Joindin();
10+
// using the test adapter for testing
11+
$client = new Zend_Http_Client();
12+
$client->setAdapter(new Zend_Http_Client_Adapter_Test());
13+
$this->_joindin->setClient($client);
14+
1015
$settings = simplexml_load_file(realpath(
1116
APPLICATION_PATH . '/../tests/_files/settings.xml'));
1217
$this->_settings = $settings->joindin;
@@ -19,6 +24,21 @@ protected function tearDown()
1924
}
2025
public function testJoindinCanGetUserDetails()
2126
{
27+
$response = <<<EOS
28+
HTTP/1.1 200 OK
29+
Content-type: text/xml
30+
31+
<?xml version="1.0"?>
32+
<response>
33+
<item>
34+
<username>DragonBe</username>
35+
<full_name>Michelangelo van Dam</full_name>
36+
<ID>19</ID>
37+
<last_login>1303248639</last_login>
38+
</item>
39+
</response>
40+
EOS;
41+
$client = $this->_joindin->getClient()->getAdapter()->setResponse($response);
2242
$expected = '<?xml version="1.0"?><response><item><username>DragonBe</username><full_name>Michelangelo van Dam</full_name><ID>19</ID><last_login>1303248639</last_login></item></response>';
2343
$this->_joindin->setUsername($this->_settings->username)
2444
->setPassword($this->_settings->password);
@@ -29,6 +49,17 @@ public function testJoindinCanCheckStatus()
2949
{
3050
$date = new DateTime();
3151
$date->setTimezone(new DateTimeZone('UTC'));
52+
$response = <<<EOS
53+
HTTP/1.1 200 OK
54+
Content-type: text/xml
55+
56+
<?xml version="1.0"?>
57+
<response>
58+
<dt>{$date->format('r')}</dt>
59+
<test_string>testing unit test</test_string>
60+
</response>
61+
EOS;
62+
$client = $this->_joindin->getClient()->getAdapter()->setResponse($response);
3263
$expected = '<?xml version="1.0"?><response><dt>' . $date->format('r') . '</dt><test_string>testing unit test</test_string></response>';
3364
$actual = $this->_joindin->site()->getStatus('testing unit test');
3465
$this->assertXmlStringEqualsXmlString($expected, $actual);

0 commit comments

Comments
 (0)