/** * Test Remove a job */ public function testRemove() { /* Create fake crontabAdapter */ $fakeCrontabAdapter = $this->getMock('TiBeN\\CrontabManager\\CrontabAdapter'); $fakeCrontabAdapter->expects($this->any())->method('readCrontab')->will($this->returnValue(file_get_contents($this->fixturesPath . 'testing_persisted_crontab.txt'))); $fakeCrontabAdapter->expects($this->once())->method('writeCrontab')->with($this->equalTo(file_get_contents($this->fixturesPath . 'testing_removed_crontab.txt'))); $crontabRepository = new CrontabRepository($fakeCrontabAdapter); /* Retrieve job */ $crontabJobs = $crontabRepository->findJobByRegex('/launch\\ -param\\ mycommand/'); /* Apply some local updates on the job to ensure * it is linked by reference to the repository */ $crontabJobs[0]->minutes = '00'; $crontabJobs[0]->hours = '01'; /* Remove job */ $crontabRepository->removeJob($crontabJobs[0]); $crontabRepository->persist(); }