function testCheckZoneLinkedToActiveCampaign() { $dllZonePartialMock = new PartialMockOA_Dll_Zone(); $dllZonePartialMock->setReturnValue('checkPermissions', true); $doZones = OA_Dal::factoryDO('zones'); $doZones->width = '468'; $doZones->height = '60'; $zoneId = DataGenerator::generateOne($doZones); $zoneId2 = DataGenerator::generateOne($doZones); $doCampaigns = OA_Dal::factoryDo('campaigns'); $campaignId1 = DataGenerator::generateOne($doCampaigns); $doBanners = OA_Dal::factoryDO('banners'); $doBanners->width = '468'; $doBanners->height = '60'; $doBanners->campaignid = $campaignId1; $bannerId = DataGenerator::generateOne($doBanners); $doCampaigns = OA_Dal::factoryDo('campaigns'); $campaignId2 = DataGenerator::generateOne($doCampaigns); // Test zone without banners or campaigns $this->assertFalse($this->dalZones->checkZoneLinkedToActiveCampaign($zoneId)); $dllZonePartialMock->linkBanner($zoneId, $bannerId); $dllZonePartialMock->linkCampaign($zoneId2, $campaignId2); // Test one zone with banner and one with empty campaign $this->assertTrue($this->dalZones->checkZoneLinkedToActiveCampaign($zoneId)); $this->assertTrue($this->dalZones->checkZoneLinkedToActiveCampaign($zoneId2)); $doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId2); $doCampaigns->active = 'f'; $doCampaigns->expire_time = '1970-01-01'; // This date expires campaign $doCampaigns->update(); // Test zone with expired campaign $this->assertFalse($this->dalZones->checkZoneLinkedToActiveCampaign($zoneId2)); }
function testGenerateTags() { TestEnv::installPluginPackage('openXInvocationTags'); $dllZonePartialMock = new PartialMockOA_Dll_Zone($this); $dllZonePartialMock->setReturnValue('checkPermissions', true); $dllZonePartialMock->expectCallCount('checkPermissions', 4); // Non existent zone $this->assertFalse($dllZonePartialMock->generateTags(1, 'foo')); $doZones = OA_Dal::factoryDO('zones'); $doZones->width = '468'; $doZones->height = '60'; $zoneId = DataGenerator::generateOne($doZones); // Non existent code type $this->assertFalse($dllZonePartialMock->generateTags($zoneId, 'foo')); // Not allowed code type $isAllowedAdjsTags = $GLOBALS['_MAX']['CONF']['oxInvocationTags']['isAllowedAdjs']; $GLOBALS['_MAX']['CONF']['oxInvocationTags']['isAllowedAdjs'] = false; $this->assertFalse($dllZonePartialMock->generateTags($zoneId, 'adjs')); // Allowed code type $GLOBALS['_MAX']['CONF']['oxInvocationTags']['isAllowedAdjs'] = true; $tag1 = $dllZonePartialMock->generateTags($zoneId, 'adjs'); $tag2 = $dllZonePartialMock->generateTags($zoneId, 'adjs', array('source' => 'x')); $this->assertTrue($tag1); $this->assertTrue($tag2); $this->assertNotEqual($tag1, $tag2); $GLOBALS['_MAX']['CONF']['oxInvocationTags']['isAllowedAdjs'] = $isAllowedAdjsTags; TestEnv::uninstallPluginPackage('openXInvocationTags'); }