function testGetZones() { $conf = $GLOBALS['_MAX']['CONF']; $dbh =& OA_DB::singleton(); $ret = $this->newZone(); $this->assertTrue(is_int($ret)); $this->assertTrue($ret > 0); // get zone record as control element $query = 'SELECT * FROM ' . $dbh->quoteIdentifier($conf['table']['prefix'] . 'zones', true) . ' WHERE zoneid = ' . $ret; $aZone1 = $dbh->queryRow($query); $this->assertTrue(is_array($aZone1)); // massage results so as to be comparable with Admin_DA::getZone() Admin_DA::_switch($aZone1, 'affiliateid', 'publisher_id'); Admin_DA::_switch($aZone1, 'zonename', 'name'); Admin_DA::_switch($aZone1, 'delivery', 'type'); Admin_DA::_switch($aZone1, 'zoneid', 'zone_id'); unset($aZone1['zonetype']); unset($aZone1['appendtype']); unset($aZone1['forceappend']); unset($aZone1['inventory_forecast_type']); unset($aZone1['height']); unset($aZone1['width']); unset($aZone1['updated']); unset($aZone1['block']); unset($aZone1['capping']); unset($aZone1['session_capping']); unset($aZone1['category']); unset($aZone1['rate']); unset($aZone1['pricing']); unset($aZone1['show_capped_no_cookie']); $aZone1 = array_filter($aZone1, 'strlen'); $aZone2 = Admin_DA::getZones(array('zone_id' => $ret)); /* Array ( [80] => Array ( [zone_id] => 80 [publisher_id] => 508 [name] => toufreacli [type] => 3 ) ) */ $this->assertTrue(is_array($aZone2[$ret])); $this->assertEqual($aZone1, $aZone2[$ret]); $zoneId = $this->newZone(); $doZones = OA_DAL::staticGetDO('zones', $zoneId); $doZones->inventory_forecast_type = 5; $doZones->update(); $aZone = Admin_DA::getZones(array('zone_inventory_forecast_type' => 1)); $this->assertTrue($aZone); // The returned zone isn't null or false or empty. }
/** * A method to test the sending of emails from the * manageCampaigns() method - tests the sending of * the "campaign deactivated" emails. */ function testManageCampaignsEmailsPlacementDeactivated() { // Prepare a single placement that is active, and has a lifetime // impression target that has been met (so that it will need to // be deactivated) $aData = array('contact' => 'Test Placement Deactivated Contact', 'email' => '*****@*****.**', 'reportdeactivate' => 't', 'report' => 't'); $advertiserId = $this->_insertAdvertiser($aData); $aAdvertiser = OA_DAL::staticGetDO('clients', $advertiserId)->toArray(); $aData = array('status' => OA_ENTITY_STATUS_RUNNING, 'views' => '100'); $campaignId = $this->_insertPlacement($aData); $aData = array('campaignid' => $campaignId); $adId = $this->_insertAd($aData); $aData = array('operation_interval_id' => 25, 'interval_start' => '2005-12-08 00:00:00', 'interval_end' => '2004-12-08 00:59:59', 'hour' => 0, 'ad_id' => 1, 'impressions' => 101); $this->_insertDataIntermediateAd($aData); // Create an instance of the mocked OA_Email class, and set // expectations on how the class' methods should be called // based on the above Mock::generate('OA_Email'); $oEmailMock = new MockOA_Email($this); $oEmailMock->expectOnce('sendCampaignActivatedDeactivatedEmail', array("{$campaignId}", 2)); // This is the date that is going to be used later $oDate = new Date(); $oEnd = new Date($oDate); $oEnd->addSpan(new Date_Span('1-0-0-0')); $oEmailMock->expectOnce('sendCampaignDeliveryEmail', array($aAdvertiser, new Date($aAdvertiser['reportlastdate']), $oEnd, "{$campaignId}")); // Register the mocked OA_Email class in the service locator $oServiceLocator =& OA_ServiceLocator::instance(); $oServiceLocator->register('OA_Email', $oEmailMock); // Run the manageCampaigns() method and ensure that the correct // calls to OA_Email were made $oFactory = new OX_Dal_Maintenance_Statistics_Factory(); $oDalMaintenanceStatistics = $oFactory->factory(); $report = $oDalMaintenanceStatistics->manageCampaigns($oDate); $oEmailMock->tally(); // Clean up DataGenerator::cleanUp(); }
function MAX_AclCopy($page, $from, $to) { $oDbh =& OA_DB::singleton(); $conf =& $GLOBALS['_MAX']['CONF']; $table = modifyTableName('acls'); switch ($page) { case 'channel-acl.php': echo "Not implemented"; break; default: // Delete old limitations $query = "\n DELETE FROM\n {$table}\n WHERE\n bannerid = " . $oDbh->quote($to, 'integer'); $res = $oDbh->exec($query); if (PEAR::isError($res)) { return $res; } // Copy ACLs $query = "\n INSERT INTO {$table} (bannerid, logical, type, comparison, data, executionorder)\n SELECT\n " . $oDbh->quote($to, 'integer') . ", logical, type, comparison, data, executionorder\n FROM\n {$table}\n WHERE\n bannerid= " . $oDbh->quote($from, 'integer') . "\n ORDER BY executionorder\n "; $res = $oDbh->exec($query); if (PEAR::isError($res)) { return $res; } // Copy compiledlimitation $doBannersFrom = OA_Dal::staticGetDO('banners', $from); $doBannersTo = OA_DAL::staticGetDO('banners', $to); $doBannersTo->compiledlimitation = $doBannersFrom->compiledlimitation; $doBannersTo->acl_plugins = $doBannersFrom->acl_plugins; $doBannersTo->block = $doBannersFrom->block; $doBannersTo->capping = $doBannersFrom->capping; $doBannersTo->session_capping = $doBannersFrom->session_capping; return $doBannersTo->update(); } }