CDbTestCase fixtures format #1936

Closed
Ragazzo opened this Issue Jan 8, 2013 · 5 comments

2 participants

@Ragazzo

i thought may be it will be good to make $fixtures property in this way:

$fixtures => array(
    'path/to/fixture' => ':test',
);

In this way it is simple to point to the fixtures path, i know that i can use fixtures manager property basePath and set it in setUpBeforeClass(), but i think that this property can be also converted in array() at future for more flexible fixtures managing. So suggestion for now is that key in this array can point to the fixtures path, so the fixture file name is the last one after /, what do u think? Not hard to implement i think, just some refactoring in fixtures manager on loadFixture method. And if the value of the fixture is model class name then i think need to detect if it is in namespace, so '/path/to/test/model/Test', would be good to pass this one in fixture value, because i have my models in namespaces, or may be i am wrong and there is a way to test fixtures in namespaces in correct way, without this modifying suggestions?

@Ragazzo

I will describe this issue with some examples today later, because it can be unclean for understanding now.

@Ragazzo

So i suggest at the beginning to do this: add new public property to the CDbTestCase.fixturesPath, so when CDbTestCase::setUp will be called then it will set basePath correctly to the fixture manager, small addition but very helpful, because then no need to set it every time. Second suggest is to make each fixture - array, or smth. like this:
fixtures = array(
'path/to/fixture/fixture' => ...
);
So in this case i can load some fixtures that can be in different places and dont need to copy them in one folder to load through basePath property change.
@samdark @cebe what do u think about this small changes?

@cebe
Yii Software LLC member

@Ragazzo I didn't get what you are trying to achive. You describe a solution but I can't see the problem it should solve... Why do you need fixtures in different places?

@Ragazzo

I got module and when it has some different components, so lets say one of the component is working with table 1 (t1) and table 2(t2), but i already have fixtures for t2 when i was testing through CDbTestCase model Users, so in this case to test component i need to copy fixture for the t2 to the new folder (fixtures\modules\users\components\someComponentName) and then only test it (the answer to why do i need to store fixtures for the module in different parts is that components or models or other can use fixtures with different data for the same tables). So i want to just load fixtures from the other folder of my module tests, to avoid do it through

$this->getFixtureManager()->basePath = Yii::getPathOfAlias($this->_fixturesPath);
$this->getFixtureManager()->load($this->fixtures);

where _fixturesPath is a private property added by me to the CDbTestCase of some model or component test.

@cebe cebe was assigned Jan 30, 2013
@cebe
Yii Software LLC member

Closed for reasons described in #2257 (comment)

@cebe cebe closed this Apr 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment