I have a problem accessing fixtures in my app. I have a table called settings, and my tests directory is set up like this;
tests/
fixtures/
settings.php
unit/
SettingsTest.php
(other files and directories omitted for simplicity)
tests/fixtures/settings.php
return array(
'theme'=>array(
'name'=>'theme',
'value'=>'default',
),
'remember_me_duration'=>array(
'name'=>'remember_me_duration',
'value'=>'2592000',
),
'mail_transport_type'=>array(
'name'=>'mail_transport_type',
'value'=>'smtp',
),
);
tests/fixtures/SettingsTest.php
class SettingsTest extends CDbTestCase
{
protected $object;
public $fixtures = array(
'settings'=>'settings'
);
protected function setUp()
{
$this->object = new Settings;
}
public function testFixtures()
{
$this->settings['theme']['value'];
}
}
Please correct me if I am wrong but this is what I expect to happen when I run phpunit on SettingsTest.php…
The settings table in my database gets cleared and replaced with the default data as specified in my fixture file, then I expect the string ‘default’ to be outputed to the screen. Instead, phpunit throws the error
Unknown property 'settings' for class 'SettingsTest'
...framework/test/CDbTestCase.php:61
Where am I going wrong with this?