public function setDumpQueriesOnly($dumpQueriesOnly) { if ($dumpQueriesOnly === true) { ClearIce::setOutputLevel(ClearIce::OUTPUT_LEVEL_0); } $this->dumpQueriesOnly = $dumpQueriesOnly; }
public function testLevelThreshold() { ClearIce::setOutputLevel(ClearIce::OUTPUT_LEVEL_0); ClearIce::output("Hello"); $this->assertFileNotExists($this->stdout); ClearIce::setOutputLevel(ClearIce::OUTPUT_LEVEL_1); ClearIce::output("Hello\n"); $this->assertStringEqualsFile($this->stdout, "Hello\n"); }
public function setup() { require_once "src/globals.php"; ClearIce::setOutputLevel(ClearIce::OUTPUT_LEVEL_1); $GLOBALS['DRIVER'] = getenv('YENTU_DRIVER'); $GLOBALS['DB_DSN'] = getenv('YENTU_BASE_DSN'); if (getenv('YENTU_FILE') === false) { $GLOBALS['DB_FULL_DSN'] = "{$GLOBALS['DB_DSN']};dbname={$this->testDatabase}"; $GLOBALS['DB_NAME'] = $this->testDatabase; $GLOBALS['DEFAULT_SCHEMA'] = (string) getenv('YENTU_DEFAULT_SCHEMA') == '' ? $this->testDatabase : (string) getenv('YENTU_DEFAULT_SCHEMA'); $GLOBALS['DB_FILE'] = ''; } else { $GLOBALS['DB_FULL_DSN'] = $GLOBALS['DB_DSN']; $GLOBALS['DB_FILE'] = getenv('YENTU_FILE'); $GLOBALS['DB_NAME'] = ''; $GLOBALS['DEFAULT_SCHEMA'] = ''; } $GLOBALS['DB_USER'] = (string) getenv('YENTU_USER'); $GLOBALS['DB_PASSWORD'] = (string) getenv('YENTU_PASSWORD'); $GLOBALS['DB_HOST'] = (string) getenv('YENTU_HOST'); $timer = $this->getMockBuilder("\\yentu\\Timer")->setMethods(array('stopInstance', 'startInstance'))->getMock(); $timer->method('stopInstance')->willReturn(10.0); \yentu\Timer::setInstance($timer); }
use yentu\Yentu; use ntentan\config\Config; ClearIce::addCommands(array('command' => 'import', 'help' => 'import the schema of an existing database'), array('command' => 'migrate', 'help' => 'run new migrations on the target database'), array('command' => 'init', 'help' => 'initialize the yentu directory'), array('command' => 'create', 'usage' => 'create [name] [options]..', 'help' => 'create a new migration'), array('command' => 'rollback', 'help' => 'rollback the previus migration which was run'), array('command' => 'status', 'help' => 'display the current status of the migrations')); ClearIce::addOptions(array('command' => 'import', 'short' => 'd', 'long' => 'skip-defaults', 'help' => 'do not import the default values of the columns'), array('command' => 'init', 'short' => 'i', 'long' => 'interractive', 'help' => 'initialize yentu interractively'), array('command' => 'init', 'short' => 'd', 'long' => 'driver', 'help' => 'database platform. Supports postgresql', 'has_value' => true), array('command' => 'init', 'short' => 'h', 'long' => 'host', 'help' => 'the hostname of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'p', 'long' => 'port', 'help' => 'the port of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'n', 'long' => 'dbname', 'help' => 'the name of the target database', 'has_value' => true), array('command' => 'init', 'short' => 'u', 'long' => 'user', 'help' => 'the user name on the target database', 'has_value' => true), array('command' => 'init', 'short' => 'p', 'long' => 'password', 'help' => 'the passwrd of the user on the target database', 'has_value' => true)); ClearIce::addOptions(array('command' => 'migrate', 'long' => 'no-foreign-keys', 'help' => 'do not apply any database foriegn-key constraints'), array('command' => 'migrate', 'long' => 'only-foreign-keys', 'help' => 'apply only database foreign-key constraints (fails on errors)'), array('command' => 'migrate', 'long' => 'force-foreign-keys', 'help' => 'apply only database foreign-key constraints'), array('command' => 'migrate', 'long' => 'dump-queries', 'help' => 'just dump the query and perform no action'), array('command' => 'migrate', 'long' => 'dry', 'help' => 'perform a dry run. Do not alter the database in anyway'), array('command' => 'migrate', 'long' => 'default-schema', 'has_value' => true, 'help' => 'use this as the default schema for all migrations'), array('command' => 'migrate', 'long' => 'default-ondelete', 'help' => 'the default cascade action for foreign key deletes', 'has_value' => true), array('command' => 'migrate', 'long' => 'default-onupdate', 'help' => 'the default cascade action for foreign key updates', 'has_value' => true)); ClearIce::addCommands(array('command' => 'rollback', 'long' => 'default-schema', 'has_value' => true, 'help' => 'reverse only migrations in this default-schema')); ClearIce::addOptions(array('short' => 'y', 'long' => 'home', 'help' => 'specifies where the yentu configurations are found', 'has_value' => true), array('short' => 'v', 'long' => 'verbose', 'help' => 'set level of verbosity. high, mid, low and none', 'has_value' => true)); ClearIce::addOptions(array('long' => 'details', 'help' => 'show details of all migrations.', 'command' => 'status')); ClearIce::setDescription("Yentu Database Migrations\nVersion " . Yentu::getVersion()); ClearIce::setFootnote("Report bugs to jainooson@gmail.com"); ClearIce::setUsage("[command] [options]"); ClearIce::addHelp(); ClearIce::setStrict(true); $options = ClearIce::parse(); if (isset($options['verbose'])) { ClearIce::setOutputLevel($options['verbose']); } try { if (isset($options['__command__'])) { if (isset($options['home'])) { Yentu::setDefaultHome($options['home']); } $class = "\\yentu\\commands\\" . ucfirst($options['__command__']); unset($options['__command__']); Config::readPath(Yentu::getPath('config'), 'yentu'); $command = new $class(); $command->run($options); } else { ClearIce::output(ClearIce::getHelpMessage()); } } catch (\yentu\exceptions\CommandException $e) {
/** * @expectedException \yentu\exceptions\CommandException */ public function testUnwritable() { vfsStream::setup('home', 0444); $initCommand = new \yentu\commands\Init(); \yentu\Yentu::setDefaultHome(vfsStream::url("home/yentu")); ClearIce::setOutputLevel(ClearIce::OUTPUT_LEVEL_0); $initCommand->run(array('driver' => 'postgresql', 'host' => $GLOBALS['DB_HOST'], 'dbname' => $GLOBALS['DB_NAME'], 'user' => $GLOBALS['DB_USER'], 'password' => $GLOBALS['DB_PASSWORD'])); }