From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- .../dav/tests/Sabre/CardDAV/ValidateVCardTest.php | 47 +++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php index 1f52f30a7..ad8495c13 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php @@ -31,6 +31,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { ); $this->server = new DAV\Server($tree); + $this->server->sapi = new HTTP\SapiMock(); $this->server->debugExceptions = true; $plugin = new Plugin(); @@ -52,20 +53,20 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { function testCreateFile() { - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', )); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status); + $this->assertEquals(415, $response->status); } function testCreateFileValid() { - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', )); @@ -73,7 +74,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { $response = $this->request($request); - $this->assertEquals('HTTP/1.1 201 Created', $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); $expected = array( 'uri' => 'blabla.vcf', 'carddata' => "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", @@ -85,24 +86,40 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { function testCreateFileNoUID() { - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - )); + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 201 Created', $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); $foo = $this->cardBackend->getCard('addressbook1','blabla.vcf'); $this->assertTrue(strpos($foo['carddata'],'UID')!==false); } + function testCreateFileJson() { + + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); + $request->setBody('[ "vcard" , [ [ "UID" , {}, "text", "foo" ] ] ]'); + + $response = $this->request($request); + + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + + $foo = $this->cardBackend->getCard('addressbook1','blabla.vcf'); + $this->assertEquals("BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", $foo['carddata']); + + } function testCreateFileVCalendar() { - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', )); @@ -110,28 +127,28 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { $response = $this->request($request); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testUpdateFile() { $this->cardBackend->createCard('addressbook1','blabla.vcf','foo'); - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', )); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status); + $this->assertEquals(415, $response->status); } function testUpdateFileParsableBody() { $this->cardBackend->createCard('addressbook1','blabla.vcf','foo'); - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', )); @@ -140,7 +157,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { $response = $this->request($request); - $this->assertEquals('HTTP/1.1 204 No Content', $response->status); + $this->assertEquals(204, $response->status); $expected = array( 'uri' => 'blabla.vcf', -- cgit v1.2.3