コード例 #1
0
ファイル: Test.php プロジェクト: alexbuyanow/zfphinx
 /**
  * Verify configuration file
  *
  * @param  InputInterface            $input
  * @param  OutputInterface           $output
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadManager($input, $output);
     $this->verifyMigrationDirectory($this->getConfig()->getMigrationPath());
     $envName = $input->getOption('environment');
     if ($envName) {
         if (!$this->getConfig()->hasEnvironment($envName)) {
             throw new \InvalidArgumentException(sprintf('The environment "%s" does not exist', $envName));
         }
         $output->writeln(sprintf('<info>validating environment</info> %s', $envName));
         $environment = new Environment($envName, $this->getConfig()->getEnvironment($envName));
         // validate environment connection
         $environment->getAdapter()->connect();
     }
     $output->writeln('<info>success!</info>');
 }
コード例 #2
0
ファイル: LhmTest.php プロジェクト: tristanpemble/lhm_php
 public function testRenameColumn()
 {
     $time = time();
     $this->environment->executeMigration(new InitialMigration($time - 1), MigrationInterface::UP);
     $this->assertNotEmpty($this->adapter->fetchAll("SELECT * FROM ponies WHERE name IS NOT NULL"));
     $this->environment->executeMigration(new RenameMigration($time), MigrationInterface::UP);
     $this->assertEmpty($this->adapter->fetchAll("SELECT * FROM ponies WHERE first_name IS NULL"));
 }
コード例 #3
0
 public function testExecutingAChangeMigrationDown()
 {
     // stub adapter
     $adapterStub = $this->getMock('\\Phinx\\Db\\Adapter\\PdoAdapter', array(), array(array()));
     $adapterStub->expects($this->once())->method('migrated')->will($this->returnArgument(0));
     $this->environment->setAdapter($adapterStub);
     // migration
     $migration = $this->getMock('\\Phinx\\Migration\\AbstractMigration', array('change'), array('20130301080000'));
     $migration->expects($this->once())->method('change');
     $this->environment->executeMigration($migration, MigrationInterface::DOWN);
 }
コード例 #4
0
ファイル: Manager.php プロジェクト: askzap/ultimate
 /**
  * Gets the manager class for the given environment.
  *
  * @param string $name Environment Name
  * @throws \InvalidArgumentException
  * @return Environment
  */
 public function getEnvironment($name)
 {
     if (isset($this->environments[$name])) {
         return $this->environments[$name];
     }
     // check the environment exists
     if (!$this->getConfig()->hasEnvironment($name)) {
         throw new \InvalidArgumentException(sprintf('The environment "%s" does not exist', $name));
     }
     // create an environment instance and cache it
     $environment = new Environment($name, $this->getConfig()->getEnvironment($name));
     $this->environments[$name] = $environment;
     $environment->setOutput($this->getOutput());
     return $environment;
 }
コード例 #5
0
ファイル: EnvironmentTest.php プロジェクト: askzap/ultimate
 /**
  * @dataProvider badAdapterProvider
  * @expectedException \RuntimeException
  */
 public function testBadAdapterFactories($adapterName, $adapter)
 {
     $env = new Environment('test-' . $adapterName, array());
     $env->registerAdapter($adapterName, $adapter);
     $env->setOptions(array('adapter' => $adapterName));
     $env->getAdapter();
 }
コード例 #6
0
ファイル: EnvironmentTest.php プロジェクト: liammartens/xtend
 public function testGettingInputObject()
 {
     $this->environment->setInput($this->getMock('\\Symfony\\Component\\Console\\Input\\InputInterface'));
     $inputObject = $this->environment->getInput();
     $this->assertInstanceOf('\\Symfony\\Component\\Console\\Input\\InputInterface', $inputObject);
 }