Skip to content

Commit e39d657

Browse files
Merge pull request #23882 from nextcloud/tests/oracle
Run unit tests against oracle
2 parents cdfad9a + 0c695d9 commit e39d657

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+905
-91
lines changed

.github/workflows/oci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- stable*
9+
10+
jobs:
11+
phpunit-oci8:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
# do not stop on another job's failure
16+
fail-fast: false
17+
matrix:
18+
php-versions: [ '7.4' ]
19+
databases: [ 'oci' ]
20+
21+
name: php${{ matrix.php-versions }}-${{ matrix.databases }}
22+
23+
services:
24+
oracle:
25+
image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2"
26+
ports:
27+
- "1521:1521"
28+
29+
steps:
30+
- name: Checkout server
31+
uses: actions/checkout@v2
32+
33+
- name: Checkout submodules
34+
shell: bash
35+
run: |
36+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
37+
git submodule sync --recursive
38+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
39+
40+
- name: Set up php ${{ matrix.php-versions }}
41+
uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: ${{ matrix.php-versions }}
44+
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, oci8
45+
tools: phpunit:8.5.2
46+
coverage: none
47+
48+
- name: Set up Nextcloud
49+
run: |
50+
mkdir data
51+
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
52+
php -f index.php
53+
54+
- name: PHPUnit
55+
working-directory: tests
56+
run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB

apps/dav/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>WebDAV</name>
66
<summary>WebDAV endpoint</summary>
77
<description>WebDAV endpoint</description>
8-
<version>1.17.0</version>
8+
<version>1.17.1</version>
99
<licence>agpl</licence>
1010
<author>owncloud.org</author>
1111
<namespace>DAV</namespace>

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir . '/../lib/Migration/Version1011Date20190725113607.php',
231231
'OCA\\DAV\\Migration\\Version1011Date20190806104428' => $baseDir . '/../lib/Migration/Version1011Date20190806104428.php',
232232
'OCA\\DAV\\Migration\\Version1012Date20190808122342' => $baseDir . '/../lib/Migration/Version1012Date20190808122342.php',
233+
'OCA\\DAV\\Migration\\Version1016Date20201109085907' => $baseDir . '/../lib/Migration/Version1016Date20201109085907.php',
233234
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
234235
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
235236
'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',

apps/dav/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class ComposerStaticInitDAV
245245
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190725113607.php',
246246
'OCA\\DAV\\Migration\\Version1011Date20190806104428' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190806104428.php',
247247
'OCA\\DAV\\Migration\\Version1012Date20190808122342' => __DIR__ . '/..' . '/../lib/Migration/Version1012Date20190808122342.php',
248+
'OCA\\DAV\\Migration\\Version1016Date20201109085907' => __DIR__ . '/..' . '/../lib/Migration/Version1016Date20201109085907.php',
248249
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
249250
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
250251
'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,13 @@ public function getCalendarsForUserCount($principalUri, $excludeBirthday = true)
242242
$principalUri = $this->convertPrincipal($principalUri, true);
243243
$query = $this->db->getQueryBuilder();
244244
$query->select($query->func()->count('*'))
245-
->from('calendars')
246-
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
245+
->from('calendars');
246+
247+
if ($principalUri === '') {
248+
$query->where($query->expr()->emptyString('principaluri'));
249+
} else {
250+
$query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
251+
}
247252

