4,251
社区成员
发帖
与我相关
我的任务
分享
<?php
class RemoteConnect
{
public function connectToServer($serverName=null)
{
if($serverName=='null'){
throw new Exception("That's not a server name!");
}
}
public function returnSampleObject()
{
$cc = 0;
return $dd = 'xxx';
}
}
?>
<?php
require_once('RemoteConnect.php');
class RemoteConnectTest extends PHPUnit_Framework_TestCase
{
public function testConnectionIsValid()
{
// test to ensure that the object from an fsockopen is valid
$connObj = new RemoteConnect();
$serverName = 'www.google.com';
$this->assertTrue($connObj->connectToServer($serverName) !== false);
$this->assertEquals($connObj->returnSampleObject()->$cc == 0);
}
}
?>