예제 #1
0
파일: Tests.php 프로젝트: halfer/Meshing
 /**
  * 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();
 }
예제 #2
0
파일: Add.php 프로젝트: halfer/Meshing
 /**
  * Builds the SQL for the node database (doesn't touch the db)
  * 
  * Note: it's tempting to build SQL in schema:add, and then run it against any node that uses
  * the schema. However we can't do that, since we could have one schema across two database
  * types (unlikely but possible).
  * 
  * @todo This is nearly an exact copy from system:build, fix this
  * 
  * @param string $projectRoot 
  */
 protected function buildSql($projectRoot)
 {
     $schemaDir = $projectRoot . Meshing_Utils::getPaths()->getPathSchemasNodes() . '/' . $this->opts->schema;
     $schemas = "schema.xml";
     $outputDir = $projectRoot . Meshing_Utils::getPaths()->getPathSqlNodes() . '/' . $this->opts->name;
     // Create task, configure, then run
     $task = new Meshing_Propel_SqlBuilder();
     $task->setPropelConnection();
     $task->addSchemas($schemaDir, $schemas);
     $task->setOutputDir($outputDir);
     $task->run();
 }
예제 #3
0
파일: Build.php 프로젝트: halfer/Meshing
 /**
  * Builds the SQL for the system database (doesn't touch the db)
  * 
  * @todo Move the paths to a build.properties file
  * 
  * @param boolean $verbose 
  */
 protected function buildSql($verbose)
 {
     $schemaDir = $this->projectRoot . Meshing_Utils::getPaths()->getPathDbConfig();
     $schemas = Meshing_Utils::getPaths()->getLeafStandardSchema();
     $outputDir = $this->projectRoot . Meshing_Utils::getPaths()->getPathSqlSystem();
     // Create task, configure, then run
     $task = new Meshing_Propel_SqlBuilder();
     $task->setPropelConnection();
     $task->addSchemas($schemaDir, $schemas);
     $task->setOutputDir($outputDir);
     $task->run();
 }
예제 #4
0
 /**
  * Generates SQL from a schema, and optionally tests it
  */
 protected function _testSqlBuilder($runTests = true)
 {
     $task = new Meshing_Propel_SqlBuilder();
     $task->setPropelConnection(Meshing_Utils::CONN_NODE_TEST_1);
     $task->addSchemas($this->outputSchemaDir, $this->paths->getLeafStandardSchema());
     $task->setOutputDir($this->sqlDir);
     $task->run();
     if ($runTests) {
         $this->assertTrue(file_exists($this->sqlDir . '/schema.sql'), 'Checking generated SQL exists');
     }
 }