configMock = $this->createMock(Config::class); $this->logEntryRotatorFactoryMock = $this->createMock(LogEntryRotatorFactory::class); $this->logRotate = $this->getObject( LogRotate::class, [ 'logEntryRotatorFactory' => $this->logEntryRotatorFactoryMock, 'config' => $this->configMock, ] ); } /** * Test that rotation may proceed when the feature is enabled. * * @covers \Vertex\Tax\Cron\LogRotate::execute() */ public function testRunRotateWhenEnabled() { $this->configMock->method('isLogRotationEnabled') ->willReturn(true); $this->logEntryRotatorFactoryMock->expects($this->once()) ->method('create') ->willReturn( $this->createMock(LogEntryRotator::class) ); $this->logRotate->execute(); } /** * Test that rotating does not run when the feature is disabled. * * @covers \Vertex\Tax\Cron\LogRotate::execute() */ public function testSkipRotateWhenDisabled() { $this->configMock->method('isLogRotationEnabled') ->willReturn(false); $this->logEntryRotatorFactoryMock->expects($this->never()) ->method('create') ->willReturn( $this->createMock(LogEntryRotator::class) ); $this->logRotate->execute(); } }