2012.5.1
>>>Unit Test:<<<
1. 编辑文件 protected/tests/WebTestCase.php 修改内容如下:
following code:
<?php
Yii::import('application.controllers.MessageController');
class MessageTest extends CTestCase
{
public function testRepeat()
{
$message = new MessageController('messageTest');
$yell = "Hello, Any One Out There?";
$returnedMessage = $message->repeat($yell);
$this->assertEquals($returnedMessage, $yell);
}
public function repeat($inputString)
{
return $inputString;
}
4. 执行
C:\xampp\yii\power\protected\tests> phpunit .\unit\MessageTest.php
>>>End of Unit Test<<<
>>>Unit Test:<<<
1. 编辑文件 protected/tests/WebTestCase.php 修改内容如下:
define('TEST_BASE_URL','http://localhost/yii/power/index-test.php/');
C:\xampp\yii\power\protected\tests> phpunit .\functional\SiteTest.php
following code:
<?php
Yii::import('application.controllers.MessageController');
class MessageTest extends CTestCase
{
public function testRepeat()
{
$message = new MessageController('messageTest');
$yell = "Hello, Any One Out There?";
$returnedMessage = $message->repeat($yell);
$this->assertEquals($returnedMessage, $yell);
}
}
public function repeat($inputString)
{
return $inputString;
}
4. 执行
C:\xampp\yii\power\protected\tests> phpunit .\unit\MessageTest.php
>>>End of Unit Test<<<