public static function setUpBeforeClass() { Database::setDetails('b8_test_' . getenv('PHPCI_BUILD'), 'b8_test', 'b8_test'); Database::setWriteServers(array('localhost')); Database::setReadServers(array('localhost')); Registry::getInstance()->set('b8.app.namespace', 'Generation'); self::$_db = Database::getConnection('write'); self::$_db->query('DROP TABLE IF EXISTS tres'); self::$_db->query('DROP TABLE IF EXISTS dos'); self::$_db->query('DROP TABLE IF EXISTS uno'); self::$_base = dirname(__FILE__) . '/data/generation/'; $gen = new Generator(self::$_db, 'Test', self::$_base . 'models/'); $gen->generate(); }
public function testUpdateDatabase() { $gen = new Generator($this->_db, 'Test', dirname(__FILE__) . '/data/generation/models/'); $gen->generate(); $gen = new Generator($this->_db, 'Update', dirname(__FILE__) . '/data/generation/update_models/'); $gen->generate(); $map = new Map($this->_db); $t = $map->generate(); $this->assertTrue(array_key_exists('uno', $t)); $this->assertTrue(array_key_exists('dos', $t)); $this->assertTrue(array_key_exists('tres', $t)); $this->assertFalse(array_key_exists('bad_table', $t)); $this->assertTrue(count($t['uno']['indexes']) == 1); $this->assertTrue(count($t['dos']['indexes']) == 3); $this->assertTrue(count($t['tres']['indexes']) == 3); $this->assertTrue(count($t['uno']['columns']) == 10); $this->assertTrue(count($t['dos']['columns']) == 4); $this->assertTrue(count($t['tres']['columns']) == 10); $this->assertTrue(array_key_exists('PRIMARY', $t['uno']['indexes'])); $this->assertTrue(array_key_exists('PRIMARY', $t['dos']['indexes'])); $this->assertTrue(array_key_exists('PRIMARY', $t['tres']['indexes'])); }