summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-11-17 09:26:13 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-11-17 09:26:13 +0100
commit2fde6a77d7b586a5f51fdc9a93da1f3961e696e3 (patch)
tree1e1aee5882ea17df1e0a9cde9f54a49243c47f26 /tests
parent705d208a8aba55cdb509380db19a0b4e2413d1eb (diff)
downloadnextcloud-server-2fde6a77d7b586a5f51fdc9a93da1f3961e696e3.tar.gz
nextcloud-server-2fde6a77d7b586a5f51fdc9a93da1f3961e696e3.zip
Add tests for the "return $this" and fix it on the new method
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/notification/actiontest.php52
-rw-r--r--tests/lib/notification/notificationtest.php26
2 files changed, 58 insertions, 20 deletions
diff --git a/tests/lib/notification/actiontest.php b/tests/lib/notification/actiontest.php
index a6157d6c56e..0044df82cd1 100644
--- a/tests/lib/notification/actiontest.php
+++ b/tests/lib/notification/actiontest.php
@@ -49,7 +49,7 @@ class ActionTest extends TestCase {
*/
public function testSetLabel($label) {
$this->assertSame('', $this->action->getLabel());
- $this->action->setLabel($label);
+ $this->assertSame($this->action, $this->action->setLabel($label));
$this->assertSame($label, $this->action->getLabel());
}
@@ -68,7 +68,7 @@ class ActionTest extends TestCase {
/**
* @dataProvider dataSetLabelInvalid
- * @param string $label
+ * @param mixed $label
*
* @expectedException \InvalidArgumentException
*/
@@ -90,7 +90,7 @@ class ActionTest extends TestCase {
*/
public function testSetParsedLabel($label) {
$this->assertSame('', $this->action->getParsedLabel());
- $this->action->setParsedLabel($label);
+ $this->assertSame($this->action, $this->action->setParsedLabel($label));
$this->assertSame($label, $this->action->getParsedLabel());
}
@@ -108,7 +108,7 @@ class ActionTest extends TestCase {
/**
* @dataProvider dataSetParsedLabelInvalid
- * @param string $label
+ * @param mixed $label
*
* @expectedException \InvalidArgumentException
*/
@@ -132,7 +132,7 @@ class ActionTest extends TestCase {
*/
public function testSetLink($link, $type) {
$this->assertSame('', $this->action->getLink());
- $this->action->setLink($link, $type);
+ $this->assertSame($this->action, $this->action->setLink($link, $type));
$this->assertSame($link, $this->action->getLink());
$this->assertSame($type, $this->action->getRequestType());
}
@@ -162,8 +162,8 @@ class ActionTest extends TestCase {
/**
* @dataProvider dataSetLinkInvalid
- * @param string $link
- * @param string $type
+ * @param mixed $link
+ * @param mixed $type
*
* @expectedException \InvalidArgumentException
*/
@@ -171,6 +171,44 @@ class ActionTest extends TestCase {
$this->action->setLink($link, $type);
}
+ public function dataSetPrimary() {
+ return [
+ [true],
+ [false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataSetPrimary
+ * @param bool $primary
+ */
+ public function testSetPrimary($primary) {
+ $this->assertSame(false, $this->action->isPrimary());
+ $this->assertSame($this->action, $this->action->setPrimary($primary));
+ $this->assertSame($primary, $this->action->isPrimary());
+ }
+
+ public function dataSetPrimaryInvalid() {
+ return [
+ [0],
+ [1],
+ [''],
+ [str_repeat('a', 257)],
+ [[]],
+ [[str_repeat('a', 257)]],
+ ];
+ }
+
+ /**
+ * @dataProvider dataSetPrimaryInvalid
+ * @param mixed $primary
+ *
+ * @expectedException \InvalidArgumentException
+ */
+ public function testSetPrimaryInvalid($primary) {
+ $this->action->setPrimary($primary);
+ }
+
public function testIsValid() {
$this->assertFalse($this->action->isValid());
$this->assertFalse($this->action->isValidParsed());
diff --git a/tests/lib/notification/notificationtest.php b/tests/lib/notification/notificationtest.php
index 8be49ebdc17..662dc5a6176 100644
--- a/tests/lib/notification/notificationtest.php
+++ b/tests/lib/notification/notificationtest.php
@@ -93,7 +93,7 @@ class NotificationTest extends TestCase {
*/
public function testSetApp($app) {
$this->assertSame('', $this->notification->getApp());
- $this->notification->setApp($app);
+ $this->assertSame($this->notification, $this->notification->setApp($app));
$this->assertSame($app, $this->notification->getApp());
}
@@ -121,7 +121,7 @@ class NotificationTest extends TestCase {
*/
public function testSetUser($user) {
$this->assertSame('', $this->notification->getUser());
- $this->notification->setUser($user);
+ $this->assertSame($this->notification, $this->notification->setUser($user));
$this->assertSame($user, $this->notification->getUser());
}
@@ -149,7 +149,7 @@ class NotificationTest extends TestCase {
*/
public function testSetTimestamp($timestamp) {
$this->assertSame(0, $this->notification->getTimestamp());
- $this->notification->setTimestamp($timestamp);
+ $this->assertSame($this->notification, $this->notification->setTimestamp($timestamp));
$this->assertSame($timestamp, $this->notification->getTimestamp());
}
@@ -182,7 +182,7 @@ class NotificationTest extends TestCase {
public function testSetObject($type, $id) {
$this->assertSame('', $this->notification->getObjectType());
$this->assertSame(0, $this->notification->getObjectId());
- $this->notification->setObject($type, $id);
+ $this->assertSame($this->notification, $this->notification->setObject($type, $id));
$this->assertSame($type, $this->notification->getObjectType());
$this->assertSame($id, $this->notification->getObjectId());
}
@@ -233,7 +233,7 @@ class NotificationTest extends TestCase {
public function testSetSubject($subject, $parameters) {
$this->assertSame('', $this->notification->getSubject());
$this->assertSame([], $this->notification->getSubjectParameters());
- $this->notification->setSubject($subject, $parameters);
+ $this->assertSame($this->notification, $this->notification->setSubject($subject, $parameters));
$this->assertSame($subject, $this->notification->getSubject());
$this->assertSame($parameters, $this->notification->getSubjectParameters());
}
@@ -262,7 +262,7 @@ class NotificationTest extends TestCase {
*/
public function testSetParsedSubject($subject) {
$this->assertSame('', $this->notification->getParsedSubject());
- $this->notification->setParsedSubject($subject);
+ $this->assertSame($this->notification, $this->notification->setParsedSubject($subject));
$this->assertSame($subject, $this->notification->getParsedSubject());
}
@@ -296,7 +296,7 @@ class NotificationTest extends TestCase {
public function testSetMessage($message, $parameters) {
$this->assertSame('', $this->notification->getMessage());
$this->assertSame([], $this->notification->getMessageParameters());
- $this->notification->setMessage($message, $parameters);
+ $this->assertSame($this->notification, $this->notification->setMessage($message, $parameters));
$this->assertSame($message, $this->notification->getMessage());
$this->assertSame($parameters, $this->notification->getMessageParameters());
}
@@ -325,7 +325,7 @@ class NotificationTest extends TestCase {
*/
public function testSetParsedMessage($message) {
$this->assertSame('', $this->notification->getParsedMessage());
- $this->notification->setParsedMessage($message);
+ $this->assertSame($this->notification, $this->notification->setParsedMessage($message));
$this->assertSame($message, $this->notification->getParsedMessage());
}
@@ -353,7 +353,7 @@ class NotificationTest extends TestCase {
*/
public function testSetLink($link) {
$this->assertSame('', $this->notification->getLink());
- $this->notification->setLink($link);
+ $this->assertSame($this->notification, $this->notification->setLink($link));
$this->assertSame($link, $this->notification->getLink());
}
@@ -387,7 +387,7 @@ class NotificationTest extends TestCase {
$action->expects($this->never())
->method('isValidParsed');
- $this->notification->addAction($action);
+ $this->assertSame($this->notification, $this->notification->addAction($action));
$this->assertEquals([$action], $this->notification->getActions());
$this->assertEquals([], $this->notification->getParsedActions());
@@ -422,7 +422,7 @@ class NotificationTest extends TestCase {
->method('isPrimary')
->willReturn(true);
- $this->notification->addAction($action);
+ $this->assertSame($this->notification, $this->notification->addAction($action));
$this->setExpectedException('\InvalidArgumentException');
$this->notification->addAction($action);
@@ -439,7 +439,7 @@ class NotificationTest extends TestCase {
$action->expects($this->never())
->method('isValid');
- $this->notification->addParsedAction($action);
+ $this->assertSame($this->notification, $this->notification->addParsedAction($action));
$this->assertEquals([$action], $this->notification->getParsedActions());
$this->assertEquals([], $this->notification->getActions());
@@ -474,7 +474,7 @@ class NotificationTest extends TestCase {
->method('isPrimary')
->willReturn(true);
- $this->notification->addParsedAction($action);
+ $this->assertSame($this->notification, $this->notification->addParsedAction($action));
$this->setExpectedException('\InvalidArgumentException');
$this->notification->addParsedAction($action);