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); }
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); }
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("\n[40m[1;31mThe file {$file} is not writable or his directory.[0m\n\n", $actual); array_pop($versions); $this->assertEquals($versions, $this->_adapter->versions); }
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); }