Open cgarvisacmg opened 13 years ago
Phactory is always accepting pull requests :)
Nevertheless, I agree, this sounds like a good idea in general. I'd be interested to hear the case where it's necessary.
How many records are you testing at once to need that type of ordering/limiting? Usually on a unit test level, you wont have too many records to pull up and you should be truncating records and resetting Phactory per test.
Not that I disagree with the idea of adding conditions.
I have a table that is kind of a log. It contains information that a customer service rep can see to know what the system has done on behalf of the customer. In my unit testing I've had code inserting multiple comments. What I would like to be able to do is pull the last comment. We have the ability to pull the first one but not the last. That is why having the ability to set the order and limit for the Phactory::get() would be useful.
are you using Phactory to insert the comments? If so you can specify an id and reference that in your get();
Phactory::create('comment', array('id' => 12345, 'data' => 'some comments'));
Phactory::get('comment', array('id' => 12345));
When I use Phactory to create records, I do this. But this case is when the code creates those records. I have no way of knowing the id.
Understood. Maybe a patch would be in order.
It would be nice to pass conditions to the get.
Like if I wanted to get the latest created user: