<?php

class Mock_Database_Schema_Skeleton {

	/**
	 * @var object Database Holder
	 */
	public static $db;

	/**
	 * @var object Forge Holder
	 */
	public static $forge;

	/**
	 * @var object Driver Holder
	 */
	public static $driver;

	/**
	 * Initialize both database and forge components
	 */
	public static function init($driver)
	{
		if (empty(static::$db) && empty(static::$forge))
		{
			$config = Mock_Database_DB::config($driver);
			$connection = new Mock_Database_DB($config);
			$db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE);

			CI_TestCase::instance()->ci_instance_var('db', $db);

			$loader = new Mock_Core_Loader();
			$loader->dbforge();
			$forge = CI_TestCase::instance()->ci_instance_var('dbforge');

			static::$db = $db;
			static::$forge = $forge;
			static::$driver = $driver;
		}

		return static::$db;
	}
	
	
	/**
	 * Create the dummy tables
	 *
	 * @return void
	 */
	public static function create_tables()
	{
		// Job Table
		static::$forge->add_field(array(
			'id' => array(
				'type' => 'INTEGER',
				'constraint' => 3,
			),
			'name' => array(
				'type' => 'VARCHAR',
				'constraint' => 40,
			),
			'description' => array(
				'type' => 'TEXT',
			),
		));
		static::$forge->add_key('id', TRUE);
		static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE));
	}

	/**
	 * Create the dummy datas
	 *
	 * @return void
	 */
	public static function create_data()
	{
		// 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) 
		{
			static::$db->truncate($table);

			foreach ($dummy_data as $single_dummy_data)
			{
				static::$db->insert($table, $single_dummy_data); 
			}
		}
	}
}