Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (45 sloc) 1.327 kB
61d96d5
qiang.xue authored
1 <?php
2
3 Yii::import('system.test.CTestCase');
4
dd334c0 refactored test framework.
qiang.xue authored
5 /**
6 * CDbTestCase is the base class for DB-related unit tests.
7 *
8 * CDbTestCase uses {@link CDbTestFixture} to manage DB fixtures and provies
9 * easy access to the fixtures.
10 */
ff3445c Added CWebTestCase.php.
qiang.xue authored
11 class CDbTestCase extends CTestCase
61d96d5
qiang.xue authored
12 {
dd334c0 refactored test framework.
qiang.xue authored
13 /**
14 * @var array a list of fixtures that should be loaded for all test cases.
15 * The array keys are fixture names, and the array values are either AR class names
16 * or table names. If table names, they must begin with a colon character (e.g. 'Post'
17 * means an AR class, while ':Post' means a table name).
18 */
19 public $fixtures=array();
20
61d96d5
qiang.xue authored
21 public function __get($name)
22 {
dd334c0 refactored test framework.
qiang.xue authored
23 if(($rows=$this->getFixtureManager()->getRows($name))!==false)
61d96d5
qiang.xue authored
24 return $rows;
25 else
26 throw new Exception("Unknown property '$name' for class '".get_class($this)."'.");
27 }
28
29 public function __call($name,$params)
30 {
dd334c0 refactored test framework.
qiang.xue authored
31 if(isset($params[0]) && ($record=$this->getFixtureManager()->getRecord($name,$params[0]))!==false)
32 return $record;
61d96d5
qiang.xue authored
33 else
34 throw new Exception("Unknown method '$name' for class '".get_class($this)."'.");
35 }
36
dd334c0 refactored test framework.
qiang.xue authored
37 public function getFixtureManager()
61d96d5
qiang.xue authored
38 {
39 return Yii::app()->getComponent('fixture');
40 }
41
42 public function fixtures()
43 {
44 return array();
45 }
46
47 public function setUp()
48 {
49 parent::setUp();
dd334c0 refactored test framework.
qiang.xue authored
50 $this->getFixtureManager()->load($this->fixtures());
61d96d5
qiang.xue authored
51 }
52 }
Something went wrong with that request. Please try again.