Skip to content

Commit

Permalink
Merge pull request #37293 from owncloud/php-7.4-fix-more-test2
Browse files Browse the repository at this point in the history
[Tests-Only] Php 7.4 another pack of fixes
  • Loading branch information
phil-davis authored Apr 22, 2020
2 parents c19ff83 + e4cc9fa commit f448f56
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
5 changes: 3 additions & 2 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,11 @@ private function createFileChunked($data) {
$info = $this->fileView->getFileInfo($targetPath);

if (isset($partStorage, $partInternalPath)) {
$checksums = $partStorage->getMetaData($partInternalPath)['checksum'];
$metadata = $partStorage->getMetaData($partInternalPath);
} else {
$checksums = $targetStorage->getMetaData($targetInternalPath)['checksum'];
$metadata = $targetStorage->getMetaData($targetInternalPath);
}
$checksums = (isset($metadata['checksum'])) ? $metadata['checksum'] : null;

$this->fileView->putFileInfo(
$targetPath,
Expand Down
9 changes: 9 additions & 0 deletions apps/dav/tests/unit/CardDAV/SyncServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ public function testUpdateAndDeleteUser() {
$backend->method('getCard')->willReturnOnConsecutiveCalls(false, [
'carddata' => "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.4.8//EN\r\nUID:test-user\r\nFN:test-user\r\nN:test-user;;;;\r\nEND:VCARD\r\n\r\n"
]);
$backend->method('getAddressBooksByUri')->willReturn([
'id' => 40,
'uri' => 'contacts',
'principaluri' => 'principals/users/admin',
'{DAV:}displayname' => 'Contacts',
'{urn:ietf:params:xml:ns:carddav}addressbook-description' => null,
'{http://calendarserver.org/ns/}getctag' => 1,
'{http://sabredav.org/ns}sync-token' => 1,
]);

/** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/tests/unit/Meta/MetaPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\DAV\PropFind;
use Sabre\DAV\Server;
use Sabre\DAV\Xml\Service as XMLService;
use Test\TestCase;

class MetaPluginTest extends TestCase {
Expand Down Expand Up @@ -75,6 +76,9 @@ public function setUp(): void {

/** @var Server | MockObject $server */
$this->server = $this->createMock(Server::class);

$xmlService = $this->createMock(XMLService::class);
$this->server->xml = $xmlService;
}

public function testInit() {
Expand Down
11 changes: 9 additions & 2 deletions tests/lib/Files/Storage/Wrapper/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,16 @@ function ($path) use ($encrypted) {
->method('getCache')
->with($path)
->willReturn($fileEntry);

if (isset($metaData['fileid'])) {
$fileId = $metaData['fileid'];
} else {
$fileId = null;
}

$fileEntry->expects($this->any())
->method('get')
->with($metaData['fileid']);
->with($fileId);

$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
$this->instance->expects($this->any())->method('verifyUnencryptedSize')
Expand All @@ -295,7 +302,7 @@ function ($path) use ($encrypted) {
public function dataTestGetMetaData() {
return [
['/test.txt', ['size' => 42, 'encrypted' => 2, 'encryptedVersion' => 2, 'fileid' => 1], true, true, 12, ['size' => 12, 'encrypted' => true, 'encryptedVersion' => 2]],
['/test.txt', null, true, true, 12, null],
['/test.txt', [], true, true, 12, ['size' => 12]],
['/test.txt', ['size' => 42, 'encrypted' => 0, 'fileid' => 1], false, false, 12, ['size' => 42, 'encrypted' => false]],
['/test.txt', ['size' => 42, 'encrypted' => false, 'fileid' => 1], true, false, 12, ['size' => 12, 'encrypted' => true]]
];
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/Files/Stream/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function testStreamOpen($mode,
// get a instance of the stream wrapper
$streamWrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption')
->setMethods(['loadContext', 'writeHeader', 'skipHeader'])->disableOriginalConstructor()->getMock();
$streamWrapper->expects($this->once())
->method('loadContext')
->with('ocencryption')
->willReturn(['sourceFileOfRename' => 'dummyfile']);

// set internal properties of the stream wrapper
$stream = new \ReflectionClass('\OC\Files\Stream\Encryption');
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/Files/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ public function testLockBasicOperationUnlocksAfterException(

/** @var Temporary | \PHPUnit\Framework\MockObject\MockObject $storage */
$storage = $this->getMockBuilder(Temporary::class)
->setMethods([$operation])
->setMethods([$operation, 'getEtag'])
->getMock();

Filesystem::mount($storage, [], $this->user . '/');
Expand All @@ -2076,6 +2076,8 @@ public function testLockBasicOperationUnlocksAfterException(
\file_put_contents($realPath . '/files/test.txt', 'blah');

$this->shallThrow = false;
$storage->method('getETag')
->willReturn('abcd');
$storage
->method($operation)
->willReturnCallback(function ($path) {
Expand Down

0 comments on commit f448f56

Please sign in to comment.