Class CDbTestCase
CDbTestCase is the base class for test cases about DB-related features.
CDbTestCase provides database fixture management with the help of CDbFixtureManager
. By declaring CDbTestCase::$fixtures
property, one can ensure the
specified tables have the expected fixture state when executing each test
method. In addition, CDbTestCase provides two ways to access the fixture
data.
For example, assume we declare CDbTestCase::$fixtures
to be:
public $fixtures=array( 'posts' => 'Post', 'comments' => 'Comment', );
We can access the original fixture data rows using <span
class="php-var">$this</span>->posts
<span
class="php-var">$this</span>->posts[<span
class="php-quote">'first post'</span>]
. We can also retrieve an
ActiveRecord instance corresponding to a fixture data row using <span
class="php-var">$this</span>->posts(<span
class="php-quote">'first post'</span>)
. Note, here 'first post'
refers to a key to a row in the original fixture data.
- PHPUnit_Framework_TestCase
- CTestCase
- CDbTestCase
Package: system\test
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1
Located at x2engine/framework/test/CDbTestCase.php
public
mixed
|
|
public
mixed
|
|
public
|
|
public
array
|
|
public
|
|
protected
|
protected
array
|
$fixtures | false |
#
a list of fixtures that should be loaded before each test method executes. The array keys are fixture names, and the array values are either AR class names or table names. If table names, they must begin with a colon character (e.g. 'Post' means an AR class, while ':post' means a table name). Defaults to false, meaning fixtures will not be used at all. |