Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CDbFixtureManager
  • CDbTestCase
  • CTestCase
  • CWebTestCase
  • Overview
  • Package
  • Class
  • Tree

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
Extended by CTestCase
Extended by CDbTestCase
Abstract
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
Methods summary
public mixed
# __get( string $name )

PHP magic method. This method is overridden so that named fixture data can be accessed like a normal property.

PHP magic method. This method is overridden so that named fixture data can be accessed like a normal property.

Parameters

$name
string
$name the property name

Returns

mixed
the property value

Throws

Exception
if unknown property is used
public mixed
# __call( string $name, string $params )

PHP magic method. This method is overridden so that named fixture ActiveRecord instances can be accessed in terms of a method call.

PHP magic method. This method is overridden so that named fixture ActiveRecord instances can be accessed in terms of a method call.

Parameters

$name
string
$name method name
$params
string
$params method parameters

Returns

mixed
the property value

Throws

Exception
if unknown method is used
public CDbFixtureManager
# getFixtureManager( )

Returns

CDbFixtureManager
the database fixture manager
public array
# getFixtureData( string $name )

Parameters

$name
string
$name the fixture name (the key value in CDbTestCase::$fixtures).

Returns

array
the named fixture data
public CActiveRecord
# getFixtureRecord( string $name, string $alias )

Parameters

$name
string
$name the fixture name (the key value in CDbTestCase::$fixtures).
$alias
string
$alias the alias of the fixture data row

Returns

CActiveRecord
the ActiveRecord instance corresponding to the specified alias in the named fixture. False is returned if there is no such fixture or the record cannot be found.
protected
# setUp( )

Sets up the fixture before executing a test method. If you override this method, make sure the parent implementation is invoked. Otherwise, the database fixtures will not be managed properly.

Sets up the fixture before executing a test method. If you override this method, make sure the parent implementation is invoked. Otherwise, the database fixtures will not be managed properly.

Properties summary
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.

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.

API documentation generated by ApiGen 2.8.0