diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2021-01-02 17:57:17 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-02-13 13:22:57 +0100 |
commit | b4fa772bc5f23f84fc292f5d6bf884543d2bfe51 (patch) | |
tree | 8576ad3ea145f3644804e2fd93de462cfc2c2578 /tests/Unit/Controller/FolderApiControllerTest.php | |
parent | ceba81060303e49b2617397397f2804516052ec9 (diff) |
Remove V1 item API
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests/Unit/Controller/FolderApiControllerTest.php')
-rw-r--r-- | tests/Unit/Controller/FolderApiControllerTest.php | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php index 858e7ff9e..1964f7b47 100644 --- a/tests/Unit/Controller/FolderApiControllerTest.php +++ b/tests/Unit/Controller/FolderApiControllerTest.php @@ -37,7 +37,7 @@ class FolderApiControllerTest extends TestCase private $folderService; private $itemService; - private $folderAPI; + private $class; private $user; private $msg; @@ -65,7 +65,7 @@ class FolderApiControllerTest extends TestCase $this->itemService = $this->getMockBuilder(ItemService::class) ->disableOriginalConstructor() ->getMock(); - $this->folderAPI = new FolderApiController( + $this->class = new FolderApiController( $request, $userSession, $this->folderService, @@ -84,7 +84,7 @@ class FolderApiControllerTest extends TestCase ->with($this->equalTo($this->user->getUID())) ->will($this->returnValue($folders)); - $response = $this->folderAPI->index(); + $response = $this->class->index(); $this->assertEquals( [ @@ -108,7 +108,7 @@ class FolderApiControllerTest extends TestCase ->with($this->user->getUID(), $folderName) ->will($this->returnValue($folder)); - $response = $this->folderAPI->create($folderName); + $response = $this->class->create($folderName); $this->assertEquals( [ @@ -129,7 +129,7 @@ class FolderApiControllerTest extends TestCase ->method('create') ->will($this->throwException(new ServiceConflictException($msg))); - $response = $this->folderAPI->create('hi'); + $response = $this->class->create('hi'); $data = $response->getData(); $this->assertEquals($msg, $data['message']); @@ -148,7 +148,7 @@ class FolderApiControllerTest extends TestCase ->method('create') ->will($this->throwException(new ServiceValidationException($msg))); - $response = $this->folderAPI->create('hi'); + $response = $this->class->create('hi'); $data = $response->getData(); $this->assertEquals($msg, $data['message']); @@ -164,7 +164,7 @@ class FolderApiControllerTest extends TestCase ->method('delete') ->with($this->user->getUID(), 23); - $this->folderAPI->delete(23); + $this->class->delete(23); } @@ -180,7 +180,7 @@ class FolderApiControllerTest extends TestCase ) ); - $response = $this->folderAPI->delete($folderId); + $response = $this->class->delete($folderId); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -197,7 +197,7 @@ class FolderApiControllerTest extends TestCase ->method('rename') ->with($this->user->getUID(), $folderId, $folderName); - $this->folderAPI->update($folderId, $folderName); + $this->class->update($folderId, $folderName); } public function testUpdateDoesNotExist() @@ -213,7 +213,7 @@ class FolderApiControllerTest extends TestCase ) ); - $response = $this->folderAPI->update($folderId, $folderName); + $response = $this->class->update($folderId, $folderName); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -234,7 +234,7 @@ class FolderApiControllerTest extends TestCase ) ); - $response = $this->folderAPI->update($folderId, $folderName); + $response = $this->class->update($folderId, $folderName); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -255,7 +255,7 @@ class FolderApiControllerTest extends TestCase ) ); - $response = $this->folderAPI->update($folderId, $folderName); + $response = $this->class->update($folderId, $folderName); $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); @@ -267,15 +267,25 @@ class FolderApiControllerTest extends TestCase public function testRead() { - $this->itemService->expects($this->once()) - ->method('readFolder') - ->with( - $this->equalTo(3), - $this->equalTo(30), - $this->equalTo($this->user->getUID()) - ); + $this->folderService->expects($this->once()) + ->method('read') + ->with($this->user->getUID(), 3, 30); + + $this->class->read(3, 30); + } + + public function testUpdateRoot() + { + $response = $this->class->update(null, ''); + $this->assertSame(400, $response->getStatus()); + + } + + public function testDeleteRoot() + { + $response = $this->class->delete(null); + $this->assertSame(400, $response->getStatus()); - $this->folderAPI->read(3, 30); } |