helperMock = $this->getMockBuilder(Helper::class)->disableOriginalConstructor()->getMock(); $this->cron = $objectManager->getObject(SystemBackup::class, ['backupData' => $this->helperMock]); } /** * Test that cron doesn't do anything if backups are disabled. */ public function testDisabled() { $this->helperMock->expects($this->any())->method('isEnabled')->willReturn(false); $this->cron->execute(); } }