Merge #20017 - Insufficient space export exception

Pull-request: #20017
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-01-17 14:07:33 +01:00
commit 79061b5c6f
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31
36 changed files with 506 additions and 920 deletions

View File

@ -5839,9 +5839,6 @@
<code><![CDATA[$row[0]]]></code>
<code><![CDATA[$row[0]]]></code>
</PossiblyNullArgument>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
</file>
<file src="src/Plugins/Export/ExportCsv.php">
<DeprecatedMethod>
@ -5878,9 +5875,6 @@
<code><![CDATA[$comments]]></code>
<code><![CDATA[$mimeMap]]></code>
</PossiblyUndefinedVariable>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
</file>
<file src="src/Plugins/Export/ExportJson.php">
<DeprecatedMethod>
@ -6066,9 +6060,6 @@
<code><![CDATA[remove]]></code>
<code><![CDATA[remove]]></code>
</PossiblyNullReference>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($column->collation)]]></code>
<code><![CDATA[empty($config->selectedServer['port'])]]></code>
@ -6437,10 +6428,6 @@
<code><![CDATA[$db['alias']]]></code>
<code><![CDATA[$table['alias']]]></code>
</MixedReturnStatement>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[$foreigner]]></code>
</RiskyTruthyFalsyComparison>

View File

@ -301,9 +301,7 @@ final readonly class ExportController implements InvocableController
}
// Add possibly some comments to export
if (! $exportPlugin->exportHeader()) {
throw new ExportException('Failure during header export.');
}
$exportPlugin->exportHeader();
/**
* Builds the dump
@ -351,7 +349,7 @@ final readonly class ExportController implements InvocableController
);
}
} elseif ($exportType === ExportType::Raw) {
Export::exportRaw($exportPlugin, Current::$database, Current::$sqlQuery);
$exportPlugin->exportRawQuery(Current::$database, Current::$sqlQuery);
} else {
// We export just one table
@ -389,9 +387,7 @@ final readonly class ExportController implements InvocableController
}
}
if (! $exportPlugin->exportFooter()) {
throw new ExportException('Failure during footer export.');
}
$exportPlugin->exportFooter();
} catch (ExportException) {
// Ignore
}

View File

@ -0,0 +1,15 @@
<?php
/**
* Export exception
*/
declare(strict_types=1);
namespace PhpMyAdmin\Exceptions;
/**
* Export exception
*/
class InsufficientSpaceExportException extends ExportException
{
}

View File

@ -289,13 +289,9 @@ class Export
$dbAlias = ! empty($aliases[$db->getName()]['alias'])
? $aliases[$db->getName()]['alias'] : '';
if (! $exportPlugin->exportDBHeader($db->getName(), $dbAlias)) {
return;
}
$exportPlugin->exportDBHeader($db->getName(), $dbAlias);
if (! $exportPlugin->exportDBCreate($db->getName(), $dbAlias)) {
return;
}
$exportPlugin->exportDBCreate($db->getName(), $dbAlias);
if ($separateFiles === SeparateFiles::Database) {
$this->outputHandler->saveObjectInBuffer('database', true);
@ -331,20 +327,15 @@ class Export
// for a view, export a stand-in definition of the table
// to resolve view dependencies (only when it's a single-file export)
if ($isView) {
if (
$separateFiles === SeparateFiles::None
&& ! $exportPlugin->exportStructure($db->getName(), $table, 'stand_in', $aliases)
) {
break;
if ($separateFiles === SeparateFiles::None) {
$exportPlugin->exportStructure($db->getName(), $table, 'stand_in', $aliases);
}
} else {
if ($this->exceedsMaxTableSize($db->getName(), $table)) {
continue;
}
if (! $exportPlugin->exportStructure($db->getName(), $table, 'create_table', $aliases)) {
break;
}
$exportPlugin->exportStructure($db->getName(), $table, 'create_table', $aliases);
}
}
@ -357,9 +348,7 @@ class Export
. ' FROM ' . Util::backquote($db->getName())
. '.' . Util::backquote($table);
if (! $exportPlugin->exportData($db->getName(), $table, $localQuery, $aliases)) {
break;
}
$exportPlugin->exportData($db->getName(), $table, $localQuery, $aliases);
}
// this buffer was filled, we save it and go to the next one
@ -373,9 +362,7 @@ class Export
continue;
}
if (! $exportPlugin->exportStructure($db->getName(), $table, 'triggers', $aliases)) {
break;
}
$exportPlugin->exportStructure($db->getName(), $table, 'triggers', $aliases);
if ($separateFiles !== SeparateFiles::Database) {
continue;
@ -390,9 +377,7 @@ class Export
continue;
}
if (! $exportPlugin->exportStructure($db->getName(), $view, 'create_view', $aliases)) {
break;
}
$exportPlugin->exportStructure($db->getName(), $view, 'create_view', $aliases);
if ($separateFiles !== SeparateFiles::Database) {
continue;
@ -401,9 +386,7 @@ class Export
$this->outputHandler->saveObjectInBuffer('view_' . $view);
}
if (! $exportPlugin->exportDBFooter($db->getName())) {
return;
}
$exportPlugin->exportDBFooter($db->getName());
if ($separateFiles === SeparateFiles::Database) {
$this->outputHandler->saveObjectInBuffer('extra');
@ -431,29 +414,6 @@ class Export
$this->outputHandler->saveObjectInBuffer('events');
}
/**
* Export a raw query
*
* @param ExportPlugin $exportPlugin the selected export plugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the query to be executed
*/
public static function exportRaw(
ExportPlugin $exportPlugin,
string|null $db,
string $sqlQuery,
): void {
if ($exportPlugin->exportRawQuery($db, $sqlQuery)) {
return;
}
Current::$message = Message::error(
// phpcs:disable Generic.Files.LineLength.TooLong
/* l10n: A query written by the user is a "raw query" that could be using no tables or databases in particular */
__('Exporting a raw query is not supported for this export method.'),
);
}
/**
* Export at the table level
*
@ -478,9 +438,7 @@ class Export
): void {
$dbAlias = ! empty($aliases[$db]['alias'])
? $aliases[$db]['alias'] : '';
if (! $exportPlugin->exportDBHeader($db, $dbAlias)) {
return;
}
$exportPlugin->exportDBHeader($db, $dbAlias);
if ($allrows === '0' && $limitTo > 0 && $limitFrom >= 0) {
$addQuery = ' LIMIT '
@ -493,11 +451,9 @@ class Export
if ($exportPlugin->includeStructure()) {
$tableObject = new Table($table, $db, $this->dbi);
if ($tableObject->isView()) {
if (! $exportPlugin->exportStructure($db, $table, 'create_view', $aliases)) {
return;
}
} elseif (! $exportPlugin->exportStructure($db, $table, 'create_table', $aliases)) {
return;
$exportPlugin->exportStructure($db, $table, 'create_view', $aliases);
} else {
$exportPlugin->exportStructure($db, $table, 'create_table', $aliases);
}
}
@ -524,22 +480,16 @@ class Export
. '.' . Util::backquote($table) . $addQuery;
}
if (! $exportPlugin->exportData($db, $table, $localQuery, $aliases)) {
return;
}
$exportPlugin->exportData($db, $table, $localQuery, $aliases);
}
// now export the triggers (needs to be done after the data because
// triggers can modify already imported tables)
if ($exportPlugin->includeStructure()) {
if (! $exportPlugin->exportStructure($db, $table, 'triggers', $aliases)) {
return;
}
$exportPlugin->exportStructure($db, $table, 'triggers', $aliases);
}
if (! $exportPlugin->exportDBFooter($db)) {
return;
}
$exportPlugin->exportDBFooter($db);
// Types of metadata to export.
// In the future these can be allowed to be selected by the user
@ -621,7 +571,9 @@ class Export
$val1 = $colAs[0];
$val2 = $colAs[1];
// Use aliases2 alias if non empty
$aliases[$dbName]['tables'][$tableName]['columns'][$col] = $val2 !== '' && $val2 !== null ? $val2 : $val1;
$aliases[$dbName]['tables'][$tableName]['columns'][$col] = $val2 !== '' && $val2 !== null
? $val2
: $val1;
}
}
}

View File

@ -7,6 +7,7 @@ namespace PhpMyAdmin\Export;
use PhpMyAdmin\Core;
use PhpMyAdmin\Current;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Exceptions\InsufficientSpaceExportException;
use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Util;
@ -54,7 +55,8 @@ class OutputHandler
public int $memoryLimit = 0;
public bool $onFlyCompression = false;
public function addLine(string $line): bool
/** @throws InsufficientSpaceExportException */
public function addLine(string $line): void
{
// Kanji encoding convert feature
if ($this->outputKanjiConversion) {
@ -82,7 +84,7 @@ class OutputHandler
Current::$message = Message::error(__('Insufficient space to save the file %s.'));
Current::$message->addParam($this->saveFilename);
return false;
throw new InsufficientSpaceExportException();
}
} else {
echo $this->dumpBuffer;
@ -93,14 +95,14 @@ class OutputHandler
}
}
return true;
return;
}
if (! self::$asFile) {
// We export as html - replace special chars
echo htmlspecialchars($line, ENT_COMPAT);
return true;
return;
}
if ($this->outputCharsetConversion) {
@ -113,14 +115,12 @@ class OutputHandler
Current::$message = Message::error(__('Insufficient space to save the file %s.'));
Current::$message->addParam($this->saveFilename);
return false;
throw new InsufficientSpaceExportException();
}
} else {
// We export as file - output normally
echo $line;
}
return true;
}
/**

View File

@ -95,12 +95,14 @@ class ExportCodegen extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
if ($this->format === self::HANDLER_NHIBERNATE_XML) {
return $this->outputHandler->addLine($this->handleNHibernateXMLBody($db, $table, $aliases));
$this->outputHandler->addLine($this->handleNHibernateXMLBody($db, $table, $aliases));
return;
}
return $this->outputHandler->addLine($this->handleNHibernateCSBody($db, $table, $aliases));
$this->outputHandler->addLine($this->handleNHibernateCSBody($db, $table, $aliases));
}
/**

View File

@ -136,7 +136,7 @@ class ExportCsv extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbi = DatabaseInterface::getInstance();
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
@ -159,9 +159,7 @@ class ExportCsv extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
$this->outputHandler->addLine($schemaInsert . $this->terminated);
}
// Format the data
@ -208,12 +206,8 @@ class ExportCsv extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertValues);
if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
$this->outputHandler->addLine($schemaInsert . $this->terminated);
}
return true;
}
/**
@ -222,13 +216,13 @@ class ExportCsv extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */

