summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-08-01 17:56:33 +0200
committerJoas Schilling <coding@schilljs.com>2016-08-01 17:56:33 +0200
commit6aa5d674d63db69367c97e7241e7d1575ef82690 (patch)
tree74600c656ba8034fd20847cf9853d748df30d189 /apps/workflowengine/tests
parentea4c6bd28568bce811c275d46478f44455cf237d (diff)
downloadnextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.tar.gz
nextcloud-server-6aa5d674d63db69367c97e7241e7d1575ef82690.zip
Translate the errors
Diffstat (limited to 'apps/workflowengine/tests')
-rw-r--r--apps/workflowengine/tests/Check/AbstractStringCheckTest.php64
-rw-r--r--apps/workflowengine/tests/Check/RequestRemoteAddressTest.php23
-rw-r--r--apps/workflowengine/tests/Check/RequestTimeTest.php42
3 files changed, 80 insertions, 49 deletions
diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
index 43818ab8e26..91da8931604 100644
--- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
+++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php
@@ -24,6 +24,30 @@ namespace OCA\WorkflowEngine\Tests\Check;
class AbstractStringCheckTest extends \Test\TestCase {
+ protected function getCheckMock() {
+ $l = $this->getMockBuilder('OCP\IL10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $l->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function($string, $args) {
+ return sprintf($string, $args);
+ });
+
+ $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck')
+ ->setConstructorArgs([
+ $l,
+ ])
+ ->setMethods([
+ 'setPath',
+ 'executeCheck',
+ 'getActualValue',
+ ])
+ ->getMock();
+
+ return $check;
+ }
+
public function dataExecuteStringCheck() {
return [
['is', 'same', 'same', true],
@@ -46,13 +70,7 @@ class AbstractStringCheckTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteStringCheck($operation, $checkValue, $actualValue, $expected) {
- $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck')
- ->setMethods([
- 'setPath',
- 'executeCheck',
- 'getActualValue',
- ])
- ->getMock();
+ $check = $this->getCheckMock();
/** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
$this->assertEquals($expected, $this->invokePrivate($check, 'executeStringCheck', [$operation, $checkValue, $actualValue]));
@@ -73,13 +91,7 @@ class AbstractStringCheckTest extends \Test\TestCase {
* @param string $value
*/
public function testValidateCheck($operator, $value) {
- $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck')
- ->setMethods([
- 'setPath',
- 'executeCheck',
- 'getActualValue',
- ])
- ->getMock();
+ $check = $this->getCheckMock();
/** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
$check->validateCheck($operator, $value);
@@ -87,10 +99,10 @@ class AbstractStringCheckTest extends \Test\TestCase {
public function dataValidateCheckInvalid() {
return [
- ['!!is', '', 1, 'Invalid operator'],
- ['less', '', 1, 'Invalid operator'],
- ['matches', '/Invalid(Regex/', 2, 'Invalid regex'],
- ['!matches', '/Invalid(Regex/', 2, 'Invalid regex'],
+ ['!!is', '', 1, 'The given operator is invalid'],
+ ['less', '', 1, 'The given operator is invalid'],
+ ['matches', '/Invalid(Regex/', 2, 'The given regular expression is invalid'],
+ ['!matches', '/Invalid(Regex/', 2, 'The given regular expression is invalid'],
];
}
@@ -102,13 +114,7 @@ class AbstractStringCheckTest extends \Test\TestCase {
* @param $exceptionMessage
*/
public function testValidateCheckInvalid($operator, $value, $exceptionCode, $exceptionMessage) {
- $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck')
- ->setMethods([
- 'setPath',
- 'executeCheck',
- 'getActualValue',
- ])
- ->getMock();
+ $check = $this->getCheckMock();
try {
/** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */
@@ -134,13 +140,7 @@ class AbstractStringCheckTest extends \Test\TestCase {
* @param bool $expected
*/
public function testMatch($pattern, $subject, $matches, $expected) {
- $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck')
- ->setMethods([
- 'setPath',
- 'executeCheck',
- 'getActualValue',
- ])
- ->getMock();
+ $check = $this->getCheckMock();
$this->invokePrivate($check, 'matches', [$matches]);
diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
index ec8798794df..efe8f6372dd 100644
--- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
+++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
@@ -27,6 +27,21 @@ class RequestRemoteAddressTest extends \Test\TestCase {
/** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
protected $request;
+ /**
+ * @return \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function getL10NMock() {
+ $l = $this->getMockBuilder('OCP\IL10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $l->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function ($string, $args) {
+ return sprintf($string, $args);
+ });
+ return $l;
+ }
+
protected function setUp() {
parent::setUp();
@@ -52,7 +67,7 @@ class RequestRemoteAddressTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckMatchesIPv4($value, $ip, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->request);
+ $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -68,7 +83,7 @@ class RequestRemoteAddressTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckNotMatchesIPv4($value, $ip, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->request);
+ $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -96,7 +111,7 @@ class RequestRemoteAddressTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckMatchesIPv6($value, $ip, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->request);
+ $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
@@ -112,7 +127,7 @@ class RequestRemoteAddressTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckNotMatchesIPv6($value, $ip, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->request);
+ $check = new \OCA\WorkflowEngine\Check\RequestRemoteAddress($this->getL10NMock(), $this->request);
$this->request->expects($this->once())
->method('getRemoteAddress')
diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php
index ca279cca0c3..c07b4bf8775 100644
--- a/apps/workflowengine/tests/Check/RequestTimeTest.php
+++ b/apps/workflowengine/tests/Check/RequestTimeTest.php
@@ -27,6 +27,21 @@ class RequestTimeTest extends \Test\TestCase {
/** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $timeFactory;
+ /**
+ * @return \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function getL10NMock() {
+ $l = $this->getMockBuilder('OCP\IL10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $l->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function ($string, $args) {
+ return sprintf($string, $args);
+ });
+ return $l;
+ }
+
protected function setUp() {
parent::setUp();
@@ -72,7 +87,7 @@ class RequestTimeTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckIn($value, $timestamp, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->timeFactory);
+ $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
->method('getTime')
@@ -88,7 +103,7 @@ class RequestTimeTest extends \Test\TestCase {
* @param bool $expected
*/
public function testExecuteCheckNotIn($value, $timestamp, $expected) {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->timeFactory);
+ $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
$this->timeFactory->expects($this->once())
->method('getTime')
@@ -99,9 +114,9 @@ class RequestTimeTest extends \Test\TestCase {
public function dataValidateCheck() {
return [
- ['in', json_encode(['08:00 Europe/Berlin', '17:00 Europe/Berlin'])],
- ['!in', json_encode(['08:00 Europe/Berlin', '17:00 America/North_Dakota/Beulah'])],
- ['in', json_encode(['08:00 America/Port-au-Prince', '17:00 America/Argentina/San_Luis'])],
+ ['in', '["08:00 Europe/Berlin","17:00 Europe/Berlin"]'],
+ ['!in', '["08:00 Europe/Berlin","17:00 America/North_Dakota/Beulah"]'],
+ ['in', '["08:00 America/Port-au-Prince","17:00 America/Argentina/San_Luis"]'],
];
}
@@ -111,18 +126,19 @@ class RequestTimeTest extends \Test\TestCase {
* @param string $value
*/
public function testValidateCheck($operator, $value) {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->timeFactory);
+ $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
$check->validateCheck($operator, $value);
}
public function dataValidateCheckInvalid() {
return [
- ['!!in', json_encode(['08:00 Europe/Berlin', '17:00 Europe/Berlin']), 1, 'Invalid operator'],
- ['in', json_encode(['28:00 Europe/Berlin', '17:00 Europe/Berlin']), 2, 'Invalid time limits'],
- ['in', json_encode(['08:00 Europa/Berlin', '17:00 Europe/Berlin']), 3, 'Invalid timezone1'],
- ['in', json_encode(['08:00 Europe/Berlin', '17:00 Europa/Berlin']), 3, 'Invalid timezone2'],
- ['in', json_encode(['08:00 Europe/Bearlin', '17:00 Europe/Berlin']), 3, 'Invalid timezone1'],
- ['in', json_encode(['08:00 Europe/Berlin', '17:00 Europe/Bearlin']), 3, 'Invalid timezone2'],
+ ['!!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'],
+ ['in', '["08:00 Europe/Berlin","27:00 Europe/Berlin"]', 2, 'The given time span is invalid'],
+ ['in', '["08:00 Europa/Berlin","17:00 Europe/Berlin"]', 3, 'The given start time is invalid'],
+ ['in', '["08:00 Europe/Berlin","17:00 Europa/Berlin"]', 4, 'The given end time is invalid'],
+ ['in', '["08:00 Europe/Bearlin","17:00 Europe/Berlin"]', 3, 'The given start time is invalid'],
+ ['in', '["08:00 Europe/Berlin","17:00 Europe/Bearlin"]', 4, 'The given end time is invalid'],
];
}
@@ -134,7 +150,7 @@ class RequestTimeTest extends \Test\TestCase {
* @param string $exceptionMessage
*/
public function testValidateCheckInvalid($operator, $value, $exceptionCode, $exceptionMessage) {
- $check = new \OCA\WorkflowEngine\Check\RequestTime($this->timeFactory);
+ $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory);
try {
$check->validateCheck($operator, $value);