Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDbTestCase fixtures format #1936

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

CDbTestCase fixtures format #1936

Ragazzo opened this issue Jan 8, 2013 · 5 comments
Assignees

Comments

@Ragazzo
Copy link

Ragazzo commented Jan 8, 2013

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
Copy link
Author

Ragazzo commented Jan 9, 2013

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

@Ragazzo
Copy link
Author

Ragazzo commented Jan 22, 2013

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
Copy link
Member

cebe commented Jan 22, 2013

@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
Copy link
Author

Ragazzo commented Jan 22, 2013

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
Copy link
Member

cebe commented Apr 24, 2013

Closed for reasons described in #2257 (comment)

@cebe cebe closed this as completed Apr 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants