Ejemplo n.º 1
0
 /**
  * Builds a system db for the test environment
  * 
  * @todo This replicates some code in Command/System/Build - needs to be much more DRY
  */
 protected function buildTestSystemDatabase()
 {
     // Load the Meshing_Test_Paths class
     $projectRoot = Meshing_Utils::getProjectRoot();
     require_once $projectRoot . '/tests/unit/Meshing_Test_Paths.php';
     Meshing_Utils::reinitialise(new Meshing_Test_Paths());
     $paths = Meshing_Utils::getPaths();
     // Build a system connection file
     $task = new Meshing_Propel_ConfBuilder();
     $task->addSchemas($projectRoot . $paths->getPathDbConfig(), $paths->getLeafStandardSchema());
     $task->setXmlFile($projectRoot . $paths->getFileRuntimeXml());
     $task->setPropelConnection(Meshing_Utils::CONN_SYSTEM_TEST);
     $task->setOutputDir($projectRoot . $paths->getPathConnsSystem());
     $task->setOutputFile($paths->getLeafRuntimePhp());
     $task->run();
     // Build the SQL for a test system database
     $task = new Meshing_Propel_SqlBuilder();
     $task->addSchemas($projectRoot . $paths->getPathDbConfig(), $paths->getLeafStandardSchema());
     $task->setOutputDir($projectRoot . $paths->getPathSqlSystem());
     $task->setPropelConnection(Meshing_Utils::CONN_SYSTEM_TEST);
     $task->run();
     // Run the sql
     $task = new Meshing_Propel_SqlRunner();
     $task->setSqlDir($projectRoot . $paths->getPathSqlSystem());
     $task->setMapFile($projectRoot . $paths->getFileDbMap());
     $task->setPropelConnection(Meshing_Utils::CONN_SYSTEM_TEST);
     $task->run();
 }
Ejemplo n.º 2
0
 /**
  * Runs the already-built SQL for the system db (deletes the existing system tables)
  * 
  * @todo Move the paths to the build.properties file
  * 
  * @param boolean $verbose 
  */
 protected function runSql($verbose)
 {
     $sqlDir = $this->projectRoot . Meshing_Utils::getPaths()->getPathSqlSystem();
     $mapFile = $this->projectRoot . Meshing_Utils::getPaths()->getFileDbMap();
     $task = new Meshing_Propel_SqlRunner();
     $task->setPropelConnection();
     $task->setSqlDir($sqlDir);
     $task->setMapFile($mapFile);
     $task->run();
 }
Ejemplo n.º 3
0
 /**
  * Runs the already-built SQL for the system db (deletes the existing system tables)
  * 
  * @todo This is similar to system:build, fix this?
  * 
  * @param string $projectRoot 
  */
 protected function runSql($projectRoot)
 {
     $sqlDir = $projectRoot . Meshing_Utils::getPaths()->getPathSqlNodes() . '/' . $this->opts->name;
     $mapFile = $projectRoot . Meshing_Utils::getPaths()->getFileDbMap();
     $task = new Meshing_Propel_SqlRunner();
     $task->setSqlDir($sqlDir);
     $task->setMapFile($mapFile);
     // Set build properties (@todo switch this to use setPropelConnection)
     $task->addProperty('propel.database', $this->connection->getAdaptor());
     $task->addProperty('propel.database.url', $this->connection->getCalculatedDsn());
     $task->addProperty('propel.database.user', $this->connection->getUsername());
     $task->addProperty('propel.database.password', $this->connection->getPassword());
     $task->run();
 }
Ejemplo n.º 4
0
 /**
  * Runs generated SQL against the configured db
  */
 protected function _testSqlRunner($runTests = true, $conName = Meshing_Utils::CONN_NODE_TEST_1)
 {
     $mapFile = $this->projectRoot . $this->paths->getFileDbMap();
     $task = new Meshing_Propel_SqlRunner();
     $task->setSqlDir($this->sqlDir);
     $task->setMapFile($mapFile);
     $task->setPropelConnection($conName);
     try {
         $task->run();
     } catch (BuildException $e) {
         echo "Error running SQL file, check build properties (map: " . $this->paths->getFileDbMap() . ")\n";
         exit;
     }
     // No tests here at the moment - we'll connect to test db later
     if ($runTests) {
     }
 }