phpunit测试fixtures问题

按照Agile Web Application Development with Yii 1.1 and PHP5书中的测试fixtures方法。

开始很正常,但是后来不知道做了什么修改,然后就提示这样的:

  1. CourseTest::testGetTeacher

Invalid argument supplied for foreach()

/var/www/yii-1.1.6.r2877/framework/test/CDbFixtureManager.php:168

/var/www/yii-1.1.6.r2877/framework/test/CDbFixtureManager.php:122

/var/www/yii-1.1.6.r2877/framework/test/CDbFixtureManager.php:85

/var/www/yii-1.1.6.r2877/framework/base/CModule.php:372

/var/www/yii-1.1.6.r2877/framework/test/CDbTestCase.php:84

/var/www/yii-1.1.6.r2877/framework/test/CDbTestCase.php:116

yii版本1.1.6

php5.3

phpunit 3.5

Did you figure out what was the issue with this ?

I’m seeing the same problem when changing from CTestCase to CDbTestCase and including some fixtures that work in other tests.

Curiously enough some of the failing tests don’t even use the fixtures but static data … :(




1) IssueTest::testGetTypes Invalid argument supplied for foreach()

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/db/schema/CDbCommandBuilder.php:191

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/test/CDbFixtureManager.php:170

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/test/CDbFixtureManager.php:122

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/test/CDbFixtureManager.php:85

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/base/CModule.php:372

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/test/CDbTestCase.php:84

/Users/sergcont/Desktop/MAMP_ROOT/yii-1.1.6/framework/test/CDbTestCase.php:116



cheers,

Ok in case someone confronts similar issue, in my case it was due to a syntax error on my fixture :huh:




<?php


return array(

	'issueBug', array(

		'name'=>'Test Issue',

		'description'=>'Test issue description',

		'project_id'=>'1',

		'type_id'=>'2',

		'status_id'=>'1',

		'owner_id'=>'1',

		'requester_id'=>'2',

		'create_time'=>'',

		'create_user_id'=>'1',

		'update_time'=>'',

		'update_user_id'=>'1',

		)

	);  



where ‘issueBug’, array( should be ‘issueBug’=> array(

It is really a pity that I forgot what I had done to make it right.

I will try to recall it… :huh: