diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
commit | d968fc51eab8b0fb259ecbeae517056b99554017 (patch) | |
tree | 10e551cff9fefbefbfd7e5031b57320116bb7fce /vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php | |
parent | c7698e4dc388b7d9a9db368672cb057c1d4d3a01 (diff) | |
parent | 4dd3839c41e18d9724855e7955d8737b6f52dcd6 (diff) | |
download | volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.gz volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.bz2 volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.zip |
Merge remote-tracking branch 'upstream/dev' into plugin-repo
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php | 47 |
1 files changed, 32 insertions, 15 deletions
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', |