[Pkg-owncloud-commits] [php-sabredav] 206/275: PropFindAll unittests.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:56:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 7f0b4fd28eb43526697f7672ed16d079bca7a806
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Sat Aug 30 14:49:37 2014 +0200
PropFindAll unittests.
---
tests/Sabre/DAV/Browser/PluginTest.php | 58 +++++++++---------------
tests/Sabre/DAV/Browser/PropFindAllTest.php | 70 +++++++++++++++++++++++++++++
2 files changed, 90 insertions(+), 38 deletions(-)
diff --git a/tests/Sabre/DAV/Browser/PluginTest.php b/tests/Sabre/DAV/Browser/PluginTest.php
index a169cec..20ed0cd 100644
--- a/tests/Sabre/DAV/Browser/PluginTest.php
+++ b/tests/Sabre/DAV/Browser/PluginTest.php
@@ -15,26 +15,23 @@ class PluginTest extends DAV\AbstractServer{
parent::setUp();
$this->server->addPlugin($this->plugin = new Plugin());
+ $this->server->tree->getNodeForPath('')->createDirectory('dir2');
}
function testCollectionGet() {
- $serverVars = array(
- 'REQUEST_URI' => '/dir',
- 'REQUEST_METHOD' => 'GET',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $request = new HTTP\Request('GET', '/dir');
+ $this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
- $this->assertEquals(array(
- 'X-Sabre-Version' => DAV\Version::VERSION,
- 'Content-Type' => 'text/html; charset=utf-8',
- 'Content-Security-Policy' => "img-src 'self'; style-src 'self';"
- ),
+ $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => DAV\Version::VERSION,
+ 'Content-Type' => 'text/html; charset=utf-8',
+ 'Content-Security-Policy' => "img-src 'self'; style-src 'self';"
+ ],
$this->response->headers
);
@@ -44,21 +41,17 @@ class PluginTest extends DAV\AbstractServer{
}
function testCollectionGetRoot() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'GET',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
+ $request = new HTTP\Request('GET', '/');
$this->server->httpRequest = ($request);
$this->server->exec();
$this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
- $this->assertEquals(array(
- 'X-Sabre-Version' => DAV\Version::VERSION,
- 'Content-Type' => 'text/html; charset=utf-8',
- 'Content-Security-Policy' => "img-src 'self'; style-src 'self';"
- ),
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => DAV\Version::VERSION,
+ 'Content-Type' => 'text/html; charset=utf-8',
+ 'Content-Security-Policy' => "img-src 'self'; style-src 'self';"
+ ],
$this->response->headers
);
@@ -80,12 +73,7 @@ class PluginTest extends DAV\AbstractServer{
function testPostOtherContentType() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'POST',
- 'CONTENT_TYPE' => 'text/xml',
- );
- $request = HTTP\Sapi::createFromServerArray($serverVars);
+ $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']);
$this->server->httpRequest = $request;
$this->server->exec();
@@ -95,14 +83,8 @@ class PluginTest extends DAV\AbstractServer{
function testPostNoSabreAction() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'POST',
- 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
- );
- $postVars = array();
-
- $request = HTTP\Sapi::createFromServerArray($serverVars,$postVars);
+ $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);
+ $request->setPostData([]);
$this->server->httpRequest = $request;
$this->server->exec();
diff --git a/tests/Sabre/DAV/Browser/PropFindAllTest.php b/tests/Sabre/DAV/Browser/PropFindAllTest.php
new file mode 100644
index 0000000..08c2080
--- /dev/null
+++ b/tests/Sabre/DAV/Browser/PropFindAllTest.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace Sabre\DAV\Browser;
+
+class PropFindAllTest extends \PHPUnit_Framework_TestCase {
+
+ function testHandleSimple() {
+
+ $pf = new PropFindAll('foo');
+ $pf->handle('{DAV:}displayname', 'foo');
+
+ $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
+ $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
+
+
+ }
+
+ function testHandleCallBack() {
+
+ $pf = new PropFindAll('foo');
+ $pf->handle('{DAV:}displayname', function() { return 'foo'; });
+
+ $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
+ $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
+
+ }
+
+ function testSet() {
+
+ $pf = new PropFindAll('foo');
+ $pf->set('{DAV:}displayname', 'foo');
+
+ $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
+ $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
+
+ }
+
+ function testSetNull() {
+
+ $pf = new PropFindAll('foo');
+ $pf->set('{DAV:}displayname', null);
+
+ $this->assertEquals(404, $pf->getStatus('{DAV:}displayname'));
+ $this->assertEquals(null, $pf->get('{DAV:}displayname'));
+
+ }
+
+ function testGet404Properties() {
+
+ $pf = new PropFindAll('foo');
+ $pf->set('{DAV:}displayname', null);
+ $this->assertEquals(
+ ['{DAV:}displayname'],
+ $pf->get404Properties()
+ );
+
+ }
+
+ function testGet404PropertiesNothing() {
+
+ $pf = new PropFindAll('foo');
+ $pf->set('{DAV:}displayname', 'foo');
+ $this->assertEquals(
+ ['{http://sabredav.org/ns}idk'],
+ $pf->get404Properties()
+ );
+
+ }
+
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list