View File

@ -132,7 +132,7 @@ class ExportExcel extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbi = DatabaseInterface::getInstance();
/**
* Gets the data from the database
@ -155,9 +155,7 @@ class ExportExcel extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
$this->outputHandler->addLine($schemaInsert . $this->terminated);
}
// Format the data
@ -206,12 +204,8 @@ class ExportExcel extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertValues);
if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
$this->outputHandler->addLine($schemaInsert . $this->terminated);
}
return true;
}
/**
@ -220,13 +214,13 @@ class ExportExcel extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */

View File

@ -104,9 +104,9 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
return $this->outputHandler->addLine(
$this->outputHandler->addLine(
'<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
@ -125,9 +125,9 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
return $this->outputHandler->addLine('</body></html>');
$this->outputHandler->addLine('</body></html>');
}
/**
@ -136,13 +136,13 @@ class ExportHtmlword extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
}
return $this->outputHandler->addLine(
$this->outputHandler->addLine(
'<h1>' . __('Database') . ' ' . htmlspecialchars($dbAlias) . '</h1>',
);
}
@ -160,22 +160,16 @@ class ExportHtmlword extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if (
! $this->outputHandler->addLine(
'<h2>'
. __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias)
. '</h2>',
)
) {
return false;
}
$this->outputHandler->addLine(
'<h2>'
. __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias)
. '</h2>',
);
if (! $this->outputHandler->addLine('<table width="100%" cellspacing="1">')) {
return false;
}
$this->outputHandler->addLine('<table width="100%" cellspacing="1">');
$dbi = DatabaseInterface::getInstance();
/**
@ -195,9 +189,7 @@ class ExportHtmlword extends ExportPlugin
}
$schemaInsert .= '</tr>';
if (! $this->outputHandler->addLine($schemaInsert)) {
return false;
}
$this->outputHandler->addLine($schemaInsert);
}
// Format the data
@ -210,12 +202,10 @@ class ExportHtmlword extends ExportPlugin
}
$schemaInsert .= '</tr>';
if (! $this->outputHandler->addLine($schemaInsert)) {
return false;
}
$this->outputHandler->addLine($schemaInsert);
}
return $this->outputHandler->addLine('</table>');
$this->outputHandler->addLine('</table>');
}
/**
@ -441,7 +431,7 @@ class ExportHtmlword extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -480,7 +470,7 @@ class ExportHtmlword extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
}
return $this->outputHandler->addLine($dump);
$this->outputHandler->addLine($dump);
}
/**

View File

@ -9,6 +9,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Exceptions\ExportException;
use PhpMyAdmin\Export\StructureOrData;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Http\ServerRequest;
@ -105,7 +106,7 @@ class ExportJson extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$data = $this->encode([
'type' => 'header',
@ -113,18 +114,18 @@ class ExportJson extends ExportPlugin
'comment' => 'Export to JSON plugin for phpMyAdmin',
]);
if ($data === false) {
return false;
throw new ExportException('Failure during header export.');
}
return $this->outputHandler->addLine('[' . "\n" . $data . ',' . "\n");
$this->outputHandler->addLine('[' . "\n" . $data . ',' . "\n");
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
return $this->outputHandler->addLine(']' . "\n");
$this->outputHandler->addLine(']' . "\n");
}
/**
@ -133,7 +134,7 @@ class ExportJson extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -141,10 +142,10 @@ class ExportJson extends ExportPlugin
$data = $this->encode(['type' => 'database', 'name' => $dbAlias]);
if ($data === false) {
return false;
throw new ExportException('Failure during header export.');
}
return $this->outputHandler->addLine($data . ',' . "\n");
$this->outputHandler->addLine($data . ',' . "\n");
}
/**
@ -160,14 +161,12 @@ class ExportJson extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if (! $this->first) {
if (! $this->outputHandler->addLine(',')) {
return false;
}
$this->outputHandler->addLine(',');
} else {
$this->first = false;
}
@ -179,10 +178,10 @@ class ExportJson extends ExportPlugin
'data' => '@@DATA@@',
]);
if ($buffer === false) {
return false;
throw new ExportException('Failure during data export.');
}
return $this->doExportForQuery(DatabaseInterface::getInstance(), $sqlQuery, $buffer, $aliases, $db, $table);
$this->doExportForQuery(DatabaseInterface::getInstance(), $sqlQuery, $buffer, $aliases, $db, $table);
}
/**
@ -198,19 +197,17 @@ class ExportJson extends ExportPlugin
* }
* >|null $aliases
*/
protected function doExportForQuery(
private function doExportForQuery(
DatabaseInterface $dbi,
string $sqlQuery,
string $buffer,
array|null $aliases,
string|null $db,
string|null $table,
): bool {
): void {
[$header, $footer] = explode('"@@DATA@@"', $buffer);
if (! $this->outputHandler->addLine($header . "\n" . '[' . "\n")) {
return false;
}
$this->outputHandler->addLine($header . "\n" . '[' . "\n");
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
@ -234,9 +231,7 @@ class ExportJson extends ExportPlugin
// Output table name as comment if this is the first record of the table
if ($recordCnt > 1) {
if (! $this->outputHandler->addLine(',' . "\n")) {
return false;
}
$this->outputHandler->addLine(',' . "\n");
}
$data = [];
@ -269,15 +264,13 @@ class ExportJson extends ExportPlugin
$encodedData = $this->encode($data);
if ($encodedData === '' || $encodedData === false) {
return false;
throw new ExportException('Failure during data export.');
}
if (! $this->outputHandler->addLine($encodedData)) {
return false;
}
$this->outputHandler->addLine($encodedData);
}
return $this->outputHandler->addLine("\n" . ']' . "\n" . $footer . "\n");
$this->outputHandler->addLine("\n" . ']' . "\n" . $footer . "\n");
}
/**
@ -286,11 +279,11 @@ class ExportJson extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
$buffer = $this->encode(['type' => 'raw', 'data' => '@@DATA@@']);
if ($buffer === false) {
return false;
throw new ExportException('Failure during data export.');
}
$dbi = DatabaseInterface::getInstance();
@ -298,7 +291,7 @@ class ExportJson extends ExportPlugin
$dbi->selectDb($db);
}
return $this->doExportForQuery($dbi, $sqlQuery, $buffer, null, $db, null);
$this->doExportForQuery($dbi, $sqlQuery, $buffer, null, $db, null);
}
/** @inheritDoc */

View File

@ -215,7 +215,7 @@ class ExportLatex extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$config = Config::getInstance();
$head = '% phpMyAdmin LaTeX Dump' . "\n"
@ -233,7 +233,7 @@ class ExportLatex extends ExportPlugin
. '% ' . __('Server version:') . ' ' . DatabaseInterface::getInstance()->getVersionString() . "\n"
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n";
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
}
/**
@ -242,7 +242,7 @@ class ExportLatex extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -252,7 +252,7 @@ class ExportLatex extends ExportPlugin
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . "\n"
. '% ' . "\n";
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
}
/**
@ -268,7 +268,7 @@ class ExportLatex extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -309,9 +309,7 @@ class ExportLatex extends ExportPlugin
. '} \\\\';
}
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
// show column names
if ($this->columns) {
@ -322,31 +320,23 @@ class ExportLatex extends ExportPlugin
}
$buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (! $this->outputHandler->addLine($buffer . ' \\endfirsthead ' . "\n")) {
return false;
}
$this->outputHandler->addLine($buffer . ' \\endfirsthead ' . "\n");
if ($this->caption) {
if (
! $this->outputHandler->addLine(
'\\caption{'
. Util::expandUserString(
$this->dataContinuedCaption,
[static::class, 'texEscape'],
['table' => $tableAlias, 'database' => $dbAlias],
)
. '} \\\\ ',
$this->outputHandler->addLine(
'\\caption{'
. Util::expandUserString(
$this->dataContinuedCaption,
[static::class, 'texEscape'],
['table' => $tableAlias, 'database' => $dbAlias],
)
) {
return false;
}
. '} \\\\ ',
);
}
if (! $this->outputHandler->addLine($buffer . '\\endhead \\endfoot' . "\n")) {
return false;
}
} elseif (! $this->outputHandler->addLine('\\\\ \hline')) {
return false;
$this->outputHandler->addLine($buffer . '\\endhead \\endfoot' . "\n");
} else {
$this->outputHandler->addLine('\\\\ \hline');
}
// print the whole table
@ -370,14 +360,12 @@ class ExportLatex extends ExportPlugin
}
$buffer .= ' \\\\ \\hline ' . "\n";
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
}
$buffer = ' \\end{longtable}' . "\n";
return $this->outputHandler->addLine($buffer);
$this->outputHandler->addLine($buffer);
}
/**
@ -386,13 +374,13 @@ class ExportLatex extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/**
@ -403,7 +391,7 @@ class ExportLatex extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -412,7 +400,7 @@ class ExportLatex extends ExportPlugin
/* We do not export triggers */
if ($exportMode === 'triggers') {
return true;
return;
}
/**
@ -443,9 +431,7 @@ class ExportLatex extends ExportPlugin
*/
$buffer = "\n" . '%' . "\n" . '% ' . __('Structure:') . ' '
. $tableAlias . "\n" . '%' . "\n" . ' \\begin{longtable}{';
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
$alignment = '|l|c|c|c|';
if ($this->doRelation && $foreigners !== null && ! $foreigners->isEmpty()) {
@ -513,9 +499,7 @@ class ExportLatex extends ExportPlugin
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . "\n";
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
$fields = $dbi->getColumns($db, $table);
foreach ($fields as $row) {
@ -565,14 +549,12 @@ class ExportLatex extends ExportPlugin
$buffer = str_replace("\000", ' & ', $localBuffer);
$buffer .= ' \\\\ \\hline ' . "\n";
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
}
$buffer = ' \\end{longtable}' . "\n";
return $this->outputHandler->addLine($buffer);
$this->outputHandler->addLine($buffer);
}
/**

View File

@ -102,7 +102,7 @@ class ExportMediawiki extends ExportPlugin
*
* @infection-ignore-all
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -166,7 +166,7 @@ class ExportMediawiki extends ExportPlugin
$output .= '|}' . str_repeat($this->exportCRLF(), 2);
}
return $this->outputHandler->addLine($output);
$this->outputHandler->addLine($output);
}
/**
@ -182,7 +182,7 @@ class ExportMediawiki extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$tableAlias = $this->getTableAlias($aliases, $db, $table);
// Print data comment
@ -240,7 +240,7 @@ class ExportMediawiki extends ExportPlugin
// End table construction
$output .= '|}' . str_repeat($this->exportCRLF(), 2);
return $this->outputHandler->addLine($output);
$this->outputHandler->addLine($output);
}
/**
@ -249,13 +249,13 @@ class ExportMediawiki extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/**

View File

@ -84,7 +84,7 @@ class ExportOds extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$this->buffer .= '<?xml version="1.0" encoding="utf-8"?>'
. '<office:document-content '
@ -131,18 +131,16 @@ class ExportOds extends ExportPlugin
. '</office:automatic-styles>'
. '<office:body>'
. '<office:spreadsheet>';
return true;
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
$this->buffer .= '</office:spreadsheet></office:body></office:document-content>';
return $this->outputHandler->addLine(
$this->outputHandler->addLine(
OpenDocument::create('application/vnd.oasis.opendocument.spreadsheet', $this->buffer),
);
}
@ -160,7 +158,7 @@ class ExportOds extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$dbi = DatabaseInterface::getInstance();
// Gets the data from the database
@ -256,8 +254,6 @@ class ExportOds extends ExportPlugin
}
$this->buffer .= '</table:table>';
return true;
}
/**
@ -266,13 +262,13 @@ class ExportOds extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */

