function test_executeTasksTablesAlter()
{
$this->assertTrue($this->initDatabase(325, array('campaigns')) . 'failed to created version 325 of campaigns table');
$tblCampaigns = $this->oDbh->quoteIdentifier($this->prefix . 'campaigns', true);
// Insert some data to test the upgrade from... we know the schema being used so we can directly insert
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (1,'campaign one', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'h', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (2,'campaign two', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'm', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (3,'campaign three', 1, -1, -1, -1, '2000-01-01', '2000-01-01', 't', 'l', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (4,'campaign four', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'h', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (5,'campaign five', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'm', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (6,'campaign six', 1, -1, -1, -1, '2000-01-01', '2000-01-01', 't', 'l', 1, 1, 'f', 'f')");
Mock::generatePartial('OA_DB_UpgradeAuditor', $mockAuditor = 'OA_DB_UpgradeAuditor' . rand(), array('logAuditAction', 'setKeyParams'));
$oLogger = new OA_UpgradeLogger();
$oLogger->setLogFile('DB_Upgrade.test.log');
$oDB_Upgrade = new OA_DB_Upgrade($oLogger);
$oDB_Upgrade->oAuditor = new $mockAuditor($this);
$oDB_Upgrade->oAuditor->setReturnValue('logAuditAction', true);
$oDB_Upgrade->oAuditor->setReturnValue('setKeyParams', true);
$oDB_Upgrade->init('constructive', 'tables_core', 326);
$aDef325 = $this->oaTable->aDefinition;
$oDB_Upgrade->aDBTables = $oDB_Upgrade->_listTables();
$this->assertTrue($oDB_Upgrade->_verifyTasksTablesAlter(), 'failed _verifyTasksTablesAlter: change field');
$this->assertTrue($oDB_Upgrade->_executeTasksTablesAlter(), 'failed _executeTasksTablesAlter: change field');
$aDefDB = $oDB_Upgrade->oSchema->getDefinitionFromDatabase(array($this->prefix . 'campaigns'));
$aDiff = $oDB_Upgrade->oSchema->compareDefinitions($this->aDefNew, $aDefDb);
$this->assertEqual(count($aDiff), 0, 'comparison failed');
$aResults = $this->oDbh->queryAll("SELECT * FROM " . $tblCampaigns);
$this->assertIsa($aResults, 'array');
$expected = array(1 => '5', 2 => '3', 3 => '0', 4 => '5', 5 => '3', 6 => '0');
foreach ($aResults as $idx => $aRow) {
$this->assertEqual($aRow['priority'], $expected[$aRow['campaignid']], ' unexpected campaign priority value detected after upgrade');
}
}