[Pkg-owncloud-commits] [php-sabredav] 37/80: Improve the tests of Sabre\DAV
David Prévot
taffit at moszumanska.debian.org
Thu Jan 7 02:56:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 548449ad413cefe265c796a5e0e96150b384a0e4
Author: Jakob Sack <mail at jakobsack.de>
Date: Mon Jan 4 16:22:23 2016 +0100
Improve the tests of Sabre\DAV
- remove unused variables
- fix function parameters
- fix some tests
---
tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php | 2 --
.../Sabre/DAV/Auth/Backend/AbstractDigestTest.php | 5 ----
tests/Sabre/DAV/Auth/Backend/FileTest.php | 2 +-
tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php | 18 +++++++------
tests/Sabre/DAV/Auth/PluginTest.php | 2 +-
tests/Sabre/DAV/FSExt/ServerTest.php | 4 +--
tests/Sabre/DAV/Locks/MSWordTest.php | 12 ++++-----
tests/Sabre/DAV/PartialUpdate/PluginTest.php | 30 +++++++++++-----------
tests/Sabre/DAV/PropPatchTest.php | 9 ++-----
tests/Sabre/DAV/ServerCopyMoveTest.php | 2 +-
tests/Sabre/DAV/ServerEventsTest.php | 6 ++---
tests/Sabre/DAV/ServerPreconditionTest.php | 2 --
tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php | 4 ---
tests/Sabre/DAV/ServerPropsTest.php | 2 +-
tests/Sabre/DAV/ServerRangeTest.php | 4 ---
tests/Sabre/DAV/ServerSimpleTest.php | 6 ++---
tests/Sabre/DAV/ServerUpdatePropertiesTest.php | 24 -----------------
tests/Sabre/DAV/SimpleFileTest.php | 2 +-
tests/Sabre/DAV/Xml/Request/SyncCollectionTest.php | 8 +++---
19 files changed, 50 insertions(+), 94 deletions(-)
diff --git a/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
index e92aa4b..7d7a598 100644
--- a/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
@@ -5,8 +5,6 @@ namespace Sabre\DAV\Auth\Backend;
use Sabre\DAV;
use Sabre\HTTP;
-require_once 'Sabre/HTTP/ResponseMock.php';
-
class AbstractBasicTest extends \PHPUnit_Framework_TestCase {
function testCheckNoHeaders() {
diff --git a/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
index 247befa..8ef416c 100644
--- a/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
@@ -47,11 +47,6 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase {
$response = new HTTP\Response();
$backend = new AbstractDigestMock();
- $this->assertNull(
- $backend->check($request, $response)
- );
-
- $backend = new AbstractDigestMock();
$backend->check($request, $response);
}
diff --git a/tests/Sabre/DAV/Auth/Backend/FileTest.php b/tests/Sabre/DAV/Auth/Backend/FileTest.php
index 72f150a..d2e5fe4 100644
--- a/tests/Sabre/DAV/Auth/Backend/FileTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/FileTest.php
@@ -35,7 +35,7 @@ class FileTest extends \PHPUnit_Framework_TestCase {
$file->loadFile(SABRE_TEMPDIR . '/backend');
$this->assertFalse($file->getDigestHash('realm','blabla'));
- $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user'));
+ $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm','user'));
}
diff --git a/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
index ede432d..8de2be6 100644
--- a/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
@@ -12,15 +12,17 @@ class PDOMySQLTest extends AbstractPDOTest {
$pdo = \Sabre\TestUtil::getMySQLDB();
if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
$pdo->query("DROP TABLE IF EXISTS users");
- $pdo->query("
+ $pdo->query(<<<SQL
create table users (
- id integer unsigned not null primary key auto_increment,
- username varchar(50),
- digesta1 varchar(32),
- email varchar(80),
- displayname varchar(80),
- unique(username)
-);");
+ id integer unsigned not null primary key auto_increment,
+ username varchar(50),
+ digesta1 varchar(32),
+ email varchar(80),
+ displayname varchar(80),
+ unique(username)
+)
+SQL
+ );
$pdo->query("INSERT INTO users (username,digesta1,email,displayname) VALUES ('user','hash','user at example.org','User')");
diff --git a/tests/Sabre/DAV/Auth/PluginTest.php b/tests/Sabre/DAV/Auth/PluginTest.php
index b45b552..0ac9e06 100644
--- a/tests/Sabre/DAV/Auth/PluginTest.php
+++ b/tests/Sabre/DAV/Auth/PluginTest.php
@@ -12,7 +12,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
function testInit() {
$fakeServer = new DAV\Server( new DAV\SimpleCollection('bla'));
- $plugin = new Plugin(new Backend\Mock(),'realm');
+ $plugin = new Plugin(new Backend\Mock());
$this->assertTrue($plugin instanceof Plugin);
$fakeServer->addPlugin($plugin);
$this->assertEquals($plugin, $fakeServer->getPlugin('auth'));
diff --git a/tests/Sabre/DAV/FSExt/ServerTest.php b/tests/Sabre/DAV/FSExt/ServerTest.php
index 2daf63f..63d858d 100644
--- a/tests/Sabre/DAV/FSExt/ServerTest.php
+++ b/tests/Sabre/DAV/FSExt/ServerTest.php
@@ -70,7 +70,7 @@ class ServerTest extends DAV\AbstractServer{
$this->assertEquals([
'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Length' => [0],
+ 'Content-Length' => ['0'],
'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'],
], $this->response->getHeaders());
@@ -161,7 +161,7 @@ class ServerTest extends DAV\AbstractServer{
],$this->response->getHeaders());
$this->assertEquals(204, $this->response->status);
$this->assertEquals('', $this->response->body);
- $this->assertFalse(file_exists($this->tempDir . '/col'));
+ $this->assertFalse(file_exists($this->tempDir . '/testcol'));
}
diff --git a/tests/Sabre/DAV/Locks/MSWordTest.php b/tests/Sabre/DAV/Locks/MSWordTest.php
index e9eeacb..23f2837 100644
--- a/tests/Sabre/DAV/Locks/MSWordTest.php
+++ b/tests/Sabre/DAV/Locks/MSWordTest.php
@@ -10,6 +10,12 @@ require_once 'Sabre/TestUtil.php';
class MSWordTest extends \PHPUnit_Framework_TestCase {
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
function testLockEtc() {
mkdir(SABRE_TEMPDIR . '/mstest');
@@ -54,12 +60,6 @@ class MSWordTest extends \PHPUnit_Framework_TestCase {
}
- function tearDown() {
-
- \Sabre\TestUtil::clearTempDir();
-
- }
-
function getLockRequest() {
$request = HTTP\Sapi::createFromServerArray(array(
diff --git a/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/tests/Sabre/DAV/PartialUpdate/PluginTest.php
index 6068c73..5bd6964 100644
--- a/tests/Sabre/DAV/PartialUpdate/PluginTest.php
+++ b/tests/Sabre/DAV/PartialUpdate/PluginTest.php
@@ -40,7 +40,7 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchNoRange() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PATCH',
'REQUEST_URI' => '/partial',
@@ -53,10 +53,10 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchNotSupported() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
@@ -66,10 +66,10 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchNoContentType() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
@@ -79,10 +79,10 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchBadRange() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
@@ -92,10 +92,10 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchNoLength() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
@@ -105,30 +105,30 @@ class PluginTest extends \Sabre\DAVServerTest {
function testPatchSuccess() {
- $this->node->put('00000000');
+ $this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
$this->assertEquals(204, $response->status, 'Full response body:' . $response->body);
- $this->assertEquals('00011100', $this->node->get());
+ $this->assertEquals('aaabbbaa', $this->node->get());
}
function testPatchNoEndRange() {
- $this->node->put('00000');
+ $this->node->put('aaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
$request->setBody(
- '111'
+ 'bbb'
);
$response = $this->request($request);
$this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString());
- $this->assertEquals('00111', $this->node->get());
+ $this->assertEquals('aaabbb', $this->node->get());
}
diff --git a/tests/Sabre/DAV/PropPatchTest.php b/tests/Sabre/DAV/PropPatchTest.php
index 21b45e7..eb88162 100644
--- a/tests/Sabre/DAV/PropPatchTest.php
+++ b/tests/Sabre/DAV/PropPatchTest.php
@@ -226,10 +226,7 @@ class PropPatchTest extends \PHPUnit_Framework_TestCase {
'{DAV:}a' => 'foo',
]);
- $calledA = false;
- $calledB = false;
-
- $propPatch->handle('{DAV:}a', function() use (&$calledA) {
+ $propPatch->handle('{DAV:}a', function() {
return [];
});
$propPatch->commit();
@@ -346,9 +343,7 @@ class PropPatchTest extends \PHPUnit_Framework_TestCase {
'{DAV:}c' => null,
]);
- $calledA = false;
-
- $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) use (&$calledA) {
+ $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) {
return 'hi';
});
$propPatch->commit();
diff --git a/tests/Sabre/DAV/ServerCopyMoveTest.php b/tests/Sabre/DAV/ServerCopyMoveTest.php
index 3dfbc9e..423bc66 100644
--- a/tests/Sabre/DAV/ServerCopyMoveTest.php
+++ b/tests/Sabre/DAV/ServerCopyMoveTest.php
@@ -143,7 +143,7 @@ class ServerCopyMoveTest extends \PHPUnit_Framework_TestCase {
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(201, $this->response->status, 'Full response: ' . $this->response->getBody(true));
+ $this->assertEquals(201, $this->response->status, 'Full response: ' . $this->response->getBodyAsString());
$this->assertEquals(array(
'X-Sabre-Version' => [Version::VERSION],
diff --git a/tests/Sabre/DAV/ServerEventsTest.php b/tests/Sabre/DAV/ServerEventsTest.php
index 7f995c6..354e689 100644
--- a/tests/Sabre/DAV/ServerEventsTest.php
+++ b/tests/Sabre/DAV/ServerEventsTest.php
@@ -62,7 +62,7 @@ class ServerEventsTest extends AbstractServer {
}
- function beforeBindCancelHandler() {
+ function beforeBindCancelHandler($path) {
return false;
@@ -92,14 +92,14 @@ class ServerEventsTest extends AbstractServer {
function testMethod() {
$k = 1;
- $this->server->on('method', function() use (&$k) {
+ $this->server->on('method', function($request, $response) use (&$k) {
$k+=1;
return false;
});
- $this->server->on('method', function() use (&$k) {
+ $this->server->on('method', function($request, $response) use (&$k) {
$k+=2;
diff --git a/tests/Sabre/DAV/ServerPreconditionTest.php b/tests/Sabre/DAV/ServerPreconditionTest.php
index 170deb7..1dc8d8a 100644
--- a/tests/Sabre/DAV/ServerPreconditionTest.php
+++ b/tests/Sabre/DAV/ServerPreconditionTest.php
@@ -232,7 +232,6 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase {
'REQUEST_URI' => '/foo'
));
- $httpRequest = $httpRequest;
$httpResponse = new HTTP\ResponseMock();
$this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse));
@@ -248,7 +247,6 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase {
'HTTP_IF_MODIFIED_SINCE' => 'Your mother',
'REQUEST_URI' => '/foo'
));
- $httpRequest = $httpRequest;
$httpResponse = new HTTP\ResponseMock();
// Invalid dates must be ignored, so this should return true
diff --git a/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php b/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
index f00b21c..405ed96 100644
--- a/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
+++ b/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
@@ -45,10 +45,6 @@ class ServerPropsInfiniteDepthTest extends AbstractServer {
public function testPropFindEmptyBody() {
- $hasFired = false;
-
- $self = $this;
-
$this->sendRequest("");
$this->assertEquals(207, $this->response->status, 'Incorrect status received. Full response body: ' . $this->response->getBodyAsString());
diff --git a/tests/Sabre/DAV/ServerPropsTest.php b/tests/Sabre/DAV/ServerPropsTest.php
index ac9137a..6d7a8b9 100644
--- a/tests/Sabre/DAV/ServerPropsTest.php
+++ b/tests/Sabre/DAV/ServerPropsTest.php
@@ -86,7 +86,7 @@ class ServerPropsTest extends AbstractServer {
$xml->registerXPathNamespace('d','urn:DAV');
list($data) = $xml->xpath('/d:multistatus/d:response/d:href');
- $this->assertEquals('/test2.txt',(string)$data,'href element should have been /');
+ $this->assertEquals('/test2.txt',(string)$data,'href element should have been /test2.txt');
$data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength');
$this->assertEquals(1,count($data));
diff --git a/tests/Sabre/DAV/ServerRangeTest.php b/tests/Sabre/DAV/ServerRangeTest.php
index 5dfd5ae..15a51c1 100644
--- a/tests/Sabre/DAV/ServerRangeTest.php
+++ b/tests/Sabre/DAV/ServerRangeTest.php
@@ -218,8 +218,6 @@ class ServerRangeTest extends AbstractServer{
*/
function testIfRangeModificationDate() {
- $node = $this->server->tree->getNodeForPath('test.txt');
-
$serverVars = [
'REQUEST_URI' => '/test.txt',
'REQUEST_METHOD' => 'GET',
@@ -253,8 +251,6 @@ class ServerRangeTest extends AbstractServer{
*/
function testIfRangeModificationDateModified() {
- $node = $this->server->tree->getNodeForPath('test.txt');
-
$serverVars = [
'REQUEST_URI' => '/test.txt',
'REQUEST_METHOD' => 'GET',
diff --git a/tests/Sabre/DAV/ServerSimpleTest.php b/tests/Sabre/DAV/ServerSimpleTest.php
index 99742bd..baf0199 100644
--- a/tests/Sabre/DAV/ServerSimpleTest.php
+++ b/tests/Sabre/DAV/ServerSimpleTest.php
@@ -120,7 +120,7 @@ class ServerSimpleTest extends AbstractServer{
'X-Sabre-Version' => [Version::VERSION],
'Content-Type' => ['application/octet-stream'],
'Content-Length' => [13],
- 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))],
+ 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))],
'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'],
],
$this->response->getHeaders()
@@ -380,7 +380,7 @@ class ServerSimpleTest extends AbstractServer{
}
- function exceptionTrigger() {
+ function exceptionTrigger($request, $response) {
throw new Exception('Hola');
@@ -433,7 +433,7 @@ class ServerSimpleTest extends AbstractServer{
}
- function reportHandler($reportName) {
+ function reportHandler($reportName, $result, $path) {
if ($reportName=='{http://www.rooftopsolutions.nl/NS}myreport') {
$this->server->httpResponse->setStatus(418);
diff --git a/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
index dd7b134..7fde11b 100644
--- a/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
+++ b/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
@@ -70,17 +70,6 @@ class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase {
}
- function updatePropFail(&$propertyDelta, &$result, $node) {
-
- $result[404] = array(
- '{DAV:}foo' => null,
- );
- unset($propertyDelta['{DAV:}foo']);
- return false;
-
- }
-
-
function testUpdatePropertiesEventSuccess() {
$tree = array(
@@ -111,17 +100,4 @@ class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase {
}
- function updatePropSuccess(&$propertyDelta, &$result, $node) {
-
- $result[200] = array(
- '{DAV:}foo' => null,
- );
- $result[201] = array(
- '{DAV:}foo2' => null,
- );
- unset($propertyDelta['{DAV:}foo']);
- unset($propertyDelta['{DAV:}foo2']);
- return;
-
- }
}
diff --git a/tests/Sabre/DAV/SimpleFileTest.php b/tests/Sabre/DAV/SimpleFileTest.php
index 406c193..9b083b9 100644
--- a/tests/Sabre/DAV/SimpleFileTest.php
+++ b/tests/Sabre/DAV/SimpleFileTest.php
@@ -10,7 +10,7 @@ class SimpleFileTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('filename.txt', $file->getName());
$this->assertEquals('contents', $file->get());
- $this->assertEquals('8', $file->getSize());
+ $this->assertEquals(8, $file->getSize());
$this->assertEquals('"' . sha1('contents') . '"', $file->getETag());
$this->assertEquals('text/plain', $file->getContentType());
diff --git a/tests/Sabre/DAV/Xml/Request/SyncCollectionTest.php b/tests/Sabre/DAV/Xml/Request/SyncCollectionTest.php
index 6dfecc5..bde1a10 100644
--- a/tests/Sabre/DAV/Xml/Request/SyncCollectionTest.php
+++ b/tests/Sabre/DAV/Xml/Request/SyncCollectionTest.php
@@ -18,7 +18,7 @@ class SyncCollectionTest extends XmlTest {
</d:sync-collection>
';
- $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\SyncCollectionReport']);
+ $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport']);
$elem = new SyncCollectionReport();
$elem->syncLevel = 1;
@@ -42,7 +42,7 @@ class SyncCollectionTest extends XmlTest {
</d:sync-collection>
';
- $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\SyncCollectionReport']);
+ $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport']);
$elem = new SyncCollectionReport();
$elem->syncLevel = 1;
@@ -66,7 +66,7 @@ class SyncCollectionTest extends XmlTest {
</d:sync-collection>
';
- $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\SyncCollectionReport']);
+ $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport']);
$elem = new SyncCollectionReport();
$elem->syncLevel = \Sabre\DAV\Server::DEPTH_INFINITY;
@@ -87,7 +87,7 @@ class SyncCollectionTest extends XmlTest {
</d:sync-collection>
';
- $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\SyncCollectionReport']);
+ $result = $this->parse($xml, ['{DAV:}sync-collection' => 'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport']);
}
--
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