248253
if ($excludeBirthday) {
249254
$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
@@ -293,13 +298,21 @@ public function getCalendarsForUser($principalUri) {
293298

294299
// Making fields a comma-delimited list
295300
$query = $this->db->getQueryBuilder();
296-
$query->select($fields)->from('calendars')
297-
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
298-
->orderBy('calendarorder', 'ASC');
299-
$stmt = $query->execute();
301+
$query->select($fields)
302+
->from('calendars')
303+
->orderBy('calendarorder', 'ASC');
304+
305+
if ($principalUri === '') {
306+
$query->where($query->expr()->emptyString('principaluri'));
307+
} else {
308+
$query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
309+
}
310+
311+
$result = $query->execute();
300312

301313
$calendars = [];
302-
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
314+
while ($row = $result->fetch()) {
315+
$row['principaluri'] = (string) $row['principaluri'];
303316
$components = [];
304317
if ($row['components']) {
305318
$components = explode(',',$row['components']);
@@ -326,8 +339,7 @@ public function getCalendarsForUser($principalUri) {
326339
$calendars[$calendar['id']] = $calendar;
327340
}
328341
}
329-
330-
$stmt->closeCursor();
342+
$result->closeCursor();
331343

332344
// query for shared calendars
333345
$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
@@ -347,17 +359,19 @@ public function getCalendarsForUser($principalUri) {
347359
$fields[] = 'a.transparent';
348360
$fields[] = 's.access';
349361
$query = $this->db->getQueryBuilder();
350-
$result = $query->select($fields)
362+
$query->select($fields)
351363
->from('dav_shares', 's')
352364
->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
353365
->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
354366
->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
355367
->setParameter('type', 'calendar')
356-
->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
357-
->execute();
368+
->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
369+
370+
$result = $query->execute();
358371

359372
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
360373
while ($row = $result->fetch()) {
374+
$row['principaluri'] = (string) $row['principaluri'];
361375
if ($row['principaluri'] === $principalUri) {
362376
continue;
363377
}
@@ -428,6 +442,7 @@ public function getUsersOwnCalendars($principalUri) {
428442
$stmt = $query->execute();
429443
$calendars = [];
430444
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
445+
$row['principaluri'] = (string) $row['principaluri'];
431446
$components = [];
432447
if ($row['components']) {
433448
$components = explode(',',$row['components']);
@@ -497,6 +512,7 @@ public function getPublicCalendars() {
497512
->execute();
498513

499514
while ($row = $result->fetch()) {
515+
$row['principaluri'] = (string) $row['principaluri'];
500516
list(, $name) = Uri\split($row['principaluri']);
501517
$row['displayname'] = $row['displayname'] . "($name)";
502518
$components = [];
@@ -563,6 +579,7 @@ public function getPublicCalendar($uri) {
563579
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
564580
}
565581

582+
$row['principaluri'] = (string) $row['principaluri'];
566583
list(, $name) = Uri\split($row['principaluri']);
567584
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
568585
$components = [];
@@ -619,6 +636,7 @@ public function getCalendarByUri($principal, $uri) {
619636
return null;
620637
}
621638

639+
$row['principaluri'] = (string) $row['principaluri'];
622640
$components = [];
623641
if ($row['components']) {
624642
$components = explode(',',$row['components']);
@@ -669,6 +687,7 @@ public function getCalendarById($calendarId) {
669687
return null;
670688
}
671689

690+
$row['principaluri'] = (string) $row['principaluri'];
672691
$components = [];
673692
if ($row['components']) {
674693
$components = explode(',',$row['components']);
@@ -718,6 +737,7 @@ public function getSubscriptionById($subscriptionId) {
718737
return null;
719738
}
720739

740+
$row['principaluri'] = (string) $row['principaluri'];
721741
$subscription = [
722742
'id' => $row['id'],
723743
'uri' => $row['uri'],
@@ -965,6 +985,7 @@ public function getCalendarObjects($calendarId, $calendarType = self::CALENDAR_T
965985
'classification' => (int)$row['classification']
966986
];
967987
}
988+
$stmt->closeCursor();
968989

969990
return $result;
970991
}
@@ -995,6 +1016,7 @@ public function getCalendarObject($calendarId, $objectUri, $calendarType = self:
9951016
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
9961017
$stmt = $query->execute();
9971018
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
1019+
$stmt->closeCursor();
9981020

9991021
if (!$row) {
10001022
return null;

apps/dav/lib/Migration/Version1012Date20190808122342.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function changeSchema(IOutput $output,
6969
'length' => 11,
7070
]);
7171
$table->addColumn('is_recurring', Types::SMALLINT, [
72-
'notnull' => true,
72+
'notnull' => false,
7373
'length' => 1,
7474
]);
7575
$table->addColumn('uid', Types::STRING, [
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
7+
*
8+
* @author Joas Schilling <coding@schilljs.com>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OCA\DAV\Migration;
28+
29+
use Closure;
30+
use OCP\DB\ISchemaWrapper;
31+
use OCP\Migration\IOutput;
32+
use OCP\Migration\SimpleMigrationStep;
33+
34+
class Version1016Date20201109085907 extends SimpleMigrationStep {
35+
/**
36+
* @param IOutput $output
37+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38+
* @param array $options
39+
* @return null|ISchemaWrapper
40+
*/
41+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
42+
/** @var ISchemaWrapper $schema */
43+
$schema = $schemaClosure();
44+
45+
$result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring');
46+
47+
return $result ? $schema : null;
48+
}
49+
50+
protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool {
51+
$table = $schema->getTable($tableName);
52+
$column = $table->getColumn($columnName);
53+
54+
if ($column->getNotnull()) {
55+
$column->setNotnull(false);
56+
return true;
57+
}
58+
59+
return false;
60+
}
61+
}

apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,13 @@ protected function getProps(string $user, string $path) {
110110
->where($query->expr()->eq('userid', $query->createNamedParameter($user)))
111111
->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path))));
112112

113-
114113
$result = $query->execute();
115-
$data = $result->fetchAll(\PDO::FETCH_KEY_PAIR);
114+
$data = [];
115+
while ($row = $result->fetch()) {
116+
$data[$row['propertyname']] = $row['propertyvalue'];
117+
}
116118
$result->closeCursor();
119+
117120
return $data;
118121
}
119122

apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5252
'notnull' => true,
5353
'length' => 4,
5454
]);
55-
$table->addUniqueIndex(['share_id'], 'share_id_index');
55+
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
56+
// $table->addUniqueIndex(['share_id'], 'share_id_index');
5657
}
5758
return $schema;
5859
}

apps/oauth2/tests/Db/ClientMapperTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ protected function setUp(): void {
4040
$this->clientMapper = new ClientMapper(\OC::$server->getDatabaseConnection());
4141
}
4242

43+
protected function tearDown(): void {
44+
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
45+
$query->delete('oauth2_clients')->execute();
46+
47+
parent::tearDown();
48+
}
49+
4350
public function testGetByIdentifier() {
4451
$client = new Client();
4552
$client->setClientIdentifier('MyAwesomeClientIdentifier');
@@ -51,7 +58,6 @@ public function testGetByIdentifier() {
5158
$this->assertEquals($client, $this->clientMapper->getByIdentifier('MyAwesomeClientIdentifier'));
5259
}
5360

54-
5561
public function testGetByIdentifierNotExisting() {
5662
$this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
5763

@@ -69,7 +75,6 @@ public function testGetByUid() {
6975
$this->assertEquals($client, $this->clientMapper->getByUid($client->getId()));
7076
}
7177

72-
7378
public function testGetByUidNotExisting() {
7479
$this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
7580

0 commit comments

Comments
 (0)