More fixes
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
799f58391e
commit
ef4b59d341
|
@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\Search;
|
||||||
use OCA\DAV\CalDAV\CalendarHome;
|
use OCA\DAV\CalDAV\CalendarHome;
|
||||||
use OCA\DAV\CalDAV\Search\SearchPlugin;
|
use OCA\DAV\CalDAV\Search\SearchPlugin;
|
||||||
use OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport;
|
use OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport;
|
||||||
|
use Sabre\Xml\Service;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SearchPluginTest extends TestCase {
|
class SearchPluginTest extends TestCase {
|
||||||
|
@ -41,6 +42,7 @@ class SearchPluginTest extends TestCase {
|
||||||
$this->server = $this->createMock(\Sabre\DAV\Server::class);
|
$this->server = $this->createMock(\Sabre\DAV\Server::class);
|
||||||
$this->server->tree = $this->createMock(\Sabre\DAV\Tree::class);
|
$this->server->tree = $this->createMock(\Sabre\DAV\Tree::class);
|
||||||
$this->server->httpResponse = $this->createMock(\Sabre\HTTP\Response::class);
|
$this->server->httpResponse = $this->createMock(\Sabre\HTTP\Response::class);
|
||||||
|
$this->server->xml = new Service();
|
||||||
|
|
||||||
$this->plugin = new SearchPlugin();
|
$this->plugin = new SearchPlugin();
|
||||||
$this->plugin->initialize($this->server);
|
$this->plugin->initialize($this->server);
|
||||||
|
@ -62,6 +64,7 @@ class SearchPluginTest extends TestCase {
|
||||||
$server->expects($this->at(0))
|
$server->expects($this->at(0))
|
||||||
->method('on')
|
->method('on')
|
||||||
->with('report', [$plugin, 'report']);
|
->with('report', [$plugin, 'report']);
|
||||||
|
$server->xml = new Service();
|
||||||
|
|
||||||
$plugin->initialize($server);
|
$plugin->initialize($server);
|
||||||
|
|
||||||
|
@ -93,6 +96,11 @@ class SearchPluginTest extends TestCase {
|
||||||
->method('getHTTPDepth')
|
->method('getHTTPDepth')
|
||||||
->with(2)
|
->with(2)
|
||||||
->will($this->returnValue(2));
|
->will($this->returnValue(2));
|
||||||
|
$this->server
|
||||||
|
->method('getHTTPPrefer')
|
||||||
|
->willReturn([
|
||||||
|
'return' => null
|
||||||
|
]);
|
||||||
$calendarHome->expects($this->at(0))
|
$calendarHome->expects($this->at(0))
|
||||||
->method('calendarSearch')
|
->method('calendarSearch')
|
||||||
->will($this->returnValue([]));
|
->will($this->returnValue([]));
|
||||||
|
|
|
@ -332,7 +332,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.gif'));
|
$this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.gif'));
|
||||||
|
|
||||||
//Create request return
|
//Create request return
|
||||||
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')];
|
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')]];
|
||||||
$this->request->method('getUploadedFile')->willReturn($reqRet);
|
$this->request->method('getUploadedFile')->willReturn($reqRet);
|
||||||
|
|
||||||
$response = $this->avatarController->postAvatar(null);
|
$response = $this->avatarController->postAvatar(null);
|
||||||
|
|
|
@ -284,13 +284,17 @@ class EncryptionTest extends Storage {
|
||||||
->method('getCache')
|
->method('getCache')
|
||||||
->with($path)
|
->with($path)
|
||||||
->willReturn($fileEntry);
|
->willReturn($fileEntry);
|
||||||
$fileEntry->expects($this->any())
|
if ($metaData !== null) {
|
||||||
->method('get')
|
$fileEntry->expects($this->any())
|
||||||
->with($metaData['fileid']);
|
->method('get')
|
||||||
|
->with($metaData['fileid']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
|
$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
|
||||||
$this->instance->expects($this->any())->method('verifyUnencryptedSize')
|
if ($expected !== null) {
|
||||||
->with($path, 0)->willReturn($expected['size']);
|
$this->instance->expects($this->any())->method('verifyUnencryptedSize')
|
||||||
|
->with($path, 0)->willReturn($expected['size']);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->instance->getMetaData($path);
|
$result = $this->instance->getMetaData($path);
|
||||||
if(isset($expected['encrypted'])) {
|
if(isset($expected['encrypted'])) {
|
||||||
|
@ -300,7 +304,12 @@ class EncryptionTest extends Storage {
|
||||||
$this->assertSame($expected['encryptedVersion'], $result['encryptedVersion']);
|
$this->assertSame($expected['encryptedVersion'], $result['encryptedVersion']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->assertSame($expected['size'], $result['size']);
|
|
||||||
|
if ($expected !== null) {
|
||||||
|
$this->assertSame($expected['size'], $result['size']);
|
||||||
|
} else {
|
||||||
|
$this->assertSame(null, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTestGetMetaData() {
|
public function dataTestGetMetaData() {
|
||||||
|
|
|
@ -52,6 +52,9 @@ class CryptoWrappingTest extends TestCase {
|
||||||
$this->crypto->expects($this->any())
|
$this->crypto->expects($this->any())
|
||||||
->method('decrypt')
|
->method('decrypt')
|
||||||
->willReturnCallback(function ($input) {
|
->willReturnCallback(function ($input) {
|
||||||
|
if ($input === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return substr($input, 1, -1);
|
return substr($input, 1, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue