aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/tests/Check/RequestTimeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workflowengine/tests/Check/RequestTimeTest.php')
-rw-r--r--apps/workflowengine/tests/Check/RequestTimeTest.php46
1 files changed, 15 insertions, 31 deletions
diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php
index 6b56bb9427a..21127d4d56e 100644
--- a/apps/workflowengine/tests/Check/RequestTimeTest.php
+++ b/apps/workflowengine/tests/Check/RequestTimeTest.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -8,19 +11,13 @@ namespace OCA\WorkflowEngine\Tests\Check;
use OCA\WorkflowEngine\Check\RequestTime;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IL10N;
+use PHPUnit\Framework\MockObject\MockObject;
class RequestTimeTest extends \Test\TestCase {
+ protected ITimeFactory&MockObject $timeFactory;
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- protected $timeFactory;
-
- /**
- * @return IL10N|\PHPUnit\Framework\MockObject\MockObject
- */
- protected function getL10NMock() {
- $l = $this->getMockBuilder(IL10N::class)
- ->disableOriginalConstructor()
- ->getMock();
+ protected function getL10NMock(): IL10N&MockObject {
+ $l = $this->createMock(IL10N::class);
$l->expects($this->any())
->method('t')
->willReturnCallback(function ($string, $args) {
@@ -32,11 +29,10 @@ class RequestTimeTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory')
- ->getMock();
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
}
- public function dataExecuteCheck() {
+ public static function dataExecuteCheck(): array {
return [
[json_encode(['08:00 Europe/Berlin', '17:00 Europe/Berlin']), 1467870105, false], // 2016-07-07T07:41:45+02:00
[json_encode(['08:00 Europe/Berlin', '17:00 Europe/Berlin']), 1467873705, true], // 2016-07-07T08:41:45+02:00
@@ -69,11 +65,8 @@ class RequestTimeTest extends \Test\TestCase {
/**
* @dataProvider dataExecuteCheck
- * @param string $value
- * @param int $timestamp
- * @param bool $expected
*/
- public function testExecuteCheckIn($value, $timestamp, $expected): void {
+ public function testExecuteCheckIn(string $value, int $timestamp, bool $expected): void {
$check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
@@ -85,11 +78,8 @@ class RequestTimeTest extends \Test\TestCase {
/**
* @dataProvider dataExecuteCheck
- * @param string $value
- * @param int $timestamp
- * @param bool $expected
*/
- public function testExecuteCheckNotIn($value, $timestamp, $expected): void {
+ public function testExecuteCheckNotIn(string $value, int $timestamp, bool $expected): void {
$check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
@@ -99,7 +89,7 @@ class RequestTimeTest extends \Test\TestCase {
$this->assertEquals(!$expected, $check->executeCheck('!in', $value));
}
- public function dataValidateCheck() {
+ public static function dataValidateCheck(): array {
return [
['in', '["08:00 Europe/Berlin","17:00 Europe/Berlin"]'],
['!in', '["08:00 Europe/Berlin","17:00 America/North_Dakota/Beulah"]'],
@@ -109,16 +99,14 @@ class RequestTimeTest extends \Test\TestCase {
/**
* @dataProvider dataValidateCheck
- * @param string $operator
- * @param string $value
*/
- public function testValidateCheck($operator, $value): void {
+ public function testValidateCheck(string $operator, string $value): void {
$check = new RequestTime($this->getL10NMock(), $this->timeFactory);
$check->validateCheck($operator, $value);
$this->addToAssertionCount(1);
}
- public function dataValidateCheckInvalid() {
+ public static function dataValidateCheckInvalid(): array {
return [
['!!in', '["08:00 Europe/Berlin","17:00 Europe/Berlin"]', 1, 'The given operator is invalid'],
['in', '["28:00 Europe/Berlin","17:00 Europe/Berlin"]', 2, 'The given time span is invalid'],
@@ -132,12 +120,8 @@ class RequestTimeTest extends \Test\TestCase {
/**
* @dataProvider dataValidateCheckInvalid
- * @param string $operator
- * @param string $value
- * @param int $exceptionCode
- * @param string $exceptionMessage
*/
- public function testValidateCheckInvalid($operator, $value, $exceptionCode, $exceptionMessage): void {
+ public function testValidateCheckInvalid(string $operator, string $value, int $exceptionCode, string $exceptionMessage): void {
$check = new RequestTime($this->getL10NMock(), $this->timeFactory);
try {