summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2019-06-14 14:12:50 +0200
committerGitHub <noreply@github.com>2019-06-14 14:12:50 +0200
commitbf18f1ee934b71e21b060450a30e321d98ab2da2 (patch)
tree0c085b17e659c1b8298996689912746636187459 /tests
parent85767660baa8b9e686303b091da8c96b13345f86 (diff)
parente9351ef779ea8e462062eaeb3e1824fe66829f7d (diff)
downloadnextcloud-server-bf18f1ee934b71e21b060450a30e321d98ab2da2.tar.gz
nextcloud-server-bf18f1ee934b71e21b060450a30e321d98ab2da2.zip
Add strict type on Notifications tests (#15935)
Add strict type on Notifications tests
Diffstat (limited to 'tests')
-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'));