diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-12-09 16:55:07 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-12-09 16:55:07 +0100 |
commit | 81d763be4224adeb5676c620d76b3e4ec407187f (patch) | |
tree | b6759ab57bdfc8b660bb57da105eee0e6e6178f1 /tests | |
parent | fdd06ba1f81d07e4597beb0b5b17f44c296b5921 (diff) | |
download | nextcloud-server-81d763be4224adeb5676c620d76b3e4ec407187f.tar.gz nextcloud-server-81d763be4224adeb5676c620d76b3e4ec407187f.zip |
use expectedException annotation, not via method call, for consistency
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/comments/comment.php | 8 | ||||
-rw-r--r-- | tests/lib/comments/manager.php | 34 |
2 files changed, 29 insertions, 13 deletions
diff --git a/tests/lib/comments/comment.php b/tests/lib/comments/comment.php index c6a8f118dd1..ae7e913eaab 100644 --- a/tests/lib/comments/comment.php +++ b/tests/lib/comments/comment.php @@ -44,10 +44,12 @@ class Test_Comments_Comment extends TestCase $this->assertSame($object['id'], $comment->getObjectId()); } + /** + * @expectedException \OCP\Comments\IllegalIDChangeException + */ public function testSetIdIllegalInput() { $comment = new \OC\Comments\Comment(); - $this->setExpectedException('\OCP\Comments\IllegalIDChangeException'); $comment->setId('c23'); $comment->setId('c17'); } @@ -71,12 +73,12 @@ class Test_Comments_Comment extends TestCase /** * @dataProvider simpleSetterProvider + * @expectedException \InvalidArgumentException */ public function testSimpleSetterInvalidInput($field, $input) { $comment = new \OC\Comments\Comment(); $setter = 'set' . $field; - $this->setExpectedException('InvalidArgumentException'); $comment->$setter($input); } @@ -95,11 +97,11 @@ class Test_Comments_Comment extends TestCase /** * @dataProvider roleSetterProvider + * @expectedException \InvalidArgumentException */ public function testSetRoleInvalidInput($role, $type, $id){ $comment = new \OC\Comments\Comment(); $setter = 'set' . $role; - $this->setExpectedException('InvalidArgumentException'); $comment->$setter($type, $id); } diff --git a/tests/lib/comments/manager.php b/tests/lib/comments/manager.php index c8d65c951e3..248de683253 100644 --- a/tests/lib/comments/manager.php +++ b/tests/lib/comments/manager.php @@ -54,15 +54,19 @@ class Test_Comments_Manager extends TestCase return $factory->getManager(); } + /** + * @expectedException \OCP\Comments\NotFoundException + */ public function testGetCommentNotFound() { $manager = $this->getManager(); - $this->setExpectedException('\OCP\Comments\NotFoundException'); $manager->get('22'); } + /** + * @expectedException \InvalidArgumentException + */ public function testGetCommentNotFoundInvalidInput() { $manager = $this->getManager(); - $this->setExpectedException('\InvalidArgumentException'); $manager->get('unexisting22'); } @@ -108,15 +112,19 @@ class Test_Comments_Manager extends TestCase $this->assertEquals($comment->getLatestChildDateTime(), $latestChildDT); } + /** + * @expectedException \OCP\Comments\NotFoundException + */ public function testGetTreeNotFound() { $manager = $this->getManager(); - $this->setExpectedException('\OCP\Comments\NotFoundException'); $manager->getTree('22'); } + /** + * @expectedException \InvalidArgumentException + */ public function testGetTreeNotFoundInvalidIpnut() { $manager = $this->getManager(); - $this->setExpectedException('\InvalidArgumentException'); $manager->getTree('unexisting22'); } @@ -301,10 +309,10 @@ class Test_Comments_Manager extends TestCase /** * @dataProvider invalidCreateArgsProvider + * @expectedException \InvalidArgumentException */ public function testCreateCommentInvalidArguments($aType, $aId, $oType, $oId) { $manager = $this->getManager(); - $this->setExpectedException('\InvalidArgumentException'); $manager->create($aType, $aId, $oType, $oId); } @@ -322,6 +330,9 @@ class Test_Comments_Manager extends TestCase $this->assertSame($comment->getObjectId(), $objectId); } + /** + * @expectedException \OCP\Comments\NotFoundException + */ public function testDelete() { $manager = $this->getManager(); @@ -339,7 +350,6 @@ class Test_Comments_Manager extends TestCase $this->assertTrue($comment instanceof \OCP\Comments\IComment); $done = $manager->delete($id); $this->assertTrue($done); - $this->setExpectedException('\OCP\Comments\NotFoundException'); $manager->get($id); } @@ -381,6 +391,9 @@ class Test_Comments_Manager extends TestCase $this->assertSame($comment->getMessage(), $loadedComment->getMessage()); } + /** + * @expectedException \OCP\Comments\NotFoundException + */ public function testSaveUpdateException() { $manager = $this->getManager(); $comment = new \OC\Comments\Comment(); @@ -394,15 +407,16 @@ class Test_Comments_Manager extends TestCase $manager->delete($comment->getId()); $comment->setMessage('very beautiful, I am really so much impressed!'); - $this->setExpectedException('\OCP\Comments\NotFoundException'); $manager->save($comment); } + /** + * @expectedException \UnexpectedValueException + */ public function testSaveIncomplete() { $manager = $this->getManager(); $comment = new \OC\Comments\Comment(); $comment->setMessage('from no one to nothing'); - $this->setExpectedException('\UnexpectedValueException'); $manager->save($comment); } @@ -442,10 +456,10 @@ class Test_Comments_Manager extends TestCase /** * @dataProvider invalidActorArgsProvider + * @expectedException \InvalidArgumentException */ public function testDeleteReferencesOfActorInvalidInput($type, $id) { $manager = $this->getManager(); - $this->setExpectedException('\InvalidArgumentException'); $manager->deleteReferencesOfActor($type, $id); } @@ -508,10 +522,10 @@ class Test_Comments_Manager extends TestCase /** * @dataProvider invalidObjectArgsProvider + * @expectedException \InvalidArgumentException */ public function testDeleteCommentsAtObjectInvalidInput($type, $id) { $manager = $this->getManager(); - $this->setExpectedException('\InvalidArgumentException'); $manager->deleteCommentsAtObject($type, $id); } |