Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-06-12 15:40:42 +0300
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-06-13 15:58:38 +0300
commite9351ef779ea8e462062eaeb3e1824fe66829f7d (patch)
treebbb3424408068cb6826853b494321d35ba8f800b /tests/lib/Notification
parent7382655a2c5a613cc923e9abd8142119d9de8d5c (diff)
Add strict type on Notifications tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'tests/lib/Notification')
-rw-r--r--tests/lib/Notification/NotificationTest.php49
1 files changed, 42 insertions, 7 deletions
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index 5aa24fc762a..7517be715ee 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -1,4 +1,5 @@
<?php
+declare (strict_types = 1);
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
*
@@ -43,6 +44,7 @@ class NotificationTest extends TestCase {
protected function dataValidString($maxLength) {
$dataSets = [
['test1'],
+ ['1564'],
[str_repeat('a', 1)],
];
if ($maxLength !== false) {
@@ -53,20 +55,24 @@ class NotificationTest extends TestCase {
protected function dataInvalidString($maxLength) {
$dataSets = [
- [true],
- [false],
- [0],
- [1],
- [''],
- [[]],
+ ['']
];
if ($maxLength !== false) {
$dataSets[] = [str_repeat('a', $maxLength + 1)];
- $dataSets[] = [[str_repeat('a', $maxLength + 1)]];
}
return $dataSets;
}
+ protected function dataInvalidStringType() {
+ return [
+ [true],
+ [false],
+ [16412],
+ [[]],
+ [null],
+ ];
+ }
+
protected function dataInvalidInt() {
return [
[true],
@@ -98,6 +104,10 @@ class NotificationTest extends TestCase {
return $this->dataInvalidString(32);
}
+ public function dataSetAppInvalidType() {
+ return $this->dataInvalidStringType();
+ }
+
/**
* @dataProvider dataSetAppInvalid
* @param mixed $app
@@ -108,6 +118,17 @@ class NotificationTest extends TestCase {
$this->notification->setApp($app);
}
+ /**
+ * @dataProvider dataSetAppInvalidType
+ * @param mixed $app
+ *
+ * @expectedException \TypeError
+ */
+ public function testSetAppInvalidType($app) {
+ $this->notification->setApp($app);
+ }
+
+
public function dataSetUser() {
return $this->dataValidString(64);
}
@@ -126,6 +147,10 @@ class NotificationTest extends TestCase {
return $this->dataInvalidString(64);
}
+ public function dataSetUserInvalidType() {
+ return $this->dataInvalidStringType();
+ }
+
/**
* @dataProvider dataSetUserInvalid
* @param mixed $user
@@ -136,6 +161,16 @@ class NotificationTest extends TestCase {
$this->notification->setUser($user);
}
+ /**
+ * @dataProvider dataSetUserInvalidType
+ * @param mixed $user
+ *
+ * @expectedException \TypeError
+ */
+ public function testSetUserInvalidType($user) {
+ $this->notification->setUser($user);
+ }
+
public function dataSetDateTime() {
$past = new \DateTime();
$past->sub(new \DateInterval('P1Y'));