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<<<
>>>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<<<
相关文章推荐
- Unit Test : rules,design and strategy
- The Definitive Guide to symfony | Chapter 15 - Unit And Functional Testing | symfony | Web PHP Framework
- Unit Test : rules,design and strategy
- Maven skip unit test and build to directory
- [iOS] block and async method unit test
- Android Unit test and UI test
- phpunit api PHPUnit_Extensions_OutputTestCase
- Advanced Unit Testing, Part IV - Fixture Setup/Teardown, Test Repetition And Performance Tests
- [c#] ASP.NET Refactor and Unit Test
- Installing PEAR and PHPUnit on WAMP
- Code Coverage and Unit Test in SonarQube
- Installing PEAR and PHPUnit on WAMP
- Database Unit Test and WCF Test
- phpunit and junit
- yaf 添加phpunittest
- potala(5)——Unit Test and Cache
- python中的单元测试pyUnit & what is unit test and why
- YII:执行单元测试时出现警告“PHP warning include(SiteTest: Firefox.php); faild to open stream”
- (转) Test Driven Development using Flash Builder 4 beta and FlexUnit
- [Study Note] TDD and Unit Test 20100401