【发布时间】:2012-05-17 01:35:34
【问题描述】:
所以我开始使用 PHPUnit 来测试我的程序。
我遇到了这个问题,当我尝试测试一个程序将控制网页是否存在时出现错误。
代码:
<?php
class RemoteConnect
{
public function connectToServer($serverName=null)
{
if($serverName==null){
throw new Exception("That's not a server name!");
}
$fp = fsockopen($serverName,80);
return ($fp) ? true : false;
}
public function returnSampleObject()
{
return $this;
}
}
?>
以及它的测试代码:
<?php
require_once('RemoteConnect.php');
class RemoteConnectTest extends PHPUnit_Framework_TestCase
{
public function setUp(){ }
public function tearDown(){ }
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);
}
}
?>
它们在同一个目录下名为:PHPUnit inside the www (C:\wamp\www\PHPUnit)
但我不明白为什么我会收到错误(致命错误:第 5 行的 C:\wamp\www\PHPUnit\RemoteConnectTest.php 中找不到类 'PHPUnit_Framework_TestCase')
我的PHPUnit包路径是(C:\wamp\bin\php\php5.3.10\pear\PHPUnit)
我尝试制作一个程序 MailSender,它发送一封邮件,其中包含文本内容,这只是为了使用 PEAR。它成功了,但我不明白为什么这不起作用。
问候 亚历克斯
【问题讨论】:
-
我大约 1 小时后回来,很快!
-
谢谢你告诉我,我以为其他人会为我这样做,谢谢!!
标签: php phpunit pear fatal-error testcase