Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a unit test to check all DBs
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and skjnldsv committed Oct 22, 2021
commit a365651a74b882f383a268c1c160afaaec38e239
2 changes: 1 addition & 1 deletion lib/private/DB/SchemaWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getTableNamesWithoutPrefix(): array {
* @return array
*/
public function getTableNames(): array {
return array_map(function (string $fullName) {
return array_map(static function (string $fullName) {
$pos = strpos($fullName, '.');
if ($pos === false) {
return $fullName;
Expand Down
57 changes: 57 additions & 0 deletions tests/lib/DB/SchemaWrapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joas Schilling <[email protected]>
*
* @author Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Test\DB;

use OC\DB\Connection;
use OC\DB\SchemaWrapper;

/**
* Class SchemaWrapperTest
*
* @group DB
*
* @package Test\DB
*/
class SchemaWrapperTest extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection $connection */
private $connection;

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

$this->connection = \OC::$server->get(Connection::class);
}

public function testGetTableNames(): void {
$schema = new SchemaWrapper($this->connection);
self::assertContains('oc_share', $schema->getTableNames());
}

public function testGetTableNamesWithoutPrefix(): void {
$schema = new SchemaWrapper($this->connection);
self::assertContains('share', $schema->getTableNamesWithoutPrefix());
}
}