-
Hello guys! Current I’ve a problem with Yii, when I’d using “@group annotation” ( support by PHPUnit ) to test a groups function in my class extends from Yii.
-
I’d configured as guidance of forum Yii as below (sorry guys! because this’s first my post, so I don’t embed links here).
Configure project options:
Open "[b]File > Project properties > Sources[/b]" and set "[b]Test Folder[/b]" to [PROJECT ROOT]/protected/tests (If the whole project testing doesn't work, try [PROJECT ROOT]/protected/tests/unit).
Open "[b]File > Project properties > PHPUnit[/b]" and set "[b]Use Bootstrap[/b]" to [i][PROJECT ROOT]/protected/tests/bootstrap.php[/i], and "[b]Use XML Configuration[/b]" to [i][PROJECT ROOT]/protected/tests/phpunit.xml[/i].
-
I’d tested all functions in my class, when I press Ctrl + F6. It’s run very good.
-
When I check "Ask for Test Groups Before Running Tests" in the dialog box in "File > Project properties > PHPUnit".
-
But when I’d used “@group annotation”(support by PHPUnit). It not run, I don’t see the dialog box.
-
I thing this’s problem here are two file “bootstrap.php” and “phpunit.php”, but I don’t how alter it?.
-
Code below:
-
DemoController.php:
`class DemoController extends Controller{`
public function add($a, $<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />
{
return $a + $b;
}
`}`
- DemoControllerTest.php:
`require_once dirname(__FILE__) . '/../../../../fixtures/dataProvider.php';`
`require_once dirname(__FILE__) . '/../../../../controllers/DemoController.php';`
`class DemoControllerTest{`
protected $object;
protected function setUp() {
$this->object = new Calculator;
}
/**
* @group Calculator
*
* @dataProvider dataProvider
*/
public function testCalculator($c, $a, $<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' /> {
$this->assertEquals($c,
, $this->object->add($a, $<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />
);
}
function dataProvider(){
$result = dataProvider::dataProvider();
return $result;
}
.......
`}`
- dataProvider.php:
`class dataProvider {`
static function dataProvider(){
return array(
array(0, 0, 0),
array(0, 1, 1),
array(1, 0, 1),
array(1, 1, 3)
);
}
`}`