tree[] = $this->sharingNodeMock = new Mock\SharedNode( 'shareable', Plugin::ACCESS_SHAREDOWNER ); } function testShareResource() { $body = << mailto:eric@example.com Eric York Shared workspace XML; $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body); $response = $this->request($request); $this->assertEquals(200, $response->getStatus(), (string)$response->getBodyAsString()); $expected = [ new Sharee([ 'href' => 'mailto:eric@example.com', 'properties' => [ '{DAV:}displayname' => 'Eric York', ], 'access' => Plugin::ACCESS_READWRITE, 'comment' => 'Shared workspace', 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, ]) ]; $this->assertEquals( $expected, $this->sharingNodeMock->getInvites() ); } /** * @depends testShareResource */ function testShareResourceRemoveAccess() { // First we just want to execute all the actions from the first // test. $this->testShareResource(); $body = << mailto:eric@example.com XML; $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body); $response = $this->request($request); $this->assertEquals(200, $response->getStatus(), (string)$response->getBodyAsString()); $expected = []; $this->assertEquals( $expected, $this->sharingNodeMock->getInvites() ); } /** * @depends testShareResource */ function testShareResourceInviteProperty() { // First we just want to execute all the actions from the first // test. $this->testShareResource(); $body = << XML; $request = new Request('PROPFIND', '/shareable', ['Content-Type' => 'application/xml'], $body); $response = $this->request($request); $this->assertEquals(207, $response->getStatus()); $expected = << /shareable mailto:eric@example.com Eric York urn:example:bar HTTP/1.1 200 OK XML; $this->assertXmlStringEqualsXmlString($expected, $response->getBodyAsString()); } function testShareResourceNotFound() { $body = << mailto:eric@example.com Eric York Shared workspace XML; $request = new Request('POST', '/not-found', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body); $response = $this->request($request, 404); } function testShareResourceNotISharedNode() { $body = << mailto:eric@example.com Eric York Shared workspace XML; $request = new Request('POST', '/', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body); $response = $this->request($request, 403); } function testShareResourceUnknownDoc() { $body = << XML; $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body); $response = $this->request($request, 400); } }