mblarsen / fFixture

Provides an easy way of creating sample data (fixtures) for unit testing using Flourish.
http://mblarsen.github.com/fFixture
2 stars 0 forks source link

Does it dump the database to json? #3

Closed jarednipper closed 1 year ago

jarednipper commented 12 years ago

How are you generating the json files?

jarednipper commented 12 years ago

I see that you are already thinking about this.

I'm considering adding a fFixturedump($root, $tables) method that uses these methods to build JSON fixture files. Maybe with some limiting options in case of huge datasets.

How about just passing it an fRecordSet?

mblarsen commented 12 years ago

Some I make by hand other I use existing data and dumping it to json. Check second comment here:

http://flourishlib.com/discussion/2/595/1700

Got it?

mblarsen commented 12 years ago

I'm considering adding a method that will build fORMJSON to dump larger amount of data. A method signature something like this:

    /**
 * Dumps an existing database into mulitiple fixture files.
 *
 * @param $root
 *   The directory in which to dump the fixture files.
 * @param $tables
 *   An array of table names to dump.
 * @param $limits
 *   An associative array of table names as keys and values that are the max limit of records to dump.
 * @param $dont_follow_dependencies
 *   In case of foreign key constraints you can opt not to follow the relation and only create the fixtures from $tables.
 */
static public function dump($root, $tables = array(), $limits = array(), $dont_follow_dependencies = FALSE)
{
}
mblarsen commented 12 years ago

Yeah that woud leave out $tables and $limits

static public function dump($root, $record_set, $dont_follow_dependencies);

However focusing on table level allows you change to a more efficient implementation for large data sets. But you could have both:

static public function dump($root, $tables = array(), $limits = array(), $dont_follow_dependencies = FALSE)
static public function dumpRecords($root, $record_set, $dont_follow_dependencies = FALSE)
jarednipper commented 12 years ago

Oh cool! I didn't know about fORMJSON::extend().

jarednipper commented 12 years ago

You can close this non-issue if you want.