示例#1
0
 public function testPrintStatusMethodWithMissingMigrations()
 {
     // stub environment
     $envStub = $this->getMock('\\Phinx\\Migration\\Manager\\Environment', array(), array('mockenv', array()));
     $envStub->expects($this->once())->method('getVersions')->will($this->returnValue(array('20120103083300', '20120815145812')));
     $this->manager->setEnvironments(array('mockenv' => $envStub));
     $this->manager->printStatus('mockenv');
     rewind($this->manager->getOutput()->getStream());
     $outputStr = stream_get_contents($this->manager->getOutput()->getStream());
     $this->assertRegExp('/up  20120103083300  \\*\\* MISSING \\*\\*/', $outputStr);
     $this->assertRegExp('/up  20120815145812  \\*\\* MISSING \\*\\*/', $outputStr);
 }
示例#2
0
 public function testGettingOutputObject()
 {
     $migrations = $this->manager->getMigrations();
     $outputObject = $this->manager->getOutput();
     $this->assertInstanceOf('\\Symfony\\Component\\Console\\Output\\OutputInterface', $outputObject);
     foreach ($migrations as $migration) {
         $this->assertEquals($outputObject, $migration->getOutput());
     }
 }
示例#3
0
 public function testBreakpointWithInvalidVersion()
 {
     if (!TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED) {
         $this->markTestSkipped('Mysql tests disabled. See TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED constant.');
     }
     $configArray = $this->getConfigArray();
     $adapter = $this->manager->getEnvironment('production')->getAdapter();
     $config = new Config($configArray);
     // ensure the database is empty
     $adapter->dropDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->createDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->disconnect();
     // migrate to the latest version
     $this->manager->setConfig($config);
     $this->manager->migrate('production');
     $this->manager->getOutput()->setDecorated(false);
     // set breakpoint on most recent migration
     $this->manager->toggleBreakpoint('production', 999);
     rewind($this->manager->getOutput()->getStream());
     $output = stream_get_contents($this->manager->getOutput()->getStream());
     $this->assertContains('is not a valid version', $output);
 }