View File

@ -145,25 +145,23 @@ class ExportOdt extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$this->buffer .= '<?xml version="1.0" encoding="utf-8"?>'
. '<office:document-content '
. OpenDocument::NS . ' office:version="1.0">'
. '<office:body>'
. '<office:text>';
return true;
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
$this->buffer .= '</office:text></office:body></office:document-content>';
return $this->outputHandler->addLine(OpenDocument::create(
$this->outputHandler->addLine(OpenDocument::create(
'application/vnd.oasis.opendocument.text',
$this->buffer,
));
@ -175,7 +173,7 @@ class ExportOdt extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -185,8 +183,6 @@ class ExportOdt extends ExportPlugin
. ' text:is-list-header="true">'
. __('Database') . ' ' . htmlspecialchars($dbAlias)
. '</text:h>';
return true;
}
/**
@ -202,7 +198,7 @@ class ExportOdt extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$dbi = DatabaseInterface::getInstance();
// Gets the data from the database
@ -280,8 +276,6 @@ class ExportOdt extends ExportPlugin
}
$this->buffer .= '</table:table>';
return true;
}
/**
@ -290,13 +284,13 @@ class ExportOdt extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/**
@ -559,7 +553,7 @@ class ExportOdt extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$tableAlias = $this->getTableAlias($aliases, $db, $table);
switch ($exportMode) {
@ -600,8 +594,6 @@ class ExportOdt extends ExportPlugin
// export a stand-in definition to resolve view dependencies
$this->getTableDefStandIn($db, $table, $aliases);
}
return true;
}
/**

View File

@ -101,10 +101,10 @@ class ExportPdf extends ExportPlugin
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
// instead of $pdf->Output():
return $this->outputHandler->addLine($this->pdf->getPDFData());
$this->outputHandler->addLine($this->pdf->getPDFData());
}
/**
@ -120,7 +120,7 @@ class ExportPdf extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$this->pdf->setCurrentDb($db);
@ -130,8 +130,6 @@ class ExportPdf extends ExportPlugin
$this->pdf->setAliases($aliases);
$this->pdf->setPurpose(__('Dumping data'));
$this->pdf->mysqlReport($sqlQuery);
return true;
}
/**
@ -140,7 +138,7 @@ class ExportPdf extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
$this->pdf->setDbAlias('----');
$this->pdf->setTableAlias('----');
@ -152,8 +150,6 @@ class ExportPdf extends ExportPlugin
}
$this->pdf->mysqlReport($sqlQuery);
return true;
}
/**
@ -164,7 +160,7 @@ class ExportPdf extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases aliases for db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$purpose = '';
$dbAlias = $this->getDbAlias($aliases, $db);
@ -197,8 +193,6 @@ class ExportPdf extends ExportPlugin
'triggers' => $this->pdf->getTriggers($db, $table),
default => true,
};
return true;
}
public static function isAvailable(): bool

View File

@ -76,7 +76,7 @@ class ExportPhparray extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$this->outputHandler->addLine(
'<?php' . "\n"
@ -85,8 +85,6 @@ class ExportPhparray extends ExportPlugin
. ' * @version ' . Version::VERSION . "\n"
. ' */' . "\n\n",
);
return true;
}
/**
@ -95,7 +93,7 @@ class ExportPhparray extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -106,8 +104,6 @@ class ExportPhparray extends ExportPlugin
. ' * Database ' . $this->commentString(Util::backquote($dbAlias))
. "\n" . ' */' . "\n",
);
return true;
}
/**
@ -123,7 +119,7 @@ class ExportPhparray extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -160,9 +156,7 @@ class ExportPhparray extends ExportPlugin
. $this->commentString(Util::backquote($dbAlias)) . '.'
. $this->commentString(Util::backquote($tableAlias)) . ' */' . "\n";
$buffer .= '$' . $tableFixed . ' = array(';
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
// Reset the buffer
$buffer = '';
@ -183,9 +177,7 @@ class ExportPhparray extends ExportPlugin
}
$buffer .= ')';
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
// Reset the buffer
$buffer = '';
@ -193,7 +185,7 @@ class ExportPhparray extends ExportPlugin
$buffer .= "\n" . ');' . "\n";
return $this->outputHandler->addLine($buffer);
$this->outputHandler->addLine($buffer);
}
/**
@ -202,13 +194,13 @@ class ExportPhparray extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */

View File

@ -611,10 +611,10 @@ class ExportSql extends ExportPlugin
* @param string $db Database
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportRoutines(string $db, array $aliases = []): bool
public function exportRoutines(string $db, array $aliases = []): void
{
if (! $this->hasCreateProcedureFunction) {
return true;
return;
}
$text = '';
@ -653,11 +653,11 @@ class ExportSql extends ExportPlugin
$text .= 'DELIMITER ;' . "\n";
}
if ($text !== '') {
return $this->outputHandler->addLine($text);
if ($text === '') {
return;
}
return false;
$this->outputHandler->addLine($text);
}
/**
@ -708,7 +708,7 @@ class ExportSql extends ExportPlugin
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
$foot = '';
@ -737,14 +737,14 @@ class ExportSql extends ExportPlugin
DatabaseInterface::getInstance()->query('SET time_zone = "' . self::$oldTimezone . '"');
}
return $this->outputHandler->addLine($foot);
$this->outputHandler->addLine($foot);
}
/**
* Outputs export header. It is the first method to be called, so all
* the required variables are initialized here.
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$dbi = DatabaseInterface::getInstance();
@ -833,7 +833,7 @@ class ExportSql extends ExportPlugin
$this->sentCharset = true;
}
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
}
/**
@ -842,26 +842,22 @@ class ExportSql extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $dbAlias = ''): bool
public function exportDBCreate(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
}
if ($this->includeStructure() && $this->dropDatabase) {
if (
! $this->outputHandler->addLine(
'DROP DATABASE IF EXISTS '
. Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes)
. ';' . "\n",
)
) {
return false;
}
$this->outputHandler->addLine(
'DROP DATABASE IF EXISTS '
. Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes)
. ';' . "\n",
);
}
if (ExportPlugin::$exportType === ExportType::Database && ! $this->createDatabase) {
return true;
return;
}
$createQuery = 'CREATE DATABASE IF NOT EXISTS '
@ -880,11 +876,9 @@ class ExportSql extends ExportPlugin
}
$createQuery .= ';' . "\n";
if (! $this->outputHandler->addLine($createQuery)) {
return false;
}
$this->outputHandler->addLine($createQuery);
return $this->exportUseStatement($dbAlias, $this->compatibility);
$this->exportUseStatement($dbAlias, $this->compatibility);
}
/**
@ -893,17 +887,19 @@ class ExportSql extends ExportPlugin
* @param string $db db to use
* @param string $compat sql compatibility
*/
private function exportUseStatement(string $db, string $compat): bool
private function exportUseStatement(string $db, string $compat): void
{
if ($compat === 'NONE') {
return $this->outputHandler->addLine(
$this->outputHandler->addLine(
'USE '
. Util::backquoteCompat($db, $compat, $this->useSqlBackquotes)
. ';' . "\n",
);
return;
}
return $this->outputHandler->addLine('USE ' . $db . ';' . "\n");
$this->outputHandler->addLine('USE ' . $db . ';' . "\n");
}
/**
@ -912,7 +908,7 @@ class ExportSql extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Alias of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -929,7 +925,7 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment();
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
}
/**
@ -937,35 +933,33 @@ class ExportSql extends ExportPlugin
*
* @param string $db Database name
*/
public function exportDBFooter(string $db): bool
public function exportDBFooter(string $db): void
{
$result = true;
//add indexes to the sql dump file
if ($this->sqlIndexes !== null) {
$result = $this->outputHandler->addLine($this->sqlIndexes);
$this->outputHandler->addLine($this->sqlIndexes);
$this->sqlIndexes = null;
}
//add auto increments to the sql dump file
if ($this->sqlAutoIncrements !== null) {
$result = $this->outputHandler->addLine($this->sqlAutoIncrements);
$this->outputHandler->addLine($this->sqlAutoIncrements);
$this->sqlAutoIncrements = null;
}
//add views to the sql dump file
if ($this->sqlViews !== '') {
$result = $this->outputHandler->addLine($this->sqlViews);
$this->outputHandler->addLine($this->sqlViews);
$this->sqlViews = '';
}
//add constraints to the sql dump file
if ($this->sqlConstraints !== null) {
$result = $this->outputHandler->addLine($this->sqlConstraints);
$this->sqlConstraints = null;
if ($this->sqlConstraints === null) {
return;
}
return $result;
$this->outputHandler->addLine($this->sqlConstraints);
$this->sqlConstraints = null;
}
/**
@ -973,10 +967,10 @@ class ExportSql extends ExportPlugin
*
* @param string $db Database
*/
public function exportEvents(string $db): bool
public function exportEvents(string $db): void
{
if (! $this->hasCreateProcedureFunction) {
return true;
return;
}
$text = '';
@ -1022,11 +1016,11 @@ class ExportSql extends ExportPlugin
$text .= 'DELIMITER ;' . "\n";
}
if ($text !== '') {
return $this->outputHandler->addLine($text);
if ($text === '') {
return;
}
return false;
$this->outputHandler->addLine($text);
}
/**
@ -1040,14 +1034,14 @@ class ExportSql extends ExportPlugin
string $db,
string|array $tables,
array $metadataTypes,
): bool {
): void {
if (! $this->hasMetadata) {
return true;
return;
}
$relationParameters = $this->relation->getRelationParameters();
if ($relationParameters->db === null) {
return true;
return;
}
$comment = $this->possibleCRLF()
@ -1055,27 +1049,23 @@ class ExportSql extends ExportPlugin
. $this->exportComment()
. $this->exportComment(__('Metadata'))
. $this->exportComment();
if (! $this->outputHandler->addLine($comment)) {
return false;
}
$this->outputHandler->addLine($comment);
if (! $this->exportUseStatement((string) $relationParameters->db, $this->compatibility)) {
return false;
}
$this->exportUseStatement((string) $relationParameters->db, $this->compatibility);
if (is_array($tables)) {
$isSuccessful = true;
// export metadata for each table
foreach ($tables as $table) {
$isSuccessful = $this->exportConfigurationMetadata($db, $table, $metadataTypes) && $isSuccessful;
$this->exportConfigurationMetadata($db, $table, $metadataTypes);
}
// export metadata for the database
return $this->exportConfigurationMetadata($db, null, $metadataTypes) && $isSuccessful;
$this->exportConfigurationMetadata($db, null, $metadataTypes);
return;
}
// export metadata for single table
return $this->exportConfigurationMetadata($db, $tables, $metadataTypes);
$this->exportConfigurationMetadata($db, $tables, $metadataTypes);
}
/**
@ -1089,7 +1079,7 @@ class ExportSql extends ExportPlugin
string $db,
string|null $table,
array $metadataTypes,
): bool {
): void {
$relationParameters = $this->relation->getRelationParameters();
$relationParams = $relationParameters->toArray();
@ -1131,9 +1121,7 @@ class ExportSql extends ExportPlugin
$comment .= $this->exportComment();
if (! $this->outputHandler->addLine($comment)) {
return false;
}
$this->outputHandler->addLine($comment);
foreach ($types as $type => $dbNameColumn) {
if (! in_array($type, $metadataTypes, true) || ! isset($relationParams[$type])) {
@ -1162,23 +1150,17 @@ class ExportSql extends ExportPlugin
. ' WHERE `db_name` = ' . $dbi->quoteString($db)
. ' AND `page_nr` = ' . (int) $page;
if (
! $this->exportData(
$relationParameters->pdfFeature->database->getName(),
$relationParameters->pdfFeature->pdfPages->getName(),
$sqlQueryRow,
$aliases,
)
) {
return false;
}
$this->exportData(
$relationParameters->pdfFeature->database->getName(),
$relationParameters->pdfFeature->pdfPages->getName(),
$sqlQueryRow,
$aliases,
);
$lastPage = "\n"
. 'SET @LAST_PAGE = LAST_INSERT_ID();'
. "\n";
if (! $this->outputHandler->addLine($lastPage)) {
return false;
}
$this->outputHandler->addLine($lastPage);
$sqlQueryCoords = 'SELECT `db_name`, `table_name`, '
. "'@LAST_PAGE' AS `pdf_page_number`, `x`, `y` FROM "
@ -1187,18 +1169,12 @@ class ExportSql extends ExportPlugin
. " WHERE `pdf_page_number` = '" . $page . "'";
self::$exportingMetadata = true;
if (
! $this->exportData(
$relationParameters->pdfFeature->database->getName(),
$relationParameters->pdfFeature->tableCoords->getName(),
$sqlQueryCoords,
$aliases,
)
) {
self::$exportingMetadata = false;
return false;
}
$this->exportData(
$relationParameters->pdfFeature->database->getName(),
$relationParameters->pdfFeature->tableCoords->getName(),
$sqlQueryCoords,
$aliases,
);
self::$exportingMetadata = false;
}
@ -1226,19 +1202,8 @@ class ExportSql extends ExportPlugin
$sqlQuery .= ' AND `table_name` = ' . $dbi->quoteString($table);
}
if (
! $this->exportData(
(string) $relationParameters->db,
(string) $relationParams[$type],
$sqlQuery,
$aliases,
)
) {
return false;
}
$this->exportData((string) $relationParameters->db, (string) $relationParams[$type], $sqlQuery, $aliases);
}
return true;
}
/**
@ -1845,13 +1810,13 @@ class ExportSql extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/**
@ -1862,7 +1827,7 @@ class ExportSql extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$formattedTableName = Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes);
@ -1874,7 +1839,7 @@ class ExportSql extends ExportPlugin
switch ($exportMode) {
case 'create_table':
if (! $this->hasCreateTable) {
return true; // User requested no table structure, so the job has been successfully completed
return;
}
$dump .= $this->exportComment(
@ -1886,7 +1851,7 @@ class ExportSql extends ExportPlugin
break;
case 'triggers':
if (! $this->hasCreateTrigger) {
return true; // User requested no triggers, so the job has been successfully completed
return;
}
$dump = '';
@ -1939,7 +1904,7 @@ class ExportSql extends ExportPlugin
break;
case 'create_view':
if (! $this->hasCreateView) {
return true; // No view to export, so the job has been successfully completed
return;
}
if (! $this->viewsAsTables) {
@ -1983,7 +1948,7 @@ class ExportSql extends ExportPlugin
break;
case 'stand_in':
if (! $this->hasCreateView) {
return true; // No view to export, so the job has been successfully completed
return;
}
$dump .= $this->exportComment(
@ -2001,7 +1966,7 @@ class ExportSql extends ExportPlugin
// but not in the case of export
$this->sqlConstraintsQuery = '';
return $this->outputHandler->addLine($dump);
$this->outputHandler->addLine($dump);
}
/**
@ -2017,11 +1982,11 @@ class ExportSql extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbi = DatabaseInterface::getInstance();
// Do not export data for merge tables
if ($dbi->getTable($db, $table)->isMerge()) {
return true;
return;
}
$tableAlias = $this->getTableAlias($aliases, $db, $table);
@ -2038,7 +2003,9 @@ class ExportSql extends ExportPlugin
. $this->exportComment()
. $this->possibleCRLF();
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
return;
}
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
@ -2052,7 +2019,7 @@ class ExportSql extends ExportPlugin
}
if ($result === false) {
return true;
return;
}
$fieldsCnt = $result->numFields();
@ -2146,22 +2113,16 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment()
. "\n";
if (! $this->outputHandler->addLine($head)) {
return false;
}
$this->outputHandler->addLine($head);
}
// We need to SET IDENTITY_INSERT ON for MSSQL
if ($currentRow === 0 && $this->compatibility === 'MSSQL') {
if (
! $this->outputHandler->addLine(
'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' ON ;' . "\n",
)
) {
return false;
}
$this->outputHandler->addLine(
'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' ON ;' . "\n",
);
}
$currentRow++;
@ -2233,9 +2194,7 @@ class ExportSql extends ExportPlugin
$insertLine = '(' . implode(', ', $values) . ')';
$insertLineSize = mb_strlen($insertLine);
if ($this->maxQuerySize > 0 && $querySize + $insertLineSize > $this->maxQuerySize) {
if (! $this->outputHandler->addLine(';' . "\n")) {
return false;
}
$this->outputHandler->addLine(';' . "\n");
$querySize = 0;
$currentRow = 1;
@ -2249,30 +2208,23 @@ class ExportSql extends ExportPlugin
$insertLine = $schemaInsert . '(' . implode(', ', $values) . ')';
}
if (! $this->outputHandler->addLine(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) {
return false;
}
$this->outputHandler->addLine(($currentRow === 1 ? '' : $separator . "\n") . $insertLine);
}
if ($currentRow > 0) {
if (! $this->outputHandler->addLine(';' . "\n")) {
return false;
}
$this->outputHandler->addLine(';' . "\n");
}
// We need to SET IDENTITY_INSERT OFF for MSSQL
if ($this->compatibility === 'MSSQL' && $currentRow > 0) {
$outputSucceeded = $this->outputHandler->addLine(
"\n" . 'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' OFF;' . "\n",
);
if (! $outputSucceeded) {
return false;
}
if ($this->compatibility !== 'MSSQL' || $currentRow <= 0) {
return;
}
return true;
$this->outputHandler->addLine(
"\n" . 'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' OFF;' . "\n",
);
}
/**

View File

@ -105,13 +105,13 @@ class ExportTexytext extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Alias of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
}
return $this->outputHandler->addLine(
$this->outputHandler->addLine(
'===' . __('Database') . ' ' . $dbAlias . "\n\n",
);
}
@ -129,18 +129,14 @@ class ExportTexytext extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if (
! $this->outputHandler->addLine(
$tableAlias !== ''
? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n"
: '==' . __('Dumping data for query result') . "\n\n",
)
) {
return false;
}
$this->outputHandler->addLine(
$tableAlias !== ''
? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n"
: '==' . __('Dumping data for query result') . "\n\n",
);
$dbi = DatabaseInterface::getInstance();
/**
@ -158,9 +154,7 @@ class ExportTexytext extends ExportPlugin
}
$textOutput .= "\n|------\n";
if (! $this->outputHandler->addLine($textOutput)) {
return false;
}
$this->outputHandler->addLine($textOutput);
}
// Format the data
@ -184,12 +178,8 @@ class ExportTexytext extends ExportPlugin
}
$textOutput .= "\n";
if (! $this->outputHandler->addLine($textOutput)) {
return false;
}
$this->outputHandler->addLine($textOutput);
}
return true;
}
/**
@ -198,13 +188,13 @@ class ExportTexytext extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/**
@ -399,7 +389,7 @@ class ExportTexytext extends ExportPlugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$dump = '';
@ -429,7 +419,7 @@ class ExportTexytext extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
}
return $this->outputHandler->addLine($dump);
$this->outputHandler->addLine($dump);
}
/**

View File

@ -177,7 +177,7 @@ class ExportXml extends ExportPlugin
* Outputs export header. It is the first method to be called, so all
* the required variables are initialized here.
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$exportStruct = $this->exportFunctions
|| $this->exportProcedures
@ -248,8 +248,7 @@ class ExportXml extends ExportPlugin
$tbl = (string) $result[$table][1];
$isView = $dbi->getTable(Current::$database, $table)
->isView();
$isView = $dbi->getTable(Current::$database, $table)->isView();
$type = $isView ? 'view' : 'table';
@ -327,17 +326,17 @@ class ExportXml extends ExportPlugin
}
}
return $this->outputHandler->addLine($head);
$this->outputHandler->addLine($head);
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
$foot = '</pma_xml_export>';
return $this->outputHandler->addLine($foot);
$this->outputHandler->addLine($foot);
}
/**
@ -346,23 +345,23 @@ class ExportXml extends ExportPlugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
if ($dbAlias === '') {
$dbAlias = $db;
}
if ($this->exportContents) {
$head = ' <!--' . "\n"
. ' - ' . __('Database:') . ' \''
. htmlspecialchars($dbAlias) . '\'' . "\n"
. ' -->' . "\n" . ' <database name="'
. htmlspecialchars($dbAlias) . '">' . "\n";
return $this->outputHandler->addLine($head);
if (! $this->exportContents) {
return;
}
return true;
$head = ' <!--' . "\n"
. ' - ' . __('Database:') . ' \''
. htmlspecialchars($dbAlias) . '\'' . "\n"
. ' -->' . "\n" . ' <database name="'
. htmlspecialchars($dbAlias) . '">' . "\n";
$this->outputHandler->addLine($head);
}
/**
@ -370,13 +369,13 @@ class ExportXml extends ExportPlugin
*
* @param string $db Database name
*/
public function exportDBFooter(string $db): bool
public function exportDBFooter(string $db): void
{
if ($this->exportContents) {
return $this->outputHandler->addLine(' </database>' . "\n");
if (! $this->exportContents) {
return;
}
return true;
$this->outputHandler->addLine(' </database>' . "\n");
}
/**
@ -392,53 +391,49 @@ class ExportXml extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbi = DatabaseInterface::getInstance();
// Do not export data for merge tables
if ($dbi->getTable($db, $table)->isMerge()) {
return true;
return;
}
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if ($this->exportContents) {
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$columns = $result->getFieldNames();
$buffer = ' <!-- ' . __('Table') . ' '
. htmlspecialchars($tableAlias) . ' -->' . "\n";
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
while ($record = $result->fetchRow()) {
$buffer = ' <table name="'
. htmlspecialchars($tableAlias) . '">' . "\n";
for ($i = 0; $i < $columnsCnt; $i++) {
$colAs = $this->getColumnAlias($aliases, $db, $table, $columns[$i]);
// If a cell is NULL, still export it to preserve
// the XML structure
if (! isset($record[$i])) {
$record[$i] = 'NULL';
}
$buffer .= ' <column name="'
. htmlspecialchars($colAs) . '">'
. htmlspecialchars($record[$i])
. '</column>' . "\n";
}
$buffer .= ' </table>' . "\n";
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
}
if (! $this->exportContents) {
return;
}
return true;
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$columns = $result->getFieldNames();
$buffer = ' <!-- ' . __('Table') . ' '
. htmlspecialchars($tableAlias) . ' -->' . "\n";
$this->outputHandler->addLine($buffer);
while ($record = $result->fetchRow()) {
$buffer = ' <table name="'
. htmlspecialchars($tableAlias) . '">' . "\n";
for ($i = 0; $i < $columnsCnt; $i++) {
$colAs = $this->getColumnAlias($aliases, $db, $table, $columns[$i]);
// If a cell is NULL, still export it to preserve
// the XML structure
if (! isset($record[$i])) {
$record[$i] = 'NULL';
}
$buffer .= ' <column name="'
. htmlspecialchars($colAs) . '">'
. htmlspecialchars($record[$i])
. '</column>' . "\n";
}
$buffer .= ' </table>' . "\n";
$this->outputHandler->addLine($buffer);
}
}
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */

View File

@ -65,21 +65,17 @@ class ExportYaml extends ExportPlugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
$this->outputHandler->addLine('%YAML 1.1' . "\n" . '---' . "\n");
return true;
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
$this->outputHandler->addLine('...' . "\n");
return true;
}
/**
@ -95,7 +91,7 @@ class ExportYaml extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool {
): void {
$dbAlias = $this->getDbAlias($aliases, $db);
$tableAlias = $this->getTableAlias($aliases, $db, $table);
$dbi = DatabaseInterface::getInstance();
@ -148,12 +144,8 @@ class ExportYaml extends ExportPlugin
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . "\n";
}
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
$this->outputHandler->addLine($buffer);
}
return true;
}
/**
@ -162,13 +154,13 @@ class ExportYaml extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
return $this->exportData($db ?? '', '', $sqlQuery);
$this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */

View File

@ -47,17 +47,15 @@ abstract class ExportPlugin implements Plugin
/**
* Outputs export header
*/
public function exportHeader(): bool
public function exportHeader(): void
{
return true;
}
/**
* Outputs export footer
*/
public function exportFooter(): bool
public function exportFooter(): void
{
return true;
}
/**
@ -66,9 +64,8 @@ abstract class ExportPlugin implements Plugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBHeader(string $db, string $dbAlias = ''): bool
public function exportDBHeader(string $db, string $dbAlias = ''): void
{
return true;
}
/**
@ -76,9 +73,8 @@ abstract class ExportPlugin implements Plugin
*
* @param string $db Database name
*/
public function exportDBFooter(string $db): bool
public function exportDBFooter(string $db): void
{
return true;
}
/**
@ -87,9 +83,8 @@ abstract class ExportPlugin implements Plugin
* @param string $db Database name
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $dbAlias = ''): bool
public function exportDBCreate(string $db, string $dbAlias = ''): void
{
return true;
}
/**
@ -105,7 +100,7 @@ abstract class ExportPlugin implements Plugin
string $table,
string $sqlQuery,
array $aliases = [],
): bool;
): void;
/**
* The following methods are used in /export or in /database/operations,
@ -118,9 +113,8 @@ abstract class ExportPlugin implements Plugin
* @param string $db Database
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportRoutines(string $db, array $aliases = []): bool
public function exportRoutines(string $db, array $aliases = []): void
{
return true;
}
/**
@ -128,9 +122,8 @@ abstract class ExportPlugin implements Plugin
*
* @param string $db Database
*/
public function exportEvents(string $db): bool
public function exportEvents(string $db): void
{
return true;
}
/**
@ -139,9 +132,8 @@ abstract class ExportPlugin implements Plugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
public function exportRawQuery(string|null $db, string $sqlQuery): bool
public function exportRawQuery(string|null $db, string $sqlQuery): void
{
return false;
}
/**
@ -152,9 +144,8 @@ abstract class ExportPlugin implements Plugin
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool
public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void
{
return true;
}
/**
@ -168,8 +159,7 @@ abstract class ExportPlugin implements Plugin
string $db,
string|array $tables,
array $metadataTypes,
): bool {
return true;
): void {
}
/**

View File

@ -136,30 +136,26 @@ class ExportCodegenTest extends AbstractTestCase
public function testExportHeader(): void
{
self::assertTrue(
$this->object->exportHeader(),
);
$this->expectNotToPerformAssertions();
$this->object->exportHeader();
}
public function testExportFooter(): void
{
self::assertTrue(
$this->object->exportFooter(),
);
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportData(): void

View File

@ -228,27 +228,32 @@ class ExportCsvTest extends AbstractTestCase
public function testExportHeader(): void
{
// case 1
self::assertTrue($this->object->exportHeader());
$this->expectNotToPerformAssertions();
$this->object->exportHeader();
}
public function testExportFooter(): void
{
self::assertTrue($this->object->exportFooter());
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
self::assertTrue($this->object->exportDBHeader('testDB'));
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue($this->object->exportDBFooter('testDB'));
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue($this->object->exportDBCreate('testDB'));
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -263,11 +268,7 @@ class ExportCsvTest extends AbstractTestCase
$this->object->exportHeader();
ob_start();
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table_csv_export`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table_csv_export`;');
$result = ob_get_clean();
self::assertSame(
@ -284,11 +285,11 @@ class ExportCsvTest extends AbstractTestCase
$this->object->exportHeader();
ob_start();
self::assertTrue($this->object->exportData(
$this->object->exportData(
'test_db',
'test_table_csv_export',
'SELECT * FROM `test_db`.`test_table_csv_export`;',
));
);
$result = ob_get_clean();
self::assertSame(
@ -310,11 +311,11 @@ class ExportCsvTest extends AbstractTestCase
$this->object->exportHeader();
ob_start();
self::assertTrue($this->object->exportData(
$this->object->exportData(
'test_db',
'test_table_csv_export',
'SELECT * FROM `test_db`.`test_table_csv_export`;',
));
);
$result = ob_get_clean();
self::assertSame(

View File

@ -188,9 +188,8 @@ class ExportExcelTest extends AbstractTestCase
public function testExportHeader(): void
{
// case 1
self::assertTrue(
$this->object->exportHeader(),
);
$this->expectNotToPerformAssertions();
$this->object->exportHeader();
// case 2
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
@ -198,9 +197,7 @@ class ExportExcelTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
// case 3
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
@ -208,9 +205,7 @@ class ExportExcelTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
}
public function testExportData(): void
@ -224,11 +219,7 @@ class ExportExcelTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertSame(

View File

@ -254,9 +254,7 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testExportFooter(): void
{
ob_start();
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
$result = ob_get_clean();
self::assertSame('</body></html>', $result);
@ -265,9 +263,7 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testExportDBHeader(): void
{
ob_start();
self::assertTrue(
$this->object->exportDBHeader('d"b'),
);
$this->object->exportDBHeader('d"b');
$result = ob_get_clean();
self::assertSame('<h1>Database d&quot;b</h1>', $result);
@ -275,16 +271,14 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -298,11 +292,7 @@ class ExportHtmlwordTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertSame(
@ -590,7 +580,7 @@ class ExportHtmlwordTest extends AbstractTestCase
{
ob_start();
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table'));
$this->object->exportStructure('test_db', 'test_table', 'create_table');
$this->dummyDbi->assertAllSelectsConsumed();
$result = ob_get_clean();
@ -609,7 +599,7 @@ class ExportHtmlwordTest extends AbstractTestCase
);
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers'));
$this->object->exportStructure('test_db', 'test_table', 'triggers');
$result = ob_get_clean();
self::assertSame(
@ -624,7 +614,7 @@ class ExportHtmlwordTest extends AbstractTestCase
ob_start();
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
$this->object->exportStructure('test_db', 'test_table', 'create_view');
$this->dummyDbi->assertAllSelectsConsumed();
$result = ob_get_clean();
@ -643,7 +633,7 @@ class ExportHtmlwordTest extends AbstractTestCase
);
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in'));
$this->object->exportStructure('test_db', 'test_table', 'stand_in');
$result = ob_get_clean();
self::assertSame(

View File

@ -120,41 +120,33 @@ class ExportJsonTest extends AbstractTestCase
. "\n",
);
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
}
public function testExportFooter(): void
{
$this->expectOutputString(']' . "\n");
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
$this->expectOutputString('{"type":"database","name":"testDB"},' . "\n");
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -169,11 +161,7 @@ class ExportJsonTest extends AbstractTestCase
. '}' . "\n",
);
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
}
public function testExportComplexData(): void
@ -190,13 +178,7 @@ class ExportJsonTest extends AbstractTestCase
. "]\n}\n",
);
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table_complex',
'SELECT * FROM `test_db`.`test_table_complex`;',
),
);
$this->object->exportData('test_db', 'test_table_complex', 'SELECT * FROM `test_db`.`test_table_complex`;');
}
public function testExportRawComplexData(): void
@ -212,11 +194,6 @@ class ExportJsonTest extends AbstractTestCase
. "]\n}\n",
);
self::assertTrue(
$this->object->exportRawQuery(
null,
'SELECT * FROM `test_db`.`test_table_complex`;',
),
);
$this->object->exportRawQuery(null, 'SELECT * FROM `test_db`.`test_table_complex`;');
}
}

View File

@ -433,9 +433,7 @@ class ExportLatexTest extends AbstractTestCase
$config->selectedServer['host'] = 'localhost';
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -445,32 +443,27 @@ class ExportLatexTest extends AbstractTestCase
public function testExportFooter(): void
{
self::assertTrue(
$this->object->exportFooter(),
);
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
$this->expectOutputString("% \n% Database: 'testDB'\n% \n");
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -492,11 +485,7 @@ class ExportLatexTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertSame(
@ -531,11 +520,7 @@ class ExportLatexTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
));
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertIsString($result);
@ -620,7 +605,7 @@ class ExportLatexTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportStructure('database', '', 'test'));
$this->object->exportStructure('database', '', 'test');
$result = ob_get_clean();
//echo $result; die;
@ -700,7 +685,7 @@ class ExportLatexTest extends AbstractTestCase
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
ob_start();
self::assertTrue($this->object->exportStructure('database', '', 'test'));
$this->object->exportStructure('database', '', 'test');
$result = ob_get_clean();
self::assertIsString($result);
@ -754,7 +739,7 @@ class ExportLatexTest extends AbstractTestCase
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
ob_start();
self::assertTrue($this->object->exportStructure('database', '', 'test'));
$this->object->exportStructure('database', '', 'test');
$result = ob_get_clean();
self::assertIsString($result);
@ -764,7 +749,7 @@ class ExportLatexTest extends AbstractTestCase
self::assertStringContainsString('caption{latexcontinued}', $result);
// case 4
self::assertTrue($this->object->exportStructure('database', '', 'triggers'));
$this->object->exportStructure('database', '', 'triggers');
}
public function testTexEscape(): void

View File

@ -180,37 +180,32 @@ class ExportMediawikiTest extends AbstractTestCase
public function testExportHeader(): void
{
self::assertTrue(
$this->object->exportHeader(),
);
$this->expectNotToPerformAssertions();
$this->object->exportHeader();
}
public function testExportFooter(): void
{
self::assertTrue(
$this->object->exportFooter(),
);
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
/**
@ -240,7 +235,7 @@ class ExportMediawikiTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportStructure('db', 'table', 'create_table'));
$this->object->exportStructure('db', 'table', 'create_table');
$result = ob_get_clean();
self::assertSame(
@ -283,13 +278,7 @@ class ExportMediawikiTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
),
);
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertSame(

View File

@ -166,7 +166,7 @@ class ExportOdsTest extends AbstractTestCase
public function testExportHeader(): void
{
$this->object->buffer = '';
self::assertTrue($this->object->exportHeader());
$this->object->exportHeader();
self::assertStringStartsWith(
'<?xml version="1.0" encoding="utf-8"?><office:document-content',
$this->object->buffer,
@ -176,7 +176,7 @@ class ExportOdsTest extends AbstractTestCase
public function testExportFooter(): void
{
$this->object->buffer = 'header';
self::assertTrue($this->object->exportFooter());
$this->object->exportFooter();
$output = $this->getActualOutputForAssertion();
self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output));
self::assertStringContainsString('header', $this->object->buffer);
@ -187,23 +187,20 @@ class ExportOdsTest extends AbstractTestCase
public function testExportDBHeader(): void
{
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -256,13 +253,7 @@ class ExportOdsTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
self::assertSame(
'<table:table table:name="table"><table:table-row><table:table-cell ' .
@ -341,13 +332,7 @@ class ExportOdsTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
self::assertSame(
'<table:table table:name="table"><table:table-row><table:table-cell ' .
@ -388,13 +373,7 @@ class ExportOdsTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$this->object->buffer = '';
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
self::assertSame(
'<table:table table:name="table"><table:table-row></table:table-row></table:table>',

View File

@ -302,9 +302,7 @@ class ExportOdtTest extends AbstractTestCase
public function testExportHeader(): void
{
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
self::assertStringContainsString('<office:document-content', $this->object->buffer);
self::assertStringContainsString('office:version', $this->object->buffer);
@ -313,7 +311,7 @@ class ExportOdtTest extends AbstractTestCase
public function testExportFooter(): void
{
$this->object->buffer = 'header';
self::assertTrue($this->object->exportFooter());
$this->object->exportFooter();
$output = $this->getActualOutputForAssertion();
self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output));
self::assertStringContainsString('header', $this->object->buffer);
@ -327,9 +325,7 @@ class ExportOdtTest extends AbstractTestCase
{
$this->object->buffer = 'header';
self::assertTrue(
$this->object->exportDBHeader('d&b'),
);
$this->object->exportDBHeader('d&b');
self::assertStringContainsString('header', $this->object->buffer);
@ -338,16 +334,14 @@ class ExportOdtTest extends AbstractTestCase
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -393,13 +387,7 @@ class ExportOdtTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportData(
'db',
'ta<ble',
'SELECT',
),
);
$this->object->exportData('db', 'ta<ble', 'SELECT');
self::assertSame(
'<text:h text:outline-level="2" text:style-name="Heading_2" ' .
@ -463,13 +451,7 @@ class ExportOdtTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
self::assertSame(
'<text:h text:outline-level="2" text:style-name="Heading_2" text:' .
@ -512,13 +494,7 @@ class ExportOdtTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$this->object->buffer = '';
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
self::assertSame(
'<text:h text:outline-level="2" text:style-name="Heading_2" ' .
@ -743,7 +719,7 @@ class ExportOdtTest extends AbstractTestCase
{
// case 1
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table'));
$this->object->exportStructure('test_db', 'test_table', 'create_table');
$this->dummyDbi->assertAllSelectsConsumed();
self::assertSame(
@ -776,7 +752,7 @@ class ExportOdtTest extends AbstractTestCase
// case 2
$this->object->buffer = '';
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers'));
$this->object->exportStructure('test_db', 'test_table', 'triggers');
self::assertSame(
'<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">'
@ -799,7 +775,7 @@ class ExportOdtTest extends AbstractTestCase
$this->object->buffer = '';
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
$this->object->exportStructure('test_db', 'test_table', 'create_view');
$this->dummyDbi->assertAllSelectsConsumed();
self::assertSame(
@ -832,7 +808,7 @@ class ExportOdtTest extends AbstractTestCase
// case 4
$this->dummyDbi->addSelectDb('test_db');
$this->object->buffer = '';
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in'));
$this->object->exportStructure('test_db', 'test_table', 'stand_in');
$this->dummyDbi->assertAllSelectsConsumed();
self::assertSame(

View File

@ -175,30 +175,25 @@ class ExportPdfTest extends AbstractTestCase
$attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf');
$attrPdf->setValue($this->object, $pdf);
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('testDB');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -214,12 +209,6 @@ class ExportPdfTest extends AbstractTestCase
$attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf');
$attrPdf->setValue($this->object, $pdf);
self::assertTrue(
$this->object->exportData(
'db',
'table',
'SELECT',
),
);
$this->object->exportData('db', 'table', 'SELECT');
}
}

View File

@ -115,9 +115,7 @@ class ExportPhparrayTest extends AbstractTestCase
public function testExportHeader(): void
{
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -127,17 +125,14 @@ class ExportPhparrayTest extends AbstractTestCase
public function testExportFooter(): void
{
self::assertTrue(
$this->object->exportFooter(),
);
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
ob_start();
self::assertTrue(
$this->object->exportDBHeader('db'),
);
$this->object->exportDBHeader('db');
$result = ob_get_clean();
self::assertIsString($result);
@ -147,28 +142,20 @@ class ExportPhparrayTest extends AbstractTestCase
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
{
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
),
);
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertSame(
@ -183,13 +170,7 @@ class ExportPhparrayTest extends AbstractTestCase
// case 2: test invalid variable name fix
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'0`932table',
'SELECT * FROM `test_db`.`test_table`;',
),
);
$this->object->exportData('test_db', '0`932table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertIsString($result);

View File

@ -404,9 +404,7 @@ class ExportSqlTest extends AbstractTestCase
$this->expectOutputString('SET FOREIGN_KEY_CHECKS=1;' . "\n" . 'COMMIT;' . "\n");
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
}
public function testExportHeader(): void
@ -449,9 +447,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -496,9 +492,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportDBCreate('db'),
);
$this->object->exportDBCreate('db');
$result = ob_get_clean();
self::assertIsString($result);
@ -529,9 +523,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->useSqlBackquotes(false);
ob_start();
self::assertTrue(
$this->object->exportDBCreate('db'),
);
$this->object->exportDBCreate('db');
$result = ob_get_clean();
self::assertIsString($result);
@ -558,9 +550,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->object->exportDBHeader('testDB');
$result = ob_get_clean();
self::assertIsString($result);
@ -571,9 +561,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->useSqlBackquotes(false);
ob_start();
self::assertTrue(
$this->object->exportDBHeader('testDB'),
);
$this->object->exportDBHeader('testDB');
$result = ob_get_clean();
self::assertIsString($result);
@ -608,9 +596,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportEvents('db'),
);
$this->object->exportEvents('db');
$result = ob_get_clean();
self::assertIsString($result);
@ -635,9 +621,7 @@ class ExportSqlTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
ob_start();
self::assertTrue(
$this->object->exportDBFooter('db'),
);
$this->object->exportDBFooter('db');
$result = ob_get_clean();
self::assertSame('SqlConstraints', $result);
@ -931,7 +915,7 @@ class ExportSqlTest extends AbstractTestCase
// case 1
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table'));
$this->object->exportStructure('test_db', 'test_table', 'create_table');
$result = ob_get_clean();
self::assertIsString($result);
@ -942,7 +926,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->useSqlBackquotes(false);
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers'));
$this->object->exportStructure('test_db', 'test_table', 'triggers');
$result = ob_get_clean();
self::assertIsString($result);
@ -957,7 +941,7 @@ class ExportSqlTest extends AbstractTestCase
ExportPlugin::$exportType = ExportType::Raw;
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
$this->object->exportStructure('test_db', 'test_table', 'create_view');
$result = ob_get_clean();
$sqlViews = (new ReflectionProperty(ExportSql::class, 'sqlViews'))->getValue($this->object);
@ -977,7 +961,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
$this->object->exportStructure('test_db', 'test_table', 'create_view');
$result = ob_get_clean();
self::assertIsString($result);
@ -987,7 +971,7 @@ class ExportSqlTest extends AbstractTestCase
// case 5
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in'));
$this->object->exportStructure('test_db', 'test_table', 'stand_in');
$result = ob_get_clean();
self::assertIsString($result);
@ -1222,9 +1206,7 @@ class ExportSqlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportData('db', 'tbl', 'SELECT'),
);
$this->object->exportData('db', 'tbl', 'SELECT');
$result = ob_get_clean();
self::assertIsString($result);
@ -1269,9 +1251,7 @@ class ExportSqlTest extends AbstractTestCase
$this->expectException(ExportException::class);
$this->expectExceptionMessage('Error reading data for table db.table: err');
self::assertTrue(
$this->object->exportData('db', 'table', 'SELECT'),
);
$this->object->exportData('db', 'table', 'SELECT');
}
public function testMakeCreateTableMSSQLCompatible(): void

View File

@ -174,38 +174,32 @@ class ExportTexytextTest extends AbstractTestCase
public function testExportHeader(): void
{
self::assertTrue(
$this->object->exportHeader(),
);
$this->expectNotToPerformAssertions();
$this->object->exportHeader();
}
public function testExportFooter(): void
{
self::assertTrue(
$this->object->exportFooter(),
);
$this->expectNotToPerformAssertions();
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
$this->expectOutputString("===Database testDb\n\n");
self::assertTrue(
$this->object->exportDBHeader('testDb'),
);
$this->object->exportDBHeader('testDb');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('testDB');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -216,13 +210,7 @@ class ExportTexytextTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
),
);
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertIsString($result);
@ -350,7 +338,7 @@ class ExportTexytextTest extends AbstractTestCase
// case 1
ob_start();
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table'));
$this->object->exportStructure('test_db', 'test_table', 'create_table');
$this->dummyDbi->assertAllSelectsConsumed();
$result = ob_get_clean();
@ -368,7 +356,7 @@ class ExportTexytextTest extends AbstractTestCase
// case 2
ob_start();
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers'));
$this->object->exportStructure('test_db', 'test_table', 'triggers');
$result = ob_get_clean();
self::assertSame(
@ -383,7 +371,7 @@ class ExportTexytextTest extends AbstractTestCase
// case 3
ob_start();
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
$this->object->exportStructure('test_db', 'test_table', 'create_view');
$this->dummyDbi->assertAllSelectsConsumed();
$result = ob_get_clean();
@ -401,7 +389,7 @@ class ExportTexytextTest extends AbstractTestCase
// case 4
ob_start();
$this->dummyDbi->addSelectDb('test_db');
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in'));
$this->object->exportStructure('test_db', 'test_table', 'stand_in');
$this->dummyDbi->assertAllSelectsConsumed();
$result = ob_get_clean();

View File

@ -249,9 +249,7 @@ class ExportXmlTest extends AbstractTestCase
Current::$table = 'table';
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -313,9 +311,7 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setTables(['t1', 't2']);
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -334,9 +330,7 @@ class ExportXmlTest extends AbstractTestCase
public function testExportFooter(): void
{
$this->expectOutputString('&lt;/pma_xml_export&gt;');
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
}
public function testExportDBHeader(): void
@ -347,9 +341,7 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportDBHeader('&db'),
);
$this->object->exportDBHeader('&db');
$result = ob_get_clean();
self::assertIsString($result);
@ -361,9 +353,7 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportDBHeader('&db'),
);
$this->object->exportDBHeader('&db');
}
public function testExportDBFooter(): void
@ -374,9 +364,7 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportDBFooter('&db'),
);
$this->object->exportDBFooter('&db');
$result = ob_get_clean();
self::assertIsString($result);
@ -388,16 +376,13 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
self::assertTrue(
$this->object->exportDBFooter('&db'),
);
$this->object->exportDBFooter('&db');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
@ -410,13 +395,7 @@ class ExportXmlTest extends AbstractTestCase
$this->object->setExportOptions($request, []);
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table`;',
),
);
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
$result = ob_get_clean();
self::assertIsString($result);

View File

@ -111,9 +111,7 @@ class ExportYamlTest extends AbstractTestCase
public function testExportHeader(): void
{
ob_start();
self::assertTrue(
$this->object->exportHeader(),
);
$this->object->exportHeader();
$result = ob_get_clean();
self::assertIsString($result);
@ -124,42 +122,31 @@ class ExportYamlTest extends AbstractTestCase
public function testExportFooter(): void
{
$this->expectOutputString("...\n");
self::assertTrue(
$this->object->exportFooter(),
);
$this->object->exportFooter();
}
public function testExportDBHeader(): void
{
self::assertTrue(
$this->object->exportDBHeader('&db'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBHeader('&db');
}
public function testExportDBFooter(): void
{
self::assertTrue(
$this->object->exportDBFooter('&db'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBFooter('&db');
}
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB'),
);
$this->expectNotToPerformAssertions();
$this->object->exportDBCreate('testDB');
}
public function testExportData(): void
{
ob_start();
self::assertTrue(
$this->object->exportData(
'test_db',
'test_table',
'SELECT * FROM `test_db`.`test_table_yaml`;',
),
);
$this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table_yaml`;');
$result = ob_get_clean();
self::assertSame(