コード例 #1
0
ファイル: InitTest.php プロジェクト: nguyenducduy/haraapp
 /**
  * @expectedException              \InvalidArgumentException
  * @expectedExceptionMessageRegExp /The file "(.*)" already exists/
  */
 public function testThrowsExceptionWhenConfigFilePresent()
 {
     touch(sys_get_temp_dir() . '/phinx.yml');
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new Init());
     // setup dependencies
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('init');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'path' => sys_get_temp_dir()), array('decorated' => false));
 }
コード例 #2
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The seed class name "badseedname" is invalid. Please use CamelCase format
  */
 public function testExecuteWithInvalidClassName()
 {
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new SeedCreate());
     // setup dependencies
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('seed:create');
     // mock the manager class
     $managerStub = $this->getMock('\\Phinx\\Migration\\Manager', array(), array($this->config, $output));
     $command->setConfig($this->config);
     $command->setManager($managerStub);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'name' => 'badseedname'), array('decorated' => false));
 }
コード例 #3
0
ファイル: RollbackTest.php プロジェクト: Slayug/castor
 public function testDatabaseNameSpecified()
 {
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new Rollback());
     // setup dependencies
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('rollback');
     // mock the manager class
     $managerStub = $this->getMock('\\Phinx\\Migration\\Manager', array(), array($this->config, $output));
     $managerStub->expects($this->once())->method('rollback');
     $command->setConfig($this->config);
     $command->setManager($managerStub);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertRegExp('/using database development/', $commandTester->getDisplay());
 }
コード例 #4
0
ファイル: StatusTest.php プロジェクト: askzap/ultimate
 public function testFormatSpecified()
 {
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new Status());
     // setup dependencies
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('status');
     // mock the manager class
     $managerStub = $this->getMock('\\Phinx\\Migration\\Manager', array(), array($this->config, $output));
     $managerStub->expects($this->once())->method('printStatus');
     $command->setConfig($this->config);
     $command->setManager($managerStub);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--format' => 'json'));
     $this->assertRegExp('/using format json/', $commandTester->getDisplay());
 }
コード例 #5
0
 public function testExecuteMultipleSeeders()
 {
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new SeedRun());
     // setup dependencies
     $input = new ArrayInput([]);
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('seed:run');
     // mock the manager class
     $managerStub = $this->getMock('\\Phinx\\Migration\\Manager', array(), array($this->config, $input, $output));
     $managerStub->expects($this->exactly(3))->method('seed')->withConsecutive(array($this->identicalTo('development'), $this->identicalTo('One')), array($this->identicalTo('development'), $this->identicalTo('Two')), array($this->identicalTo('development'), $this->identicalTo('Three')));
     $command->setConfig($this->config);
     $command->setManager($managerStub);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--seed' => ['One', 'Two', 'Three']), array('decorated' => false));
     $this->assertRegExp('/no environment specified/', $commandTester->getDisplay());
 }
コード例 #6
0
ファイル: CreateTest.php プロジェクト: JesseDarellMoore/CS499
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The migration class name "MyDuplicateMigration" already exists
  */
 public function testExecuteWithDuplicateMigrationNames()
 {
     $application = new \Phinx\Console\PhinxApplication('testing');
     $application->add(new Create());
     // setup dependencies
     $output = new StreamOutput(fopen('php://memory', 'a', false));
     $command = $application->find('create');
     // mock the manager class
     $managerStub = $this->getMock('\\Phinx\\Migration\\Manager', array(), array($this->config, $output));
     $command->setConfig($this->config);
     $command->setManager($managerStub);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'name' => 'MyDuplicateMigration'));
     sleep(1.01);
     // need at least a second due to file naming scheme
     $commandTester->execute(array('command' => $command->getName(), 'name' => 'MyDuplicateMigration'));
 }