diff options
Diffstat (limited to 'tests/Unit/Service/StatusServiceTest.php')
-rw-r--r-- | tests/Unit/Service/StatusServiceTest.php | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/tests/Unit/Service/StatusServiceTest.php b/tests/Unit/Service/StatusServiceTest.php index 8ffed5073..9f87303ae 100644 --- a/tests/Unit/Service/StatusServiceTest.php +++ b/tests/Unit/Service/StatusServiceTest.php @@ -16,18 +16,19 @@ namespace OCA\News\Tests\Unit\Service; use OCA\News\Service\StatusService; use OCP\IConfig; use OCP\IDBConnection; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class StatusServiceTest extends TestCase { /** - * @var \PHPUnit\Framework\MockObject\MockObject|IConfig + * @var MockObject|IConfig */ private $settings; /** - * @var \PHPUnit\Framework\MockObject\MockObject|IDBConnection + * @var MockObject|IDBConnection */ private $connection; @@ -179,4 +180,64 @@ class StatusServiceTest extends TestCase $this->assertEquals($expected, $response); } + /** + * @covers \OCA\News\Service\StatusService::isCronProperlyConfigured + */ + public function testIsProperlyConfiguredNone() + { + $this->settings->expects($this->exactly(2)) + ->method('getAppValue') + ->withConsecutive( + ['core', 'backgroundjobs_mode'], + ['news', 'useCronUpdates'] + ) + ->will($this->returnValueMap([ + ['core', 'backgroundjobs_mode', '', 'ajax'], + ['news', 'useCronUpdates', true, true], + ])); + + $response = $this->service->isCronProperlyConfigured(); + $this->assertFalse($response); + } + + /** + * @covers \OCA\News\Service\StatusService::isCronProperlyConfigured + */ + public function testIsProperlyConfiguredModeCronNoSystem() + { + $this->settings->expects($this->exactly(2)) + ->method('getAppValue') + ->withConsecutive( + ['core', 'backgroundjobs_mode'], + ['news', 'useCronUpdates'] + ) + ->will($this->returnValueMap([ + ['core', 'backgroundjobs_mode', '', 'cron'], + ['news', 'useCronUpdates', true, false], + ])); + + $response = $this->service->isCronProperlyConfigured(); + $this->assertTrue($response); + } + + /** + * @covers \OCA\News\Service\StatusService::isCronProperlyConfigured + */ + public function testIsProperlyConfiguredModeCron() + { + $this->settings->expects($this->exactly(2)) + ->method('getAppValue') + ->withConsecutive( + ['core', 'backgroundjobs_mode'], + ['news', 'useCronUpdates'] + ) + ->will($this->returnValueMap([ + ['core', 'backgroundjobs_mode', '', 'cron'], + ['news', 'useCronUpdates', true, false], + ])); + + $response = $this->service->isCronProperlyConfigured(); + $this->assertTrue($response); + } + }
\ No newline at end of file |