chriskite / phactory

A Database Factory for PHP Unit Tests
http://phactory.org
MIT License
140 stars 39 forks source link

Rowfill #11

Closed cschwendiman closed 12 years ago

cschwendiman commented 13 years ago

When creating rows with Phactory, omitted optional columns are filled with null in the database. This is convenient because I don't have to provide every column in my definition of of a table (which is subject to change unexpectedly/often). However, when I create objects from Phactory Rows, I often want them to mirror what is in the database - not what is in the internal storage of a Phactory Row (which doesn't account for those null columns).

To get arround this I am doing: $user = Phactory::create('user'); $user = Phactory::get('user', array('id' => $user->getId()); $user_object = new User($user->toArray());

This will allow us to instead use: $user = Phactory::create('user'); $user_object = new User($user->fill()->toArray());

ramsey commented 12 years ago

FYI, I also added this into my pull request #17.

jimbojsb commented 12 years ago

closing this per @ramsey