예제 #1
0
 public function testExecuteWithTableSchemaWihtMaxVersionUnknown()
 {
     $this->_adapter->setTableSchemaExist(true);
     $this->_adapter->versions = array(array('version' => '20130124064438'), array('version' => '20120124064438'), array('version' => '20120112064438'), array('version' => '20120110064438'));
     $actual = $this->object->execute(array());
     $regexp = '/^Started: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+' . '\\[db:version\\]:\\012+\\t+Current version: 20130124064438' . '\\012+Finished: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+$/';
     $this->assertNotEmpty($actual);
     $this->assertRegExp($regexp, $actual);
 }
예제 #2
0
 public function testExecuteWithPreviousVersionException()
 {
     $this->_adapter->setTableSchemaExist(true);
     $versions = array(array('version' => '20120109064438'), array('version' => '20120110064438'), array('version' => '20120111064438'), array('version' => '20120112064438'));
     $this->_adapter->versions = $versions;
     $actual = $this->object->execute(array('VERSION' => '20120111064438'));
     $regexp = '/^Started: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+' . '\\[db:migrate\\]:\\012+\\tMigrating DOWN to: 20120111064438\\012+' . 'MissingMethodUp - Query for selectOne\\(\\) is not one of SELECT' . ' or SHOW: UPDATE `users` SET `login` `login` VARCHAR\\(20\\);\\012+' . 'Finished: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+$/';
     $this->assertNotEmpty($actual);
     $this->assertRegExp($regexp, $actual);
     $this->assertEquals($versions, $this->_adapter->versions);
 }
예제 #3
0
 public function testExecuteWithOutputAndFileNotWritable()
 {
     $this->_adapter->setTableSchemaExist(true);
     $versions = array(array('version' => '20120109064438'), array('version' => '20120110064438'), array('version' => '20120111064438'));
     $this->_adapter->versions = $versions;
     $file = '/usr/bin/tests.sql';
     $actual = $this->object->execute(array('VERSION' => '20120110064438', '-o' => $file));
     $this->assertNotEmpty($actual);
     $this->assertStringEndsWith("\nThe file {$file} is not writable or his directory.\n\n", $actual);
     array_pop($versions);
     $this->assertEquals($versions, $this->_adapter->versions);
 }
예제 #4
0
 public function testExecuteExportForTestHeader()
 {
     $parameters = array('monScript.php', '-d', PHIGRATE_BASE . '/tests/fixtures/config/database.ini', '-c', PHIGRATE_BASE . '/tests/fixtures/config/application.ini', 'db:export');
     $actual = new Phigrate_FrameworkRunner($parameters);
     $adapter = new adapterTaskMock(array(), '');
     $adapter->setTableSchemaExist(true);
     $adapter->versions = array(array('version' => '20120110064438'));
     $actual->setAdapter($adapter);
     $task = $actual->execute();
     $this->assertNotEmpty($task);
     $this->assertNotRegExp('/^[\\s_|`]+/', $task);
 }