mirror of
https://codeberg.org/icewind/SearchDAV.git
synced 2026-06-03 09:34:08 +02:00
test search with invalid queries
This commit is contained in:
parent
b42b650266
commit
695bb7c694
4 changed files with 92 additions and 0 deletions
|
|
@ -196,4 +196,60 @@ class SearchPluginTest extends \PHPUnit_Framework_TestCase {
|
|||
$expected = $parser->parse(fopen(__DIR__ . '/searchresult.xml', 'r'));
|
||||
$this->assertEquals($expected, $parsedResponse);
|
||||
}
|
||||
|
||||
public function testSearchQueryNoFrom() {
|
||||
$this->searchBackend->expects($this->any())
|
||||
->method('getArbiterPath')
|
||||
->willReturn('foo');
|
||||
|
||||
$plugin = new SearchPlugin($this->searchBackend);
|
||||
$server = new Server();
|
||||
$plugin->initialize($server);
|
||||
|
||||
$request = new Request('SEARCH', '/index.php/foo', [
|
||||
'Content-Type' => 'text/xml'
|
||||
]);
|
||||
$request->setBaseUrl('/index.php');
|
||||
$request->setBody(fopen(__DIR__ . '/nofrom.xml', 'r'));
|
||||
$response = new Response();
|
||||
|
||||
$this->searchBackend->expects($this->any())
|
||||
->method('isValidScope')
|
||||
->willReturn(true);
|
||||
|
||||
$this->searchBackend->expects($this->never())
|
||||
->method('search');
|
||||
|
||||
$plugin->searchHandler($request, $response);
|
||||
|
||||
$this->assertEquals(400, $response->getStatus());
|
||||
}
|
||||
|
||||
public function testSearchQueryNoWhere() {
|
||||
$this->searchBackend->expects($this->any())
|
||||
->method('getArbiterPath')
|
||||
->willReturn('foo');
|
||||
|
||||
$plugin = new SearchPlugin($this->searchBackend);
|
||||
$server = new Server();
|
||||
$plugin->initialize($server);
|
||||
|
||||
$request = new Request('SEARCH', '/index.php/foo', [
|
||||
'Content-Type' => 'text/xml'
|
||||
]);
|
||||
$request->setBaseUrl('/index.php');
|
||||
$request->setBody(fopen(__DIR__ . '/nowhere.xml', 'r'));
|
||||
$response = new Response();
|
||||
|
||||
$this->searchBackend->expects($this->any())
|
||||
->method('isValidScope')
|
||||
->willReturn(true);
|
||||
|
||||
$this->searchBackend->expects($this->never())
|
||||
->method('search');
|
||||
|
||||
$plugin->searchHandler($request, $response);
|
||||
|
||||
$this->assertEquals(400, $response->getStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
tests/phpunit.xml
Normal file
11
tests/phpunit.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit bootstrap="bootstrap.php">
|
||||
<testsuite name='SearchDAV'>
|
||||
<directory suffix='.php'>./</directory>
|
||||
</testsuite>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
Loading…
Add table
Add a link
Reference in a new issue