Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     dbsteward::set_sql_format('pgsql8');
     // reset these flags before each test
     pgsql8_diff::$as_transaction = TRUE;
     dbsteward::$require_slony_set_id = FALSE;
     dbsteward::$require_slony_id = FALSE;
     dbsteward::$generate_slonik = FALSE;
     dbsteward::$slonyid_set_value = 1;
     dbsteward::$slonyid_start_value = 1;
     // clear these before each test so we don't run into conflicts
     pgsql8::$table_slony_ids = array();
     pgsql8::$sequence_slony_ids = array();
     pgsql8_diff::$new_table_dependency = null;
     pgsql8_diff::$old_table_dependency = null;
     // rest test fixtures
     $this->in_doc = null;
     $this->slonyid_doc = null;
 }
 protected function setUp()
 {
     if (!is_dir(__DIR__ . '/testdata')) {
         mkdir(__DIR__ . '/testdata');
     }
     $this->output_prefix = dirname(__FILE__) . '/testdata/unit_test_xml_a';
     $this->xml_file_a = __DIR__ . '/testdata/unit_test_xml_a.xml';
     file_put_contents($this->xml_file_a, $this->xml_content_a);
     $this->xml_file_b = __DIR__ . '/testdata/unit_test_xml_b.xml';
     file_put_contents($this->xml_file_b, $this->xml_content_b);
     $this->pgsql8 = $GLOBALS['db_config']->pgsql8_conn;
     $this->mssql10 = $GLOBALS['db_config']->mssql10_conn;
     $this->mysql5 = $GLOBALS['db_config']->mysql5_conn;
     // reset dbsteward runtime mode flags for each test
     dbsteward::$single_stage_upgrade = FALSE;
     dbsteward::$generate_slonik = FALSE;
     pgsql8_diff::$as_transaction = TRUE;
     // reset dbsteward runtime tracking variables for each test
     pgsql8::$table_slony_ids = array();
     pgsql8::$sequence_slony_ids = array();
     pgsql8::$known_pg_identifiers = array();
 }
Exemplo n.º 3
0
 private function diff($old, $new, $expected)
 {
     $ofs = new mock_output_file_segmenter();
     $old = '<dbsteward><database/>' . $old . '</dbsteward>';
     $new = '<dbsteward><database/>' . $new . '</dbsteward>';
     $old_doc = simplexml_load_string($old);
     $new_doc = simplexml_load_string($new);
     dbsteward::$old_database = $old_doc;
     dbsteward::$new_database = $new_doc;
     pgsql8_diff::$old_table_dependency = xml_parser::table_dependency_order($old_doc);
     pgsql8_diff::$new_table_dependency = xml_parser::table_dependency_order($new_doc);
     pgsql8_diff_types::apply_changes($ofs, $old_doc->schema, $new_doc->schema);
     $sql = trim(preg_replace('/\\n\\n+/', "\n", preg_replace('/^--.*$/m', '', $ofs->_get_output())));
     $this->assertEquals($expected, $sql);
 }
Exemplo n.º 4
0
 /**
  * diff the xml files on disk to create an upgrade sql that gets us from a to b
  *
  */
 public static function sql_diff($old, $new, $upgrade_prefix)
 {
     if (!is_array($old)) {
         $old = array($old);
     }
     if (!is_array($new)) {
         $new = array($new);
     }
     dbsteward::notice("Calculating sql differences:");
     dbsteward::notice("Old set:  " . implode(', ', $old));
     dbsteward::notice("New set:  " . implode(', ', $new));
     dbsteward::notice("Upgrade:  " . $upgrade_prefix);
     return pgsql8_diff::diff_sql($old, $new, $upgrade_prefix);
 }
Exemplo n.º 5
0
 public function testGenerateSlonikRemovesTransactionStatements()
 {
     pgsql8_diff::$as_transaction = FALSE;
     dbsteward::$generate_slonik = TRUE;
     $this->transaction_statement_check(FALSE);
     pgsql8_diff::$as_transaction = TRUE;
     dbsteward::$generate_slonik = FALSE;
     $this->transaction_statement_check(TRUE);
     pgsql8_diff::$as_transaction = TRUE;
     dbsteward::$generate_slonik = TRUE;
     $this->transaction_statement_check(TRUE);
 }
 public function setUp()
 {
     parent::setUp();
     dbsteward::set_sql_format('pgsql8');
     // reset runtime mode flags to their default
     dbsteward::$single_stage_upgrade = FALSE;
     dbsteward::$generate_slonik = FALSE;
     pgsql8_diff::$as_transaction = TRUE;
     // reset runtime tracking variables
     pgsql8::$table_slony_ids = array();
     pgsql8::$sequence_slony_ids = array();
     pgsql8::$known_pg_identifiers = array();
     pgsql8_diff::$new_table_dependency = null;
     pgsql8_diff::$old_table_dependency = null;
 }