diff options
Diffstat (limited to 'tests/mocks/database/schema')
-rw-r--r-- | tests/mocks/database/schema/.gitkeep | 0 | ||||
-rw-r--r-- | tests/mocks/database/schema/skeleton.php | 57 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/mocks/database/schema/.gitkeep b/tests/mocks/database/schema/.gitkeep deleted file mode 100644 index e69de29bb..000000000 --- a/tests/mocks/database/schema/.gitkeep +++ /dev/null diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php new file mode 100644 index 000000000..6610d6b59 --- /dev/null +++ b/tests/mocks/database/schema/skeleton.php @@ -0,0 +1,57 @@ +<?php + +class Mock_Database_Schema_Skeleton { + + /** + * Create the dummy tables + * + * @return void + */ + public static function create_tables($forge, $driver) + { + // Job Table + $forge->add_field(array( + 'id' => array( + 'type' => 'INTEGER', + 'constraint' => 3, + ), + 'name' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + ), + 'description' => array( + 'type' => 'TEXT', + ), + )); + $forge->add_key('id', TRUE); + $forge->create_table('job', (strpos($driver, 'pgsql') === FALSE)); + } + + /** + * Create the dummy datas + * + * @return void + */ + public static function create_data($db) + { + // Job Data + $data = array( + 'job' => array( + array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), + array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'), + array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), + array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'), + ), + ); + + foreach ($data as $table => $dummy_data) + { + $db->truncate($table); + + foreach ($dummy_data as $single_dummy_data) + { + $db->insert($table, $single_dummy_data); + } + } + } +}
\ No newline at end of file |