Пример #1
0
 /**
  * Method to run all tests for zone statistics
  *
  * @access private
  *
  * @param string $methodName  Method name in Dll
  */
 function _testStatistics($methodName)
 {
     $dllPublisherPartialMock = new PartialMockOA_Dll_Publisher_ZoneTest($this);
     $dllZonePartialMock = new PartialMockOA_Dll_Zone($this);
     $dllPublisherPartialMock->setReturnValue('getDefaultAgencyId', $this->agencyId);
     $dllPublisherPartialMock->setReturnValue('checkPermissions', true);
     $dllPublisherPartialMock->expectCallCount('checkPermissions', 2);
     $dllZonePartialMock->setReturnValue('checkPermissions', true);
     $dllZonePartialMock->expectCallCount('checkPermissions', 5);
     $oZoneInfo = new OA_DLL_ZoneInfo();
     $oPublisherInfo = new OA_DLL_PublisherInfo();
     $oPublisherInfo->publisherName = "Publisher";
     $oPublisherInfo->agencyId = $this->agencyId;
     $dllPublisherPartialMock->modify($oPublisherInfo);
     $oZoneInfo->publisherId = $oPublisherInfo->publisherId;
     // Add
     $this->assertTrue($dllZonePartialMock->modify($oZoneInfo), $dllZonePartialMock->getLastError());
     // Get no data
     $rsZoneStatistics = null;
     $this->assertTrue($dllZonePartialMock->{$methodName}($oZoneInfo->zoneId, new Date('2001-12-01'), new Date('2007-09-19'), false, $rsZoneStatistics), $dllZonePartialMock->getLastError());
     $this->assertTrue(isset($rsZoneStatistics));
     if (is_array($rsZoneStatistics)) {
         $this->assertEqual(count($rsZoneStatistics), 0, 'No records should be returned');
     } else {
         $this->assertEqual($rsZoneStatistics->getRowCount(), 0, 'No records should be returned');
     }
     // Test for wrong date order
     $rsZoneStatistics = null;
     $this->assertTrue(!$dllZonePartialMock->{$methodName}($oZoneInfo->zoneId, new Date('2007-09-19'), new Date('2001-12-01'), false, $rsZoneStatistics) && $dllZonePartialMock->getLastError() == $this->wrongDateError, $this->_getMethodShouldReturnError($this->wrongDateError));
     // Delete
     $this->assertTrue($dllZonePartialMock->delete($oZoneInfo->zoneId), $dllZonePartialMock->getLastError());
     // Test statistics for not existing id
     $rsZoneStatistics = null;
     $this->assertTrue(!$dllZonePartialMock->{$methodName}($oZoneInfo->zoneId, new Date('2001-12-01'), new Date('2007-09-19'), false, $rsZoneStatistics) && $dllZonePartialMock->getLastError() == $this->unknownIdError, $this->_getMethodShouldReturnError($this->unknownIdError));
     $dllZonePartialMock->tally();
 }