Skip to content

Commit

Permalink
update sabredav and phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Feb 6, 2020
1 parent 946bc1b commit 49c010f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
composer.lock
vendor
coverage.xml
.phpunit.result.cache
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: php
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'

cache:
directories:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
],
"require": {
"php": ">=7.1",
"sabre/dav": "^3.2.0"
"sabre/dav": "^4.0.0"
},
"require-dev": {
"phpunit/phpunit": "^7"
"phpunit/phpunit": "^8"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion tests/DummyBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace SearchDAV\Test;


use Sabre\DAV\INode;
use Sabre\DAV\SimpleFile;
use SearchDAV\Backend\ISearchBackend;
Expand Down
39 changes: 15 additions & 24 deletions tests/QueryParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

namespace SearchDAV\Test;


use PHPUnit\Framework\TestCase;
use Sabre\Xml\ParseException;
use Sabre\Xml\Service;
use SearchDAV\DAV\QueryParser;
use SearchDAV\XML\BasicSearch;
Expand All @@ -49,14 +49,14 @@ public function testParseBasicQuery() {

$this->assertEquals(['{DAV:}getcontentlength'], $search->select);
$this->assertEquals([
new Scope('/container1/', 'infinity')
new Scope('/container1/', 'infinity'),
], $search->from);
$this->assertEquals(new Operator(\SearchDAV\Query\Operator::OPERATION_GREATER_THAN, [
'{DAV:}getcontentlength',
new Literal(10000)
new Literal(10000),
]), $search->where);
$this->assertEquals([
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::ASC)
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::ASC),
], $search->orderBy);
}

Expand All @@ -74,14 +74,14 @@ public function testParseDescending() {

$this->assertEquals(['{DAV:}getcontentlength'], $search->select);
$this->assertEquals([
new Scope('/container1/', 'infinity')
new Scope('/container1/', 'infinity'),
], $search->from);
$this->assertEquals(new Operator(\SearchDAV\Query\Operator::OPERATION_GREATER_THAN, [
'{DAV:}getcontentlength',
new Literal(10000)
new Literal(10000),
]), $search->where);
$this->assertEquals([
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::DESC)
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::DESC),
], $search->orderBy);
}

Expand All @@ -106,12 +106,10 @@ public function testParseNoOrder() {
$this->assertEquals([], $search->orderBy);
}

/**
* @expectedException \Sabre\XML\ParseException
*/
public function testParseNoFrom() {
$query = file_get_contents(__DIR__ . '/nofrom.xml');
$parser = new QueryParser();
$this->expectException(ParseException::class);
$parser->parse($query, null, $rootElementName);
}

Expand Down Expand Up @@ -158,36 +156,29 @@ public function testParseComplexQuery() {

$this->assertEquals(['{DAV:}getcontentlength'], $search->select);
$this->assertEquals([
new Scope('/container1/', 'infinity')
new Scope('/container1/', 'infinity'),
], $search->from);
$this->assertEquals(new Operator(\SearchDAV\Query\Operator::OPERATION_AND, [
new Operator(\SearchDAV\Query\Operator::OPERATION_GREATER_THAN, [
'{DAV:}getcontentlength',
new Literal(10000)
new Literal(10000),
]),
new Operator(\SearchDAV\Query\Operator::OPERATION_LESS_THAN, [
'{DAV:}getcontentlength',
new Literal(90000)
new Literal(90000),
]),
new Operator(\SearchDAV\Query\Operator::OPERATION_CONTAINS, [
'Peter Forsberg'
'Peter Forsberg',
]),
]), $search->where);
$this->assertEquals([
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::ASC)
new Order('{DAV:}getcontentlength', \SearchDAV\Query\Order::ASC),
], $search->orderBy);
}

/**
* @expectedException \Sabre\Xml\LibXMLException
* @expectedExceptionMessage Opening and ending tag mismatch: prop line 17 and gt
* on line 19, column 20
*
* @throws \Sabre\Xml\ParseException
*/
public function testParseWhereBroken()
{
public function testParseWhereBroken() {
$query = file_get_contents(__DIR__ . '/invalidwherebroken.xml');
$this->expectException(ParseException::class);
(new QueryParser())->parse($query, null, $rootElementName);
}
}
3 changes: 1 addition & 2 deletions tests/SearchPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace SearchDAV\Test;


use PHPUnit\Framework\TestCase;
use Sabre\DAV\FS\Directory;
use Sabre\DAV\INode;
Expand All @@ -44,7 +43,7 @@ class SearchPluginTest extends TestCase {
/** @var ISearchBackend|\PHPUnit_Framework_MockObject_MockObject */
private $searchBackend;

protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->searchBackend = $this->getMockBuilder(ISearchBackend::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

require '../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

0 comments on commit 49c010f

Please sign in to comment.