objects['serviceFactory'] = $this->getMockBuilder('\\Espo\\Core\\ServiceFactory')->disableOriginalConstructor()->getMock(); $this->objects['config'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Config')->disableOriginalConstructor()->getMock(); $this->objects['fileManager'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\File\\Manager')->disableOriginalConstructor()->getMock(); $this->objects['scheduledJob'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\ScheduledJob')->disableOriginalConstructor()->getMock(); $this->objects['entityManager'] = $this->getMockBuilder('\\Espo\\Core\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->objects['injectableFactory'] = $this->getMockBuilder('\\Espo\\Core\\InjectableFactory')->disableOriginalConstructor()->getMock(); $this->object = new \Espo\Core\CronManager( $this->objects['config'], $this->objects['fileManager'], $this->objects['entityManager'], $this->objects['serviceFactory'], $this->objects['injectableFactory'], $this->objects['scheduledJob'] ); $this->reflection = new ReflectionHelper($this->object); } protected function tearDown() : void { $this->object = NULL; } function testCheckLastRunTimeFileDoesnotExist() { $this->objects['fileManager'] ->expects($this->once()) ->method('getPhpContents') ->will($this->returnValue(false)); $this->objects['config'] ->expects($this->any()) ->method('get') ->will($this->returnValue(50)); $this->assertTrue( $this->reflection->invokeMethod('checkLastRunTime', array())); } public function testCheckLastRunTime() { $this->objects['fileManager'] ->expects($this->once()) ->method('getPhpContents') ->will($this->returnValue(array( 'time' => time() - 60, ))); $this->objects['config'] ->expects($this->any()) ->method('get') ->will($this->returnValue(50)); $this->assertTrue( $this->reflection->invokeMethod('checkLastRunTime', array())); } public function testCheckLastRunTimeTooFrequency() { $this->objects['fileManager'] ->expects($this->once()) ->method('getPhpContents') ->will($this->returnValue(array( 'time' => time() - 49, ))); $this->objects['config'] ->expects($this->exactly(1)) ->method('get') ->will($this->returnValue(50)); $this->assertFalse($this->reflection->invokeMethod('checkLastRunTime', array())); } }