您的位置:首页 > 编程语言 > PHP开发

Yii and PHP Unit test

2012-05-01 01:48 489 查看
2012.5.1

>>>Unit Test:<<<

1. 编辑文件 protected/tests/WebTestCase.php 修改内容如下:

define('TEST_BASE_URL','http://localhost/yii/power/index-test.php/');

2. 执行

C:\xampp\yii\power\protected\tests> phpunit .\functional\SiteTest.php

3. Create the new file, protected/tests/unit/MessageTest.php and add to it the

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);

}

}

Add the following method to the MessageController class:

public function repeat($inputString)

{

return $inputString;

}

4. 执行

C:\xampp\yii\power\protected\tests> phpunit .\unit\MessageTest.php

>>>End of Unit Test<<<
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: