Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created March 23, 2009 15:56
Show Gist options
  • Save sasezaki/83616 to your computer and use it in GitHub Desktop.
Save sasezaki/83616 to your computer and use it in GitHub Desktop.
<?php
require_once 'PHPUnit/Framework.php';
require_once 'Hanako.php';
/**
* Test class for Services_Hanako.
* Generated by PHPUnit on 2009-03-21 at 20:12:07.
*/
class Www_Kankyosho_HanakoTest extends PHPUnit_Framework_TestCase
{
/**
* @var Services_Hanako
* @access protected
*/
protected $object;
/**
array(7) {
["hour"]=>
string(5) "20時"
["pollen"]=>
string(2) "36"
["wd"]=>
string(9) "南南東"
["ws"]=>
string(1) "1"
["temp"]=>
string(3) "9.9"
["prec"]=>
string(1) "0"
["prec_bool"]=>
string(6) "無し"
}
*/
//20時の結果
private $kekka = array (
'hour' => '20時',
'pollen' => '36',
'wd' => '南南東',
'ws' => '1',
'temp' => '9.9',
'prec' => '0',
'prec_bool' => '無し',
);
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->object = new Www_Kankyosho_Hanako('03', '50810100');
}
public function testParseDescription()
{
$deschtml = file_get_contents(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/files/Hyou2.aspx.html');
$this->object->parseDescription($deschtml);
$parse = $this->object->now();
$this->assertEquals($parse, $this->kekka);
}
public function testSetHttpRequest()
{
require_once 'HTTP/Request2.php';
require_once 'HTTP/Request2/Adapter/Mock.php';
$deschtml = file_get_contents(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/files/Hyou2.aspx.html');
require_once 'Zend/Http/Cookie.php';
$cookie = (string) Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; '.'path=/;');
$responseHeader200 = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n".
"Set-Cookie: $cookie";
$responseStr = "$responseHeader200\r\n\r\n$deschtml";
$mock = new HTTP_Request2_Adapter_Mock();
$mock->addResponse($responseStr);
$mock->addResponse($responseStr);
$req2 = new HTTP_Request2();
$req2->setAdapter($mock);
$this->object->setHttpRequest($req2);
$this->assertEquals($this->kekka, $this->object->now());
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment