Example #1
0
 protected function setUp()
 {
     $cluster = new Cluster();
     $schema = $this->getSchema();
     $cluster->addSchema($schema);
     $this->generator = new Generator();
 }
Example #2
0
 /**
  * @group schema
  */
 public function testCreateSchema()
 {
     $this->assertTrue($this->cluster->hasTable('product'));
     $this->assertFalse($this->cluster->hasTable(null));
     $productTable = $this->cluster->getTable('product');
     $this->assertInstanceOf('\\Model\\Cluster\\Schema\\Table', $productTable);
     $this->assertNull($this->cluster->getTable('not_exists'));
     //        $allInclusiveTable = $this->_schema->getTable('all_inclusive');
     //      $this->assertInstanceOf('Model_Schema_Table', $allInclusiveTable);
     //    $this->assertInstanceOf('Model_Schema_Table_Index_Unique', $allInclusiveTable->getIndex('idx_uniq_admin_creator'));
 }
Example #3
0
 public function __construct(Config $config, $db)
 {
     $outputDir = $config->getParameter('output-dir');
     if (!$outputDir) {
         $console = Console::getInstance();
         $console->write("Unknown output dir. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     if (!is_dir($outputDir) || !is_writeable($outputDir)) {
         $console = Console::getInstance();
         $console->write("Unknown output dir not exists or not writable. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $this->setOutDir($outputDir);
     $this->cluster = new Cluster();
     $this->cluster->addSchema((new Schema($db))->init());
     $configPath = $config->getParameter('config', __DIR__ . '/models.json');
     if (!is_file($configPath) || !is_readable($configPath)) {
         $console = Console::getInstance();
         $console->write("Config file not exists or not readable. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $generatorConfig = json_decode(file_get_contents($configPath), true);
     if (!$generatorConfig) {
         $console = Console::getInstance();
         $console->write("Bad config file. Use ./models --help\n", ColorInterface::RED);
         exit;
     }
     $this->setGeneratorConfig($generatorConfig);
     // Register plugins
     $plugins = isset($generatorConfig['plugins']) ? $generatorConfig['plugins'] : array();
     if (!empty($plugins)) {
         $this->registerPlugins($plugins);
     }
     $this->config = $config;
 }