From e9351ef779ea8e462062eaeb3e1824fe66829f7d Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Wed, 12 Jun 2019 14:40:42 +0200 Subject: Add strict type on Notifications tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- tests/lib/Notification/NotificationTest.php | 49 ++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'tests/lib/Notification') 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 @@ * @@ -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')); -- cgit v1.2.3