protected function _testMassOfferUpdateJobSetup($isFirstTime) { $mockScheduleCollection = $this->mockResource('cron/schedule_collection', array('addFieldToFilter', 'load', 'count')); $countReturn = $isFirstTime ? 0 : mt_rand(1, mt_getrandmax()); $mockScheduleCollection->expects($this->once())->method('count')->will($this->returnValue($countReturn)); $mockScheduleCollection->expects($this->any())->method('addFieldToFilter')->will($this->returnSelf()); $mockScheduleCollection->expects($this->once())->method('load')->will($this->returnSelf()); $mockSchedule = $this->mockModel('cron/schedule', array('getCollection', 'setJobCode', 'setCreatedAt', 'setScheduledAt', 'save')); $mockSchedule->expects($this->once())->method('getCollection')->will($this->returnValue($mockScheduleCollection)); $mockSchedule->expects($isFirstTime ? $this->once() : $this->never())->method('setJobCode')->will($this->returnSelf()); $mockSchedule->expects($isFirstTime ? $this->once() : $this->never())->method('setCreatedAt')->will($this->returnSelf()); $mockSchedule->expects($isFirstTime ? $this->once() : $this->never())->method('setScheduledAt')->will($this->returnSelf()); $mockSchedule->expects($isFirstTime ? $this->once() : $this->never())->method('save'); $retObj = $this->_object->massOfferUpdateJobSetup(); $this->assertSame($this->_object, $retObj); }