Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
f3b80607b0
|
|||
e05278da19
|
|||
69bf942608
|
|||
bcd91cf709
|
|||
e604b84849
|
|||
67c462ccda
|
|||
2549003c71
|
|||
f86e3a9daf
|
|||
91b18a9196
|
|||
e0bd9f02b6
|
|||
5251490b74
|
@ -19,14 +19,11 @@ use D3\DataWizard\Application\Model\Configuration;
|
||||
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
||||
use D3\DataWizard\Application\Model\Exceptions\DebugException;
|
||||
use D3\ModCfg\Application\Model\d3database;
|
||||
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
||||
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
||||
use OxidEsales\Eshop\Core\Config;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class d3ActionWizard extends AdminDetailsController
|
||||
@ -43,7 +40,7 @@ class d3ActionWizard extends AdminDetailsController
|
||||
$this->configuration = oxNew(Configuration::class);
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
public function getGroups(): array
|
||||
{
|
||||
return $this->configuration->getActionGroups();
|
||||
}
|
||||
@ -55,9 +52,6 @@ class d3ActionWizard extends AdminDetailsController
|
||||
|
||||
/**
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws StandardException
|
||||
* @throws d3ShopCompatibilityAdapterException
|
||||
* @throws d3_cfg_mod_exception
|
||||
*/
|
||||
public function runTask()
|
||||
{
|
||||
@ -93,7 +87,7 @@ class d3ActionWizard extends AdminDetailsController
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function d3GetConfig()
|
||||
public function d3GetConfig(): Config
|
||||
{
|
||||
return Registry::getConfig();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class d3ExportWizard extends AdminDetailsController
|
||||
$this->configuration = oxNew(Configuration::class);
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
public function getGroups(): array
|
||||
{
|
||||
return $this->configuration->getExportGroups();
|
||||
}
|
||||
@ -101,7 +101,7 @@ class d3ExportWizard extends AdminDetailsController
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function d3GetConfig()
|
||||
public function d3GetConfig(): Config
|
||||
{
|
||||
return Registry::getConfig();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ abstract class ActionBase implements QueryBase
|
||||
* @return DatabaseInterface|null
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
public function d3GetDb()
|
||||
public function d3GetDb(): ?DatabaseInterface
|
||||
{
|
||||
return DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC );
|
||||
}
|
||||
|
@ -15,11 +15,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace D3\DataWizard\Application\Model;
|
||||
|
||||
use D3\DataWizard\Application\Model\Actions\FixArtextendsItems;
|
||||
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
||||
use D3\DataWizard\Application\Model\Exports\InactiveCategories;
|
||||
use D3\DataWizard\Application\Model\Exports\KeyFigures;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ use Doctrine\DBAL\DBALException;
|
||||
use FormManager\Inputs\Checkbox;
|
||||
use FormManager\Inputs\Input;
|
||||
use FormManager\Inputs\Radio;
|
||||
use OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface;
|
||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
@ -94,7 +95,7 @@ abstract class ExportBase implements QueryBase
|
||||
/**
|
||||
* @return RendererBridge
|
||||
*/
|
||||
public function getRendererBridge()
|
||||
public function getRendererBridge(): RendererBridge
|
||||
{
|
||||
return oxNew(RendererBridge::class);
|
||||
}
|
||||
@ -224,9 +225,7 @@ abstract class ExportBase implements QueryBase
|
||||
*/
|
||||
protected function executeExport(string $format, $path): string
|
||||
{
|
||||
[$rows, $fieldNames] = $this->getExportData($this->getQuery());
|
||||
|
||||
$content = $this->renderContent($rows, $fieldNames, $format);
|
||||
$content = $this->getContent( $format );
|
||||
|
||||
/** @var $oFS d3filesystem */
|
||||
$oFS = $this->getFileSystem();
|
||||
@ -244,10 +243,10 @@ abstract class ExportBase implements QueryBase
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface|null
|
||||
* @return DatabaseInterface|null
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
protected function d3GetDb(): ?\OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface
|
||||
protected function d3GetDb(): ?DatabaseInterface
|
||||
{
|
||||
return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
|
||||
}
|
||||
@ -259,4 +258,21 @@ abstract class ExportBase implements QueryBase
|
||||
{
|
||||
return oxNew(d3filesystem::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $format
|
||||
*
|
||||
* @return string
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws DatabaseErrorException
|
||||
* @throws Exceptions\NoSuitableRendererException
|
||||
*/
|
||||
public function getContent( string $format ): string
|
||||
{
|
||||
[ $rows, $fieldNames ] = $this->getExportData( $this->getQuery() );
|
||||
|
||||
$content = $this->renderContent( $rows, $fieldNames, $format );
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ class Csv implements RendererInterface
|
||||
$csv = $this->getCsv();
|
||||
$csv->insertOne( $fieldNames );
|
||||
$csv->insertAll( $rows );
|
||||
return method_exists($csv, 'getContent') ? $csv->getContent() : (string) $csv;
|
||||
return (string) $csv;
|
||||
} catch (Exception $e) {
|
||||
/** @var RenderException $newException */
|
||||
$newException = oxNew(RenderException::class, $e->getMessage(), $e->getCode(), $e );
|
||||
@ -86,7 +86,7 @@ class Csv implements RendererInterface
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function d3GetConfig()
|
||||
public function d3GetConfig(): Config
|
||||
{
|
||||
return Registry::getConfig();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
namespace D3\DataWizard\Application\Model\ExportRenderer;
|
||||
|
||||
use D3\DataWizard\Application\Model\Exceptions\RenderException;
|
||||
use JsonException;
|
||||
|
||||
class Json implements RendererInterface
|
||||
{
|
||||
@ -28,12 +29,15 @@ class Json implements RendererInterface
|
||||
*/
|
||||
public function getContent($rows, $fieldNames): string
|
||||
{
|
||||
$flags = JSON_PRETTY_PRINT;
|
||||
try {
|
||||
$flags = JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR;
|
||||
$json = json_encode( $rows, $flags );
|
||||
if ( $json === false ) {
|
||||
throw oxNew( RenderException::class, json_last_error_msg(), json_last_error());
|
||||
}
|
||||
return $json;
|
||||
} catch ( JsonException $e) {
|
||||
/** @var RenderException $newException */
|
||||
$newException = oxNew(RenderException::class, $e->getMessage(), $e->getCode(), $e );
|
||||
throw $newException;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFileExtension(): string
|
||||
|
@ -35,7 +35,7 @@ class Pretty implements RendererInterface
|
||||
* @param $rows
|
||||
* @return ArrayToTextTable
|
||||
*/
|
||||
public function getArrayToTextTableInstance($rows)
|
||||
public function getArrayToTextTableInstance($rows): ArrayToTextTable
|
||||
{
|
||||
return oxNew(ArrayToTextTable::class, $rows);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class RendererBridge
|
||||
];
|
||||
}
|
||||
|
||||
public function getTranslatedRendererIdList()
|
||||
public function getTranslatedRendererIdList(): array
|
||||
{
|
||||
$rendererList = $this->getRendererList();
|
||||
array_walk($rendererList, [$this, 'translateRendererId']);
|
||||
|
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## 2.1.0.0 (2021-12-21)
|
||||
|
||||
#### Changed
|
||||
- adjust to CLI extension which can export to STDOUT
|
||||
|
||||
---
|
||||
|
||||
## 2.0.0.0 (2021-12-20)
|
||||
|
||||
#### Added
|
||||
- add tests
|
||||
- make installable in OXID 6.4
|
||||
|
||||
#### Changed
|
||||
- adjust code to PHP 7.3 and up
|
||||
|
||||
---
|
||||
|
||||
## 1.4.0.0 (2021-11-11)
|
||||
|
||||
#### Added
|
||||
|
@ -18,7 +18,7 @@ Sample exports are included in the package d3/datawizardtasks. These are intende
|
||||
In the console in the shop root (above source and vendor), execute the following command:
|
||||
|
||||
```bash
|
||||
php composer require d3/datawizard
|
||||
php composer require d3/datawizard:^2.0
|
||||
```
|
||||
|
||||
Activate the module in the admin area of the shop in "Extensions -> Modules".
|
||||
|
@ -18,7 +18,7 @@ Im Paket d3/datawizardtasks sind Beispielexporte enthalten. Diese sollen als Imp
|
||||
Auf der Konsole im Shoproot (oberhalb von source und vendor) folgenden Befehl ausfĂĽhren:
|
||||
|
||||
```bash
|
||||
php composer require d3/datawizard
|
||||
php composer require d3/datawizard:^2.0
|
||||
```
|
||||
|
||||
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
||||
|
@ -25,14 +25,11 @@
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"oxid-esales/oxideshop-ce": "6.3 - 6.9",
|
||||
"php": ">=7.3",
|
||||
"oxid-esales/oxideshop-ce": "6.8 - 6.10",
|
||||
"league/csv": "^9.0",
|
||||
"mathieuviossat/arraytotexttable": "^1.0",
|
||||
"form-manager/form-manager": "^5.1 || ^6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"oxid-esales/oxideshop-ce": "6.8 - 6.9"
|
||||
"form-manager/form-manager": "^6.1"
|
||||
},
|
||||
"extra": {
|
||||
"oxideshop": {
|
||||
|
@ -32,7 +32,7 @@ $aModule = [
|
||||
'en' => '',
|
||||
],
|
||||
'thumbnail' => '',
|
||||
'version' => '1.4.0.0',
|
||||
'version' => '2.1.0.0',
|
||||
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
|
@ -11,5 +11,5 @@
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
define('D3DATAWIZARD_REQUIRE_MODCFG', true);
|
||||
const D3DATAWIZARD_REQUIRE_MODCFG = true;
|
||||
|
||||
|
@ -13,6 +13,6 @@ class d3TestExport extends ExportBase
|
||||
|
||||
public function getQuery(): array
|
||||
{
|
||||
return "SELECT 1";
|
||||
return ["SELECT 1"];
|
||||
}
|
||||
}
|
@ -94,7 +94,7 @@ class ActionBaseTest extends d3ModCfgUnitTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function canGetHasFormElementsDataProvider()
|
||||
public function canGetHasFormElementsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'hasFormElements' => [['abc', 'def'], true],
|
||||
|
@ -21,6 +21,7 @@ use D3\DataWizard\tests\tools\d3TestAction;
|
||||
use D3\DataWizard\tests\tools\d3TestExport;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -44,7 +45,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
@ -65,7 +66,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::configure()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConfigure()
|
||||
{
|
||||
@ -80,7 +81,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::registerAction
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canRegisterAction()
|
||||
{
|
||||
@ -113,7 +114,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::registerExport
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canRegisterExport()
|
||||
{
|
||||
@ -166,7 +167,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getGroupedActions()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetGroupedActions()
|
||||
{
|
||||
@ -190,7 +191,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getGroupedExports()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetGroupedExports()
|
||||
{
|
||||
@ -214,7 +215,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getActionGroups()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetActionGroups()
|
||||
{
|
||||
@ -238,7 +239,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getExportGroups()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetExportGroups()
|
||||
{
|
||||
@ -262,7 +263,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getActionsByGroup()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetActionsByGroup()
|
||||
{
|
||||
@ -287,7 +288,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getExportsByGroup()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetExportsByGroup()
|
||||
{
|
||||
@ -312,7 +313,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getAllActions()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetAllActions()
|
||||
{
|
||||
@ -343,7 +344,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getAllExports()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetAllExports()
|
||||
{
|
||||
@ -374,7 +375,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getActionById()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @dataProvider canGetActionByIdDataProvider
|
||||
*/
|
||||
public function canGetActionById($id, $throwException)
|
||||
@ -409,7 +410,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Configuration::getExportById()
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @dataProvider canGetActionByIdDataProvider
|
||||
*/
|
||||
public function canGetExportById($id, $throwException)
|
||||
|
@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\DataWizard\Application\Model\Exceptions\DebugException;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class DebugExceptionTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -27,13 +29,13 @@ class DebugExceptionTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Exceptions\DebugException::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
$code = '500';
|
||||
|
||||
$exception = oxNew(\Exception::class);
|
||||
$exception = oxNew( Exception::class);
|
||||
|
||||
/** @var DebugException|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(DebugException::class)
|
||||
|
@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\DataWizard\Application\Model\Exceptions\ExportFileException;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class ExportFileExceptionTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -27,13 +29,13 @@ class ExportFileExceptionTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Exceptions\ExportFileException::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
$code = '500';
|
||||
|
||||
$exception = oxNew(\Exception::class);
|
||||
$exception = oxNew( Exception::class);
|
||||
|
||||
/** @var ExportFileException|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(ExportFileException::class)
|
||||
|
@ -19,8 +19,10 @@ use D3\DataWizard\Application\Model\Exceptions\InputUnvalidException;
|
||||
use D3\DataWizard\Application\Model\ExportBase;
|
||||
use D3\DataWizard\tests\tools\d3TestExport;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use Exception;
|
||||
use FormManager\Inputs\Number;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -30,15 +32,14 @@ class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Exceptions\InputUnvalidException::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
$code = '500';
|
||||
|
||||
$exception = oxNew(\Exception::class);
|
||||
$exception = oxNew( Exception::class);
|
||||
|
||||
/** @var Number $invalidField */
|
||||
$invalidField = new Number(null, [
|
||||
'required' => true,
|
||||
'min' => 1,
|
||||
|
@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class NoSuitableRendererExceptionTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -27,13 +29,13 @@ class NoSuitableRendererExceptionTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
$code = '500';
|
||||
|
||||
$exception = oxNew(\Exception::class);
|
||||
$exception = oxNew( Exception::class);
|
||||
|
||||
/** @var NoSuitableRendererException|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(NoSuitableRendererException::class)
|
||||
|
@ -19,7 +19,9 @@ use D3\DataWizard\Application\Model\Exceptions\TaskException;
|
||||
use D3\DataWizard\Application\Model\ExportBase;
|
||||
use D3\DataWizard\tests\tools\d3TestExport;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class TaskExceptionTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -29,13 +31,13 @@ class TaskExceptionTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\Exceptions\TaskException::__construct
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canConstruct()
|
||||
{
|
||||
$code = '500';
|
||||
|
||||
$exception = oxNew(\Exception::class);
|
||||
$exception = oxNew( Exception::class);
|
||||
|
||||
/** @var ExportBase|MockObject $taskMock */
|
||||
$taskMock = $this->getMockBuilder(d3TestExport::class)
|
||||
|
@ -99,7 +99,7 @@ class ExportBaseTest extends d3ModCfgUnitTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function canGetHasFormElementsDataProvider()
|
||||
public function canGetHasFormElementsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'hasFormElements' => [['abc', 'def'], true],
|
||||
@ -285,16 +285,12 @@ class ExportBaseTest extends d3ModCfgUnitTestCase
|
||||
/** @var d3TestExport|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(d3TestExport::class)
|
||||
->onlyMethods([
|
||||
'getQuery',
|
||||
'getExportData',
|
||||
'renderContent',
|
||||
'getContent',
|
||||
'getFileSystem',
|
||||
'getExportFileName'
|
||||
])
|
||||
->getMock();
|
||||
$modelMock->expects($this->atLeastOnce())->method('getQuery')->willReturn(['SELECT 1', ['arg1', 'arg2']]);
|
||||
$modelMock->expects($this->atLeastOnce())->method('getExportData')->willReturn([[1, 2], ['field1', 'field2']]);
|
||||
$modelMock->expects($this->atLeastOnce())->method('renderContent')->willReturn('some content');
|
||||
$modelMock->expects($this->atLeastOnce())->method('getContent')->willReturn('some content');
|
||||
$modelMock->expects($this->atLeastOnce())->method('getFileSystem')->willReturn($fsMock);
|
||||
$modelMock->expects($this->atLeastOnce())->method('getExportFileName')->willReturn('exportFileName');
|
||||
|
||||
@ -604,4 +600,35 @@ class ExportBaseTest extends d3ModCfgUnitTestCase
|
||||
'fulfilled SELECT' => [' SELECT 1', false, [['field1' => 'content1', 'field2' => 'content2']]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportBase::getContent
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetContent()
|
||||
{
|
||||
/** @var d3TestExport|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(d3TestExport::class)
|
||||
->onlyMethods([
|
||||
'getQuery',
|
||||
'getExportData',
|
||||
'renderContent'
|
||||
])
|
||||
->getMock();
|
||||
$modelMock->expects($this->atLeastOnce())->method('getQuery')->willReturn(['SELECT 1', ['arg1', 'arg2']]);
|
||||
$modelMock->expects($this->atLeastOnce())->method('getExportData')->willReturn([[1, 2], ['field1', 'field2']]);
|
||||
$modelMock->expects($this->atLeastOnce())->method('renderContent')->willReturn('some content');
|
||||
|
||||
$this->_oModel = $modelMock;
|
||||
|
||||
$this->assertSame(
|
||||
'some content',
|
||||
$this->callMethod(
|
||||
$this->_oModel,
|
||||
'getContent',
|
||||
['CSV']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ use League\Csv\Writer;
|
||||
use OxidEsales\Eshop\Core\Config;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class CsvTest extends ExportRendererTest
|
||||
{
|
||||
@ -38,7 +39,7 @@ class CsvTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getContent
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @dataProvider canGetContentDataProvider
|
||||
*/
|
||||
public function canGetContent($blThrowException)
|
||||
@ -50,23 +51,19 @@ class CsvTest extends ExportRendererTest
|
||||
/** @var Writer|MockObject $csvMock */
|
||||
$csvMockBuilder = $this->getMockBuilder( Writer::class);
|
||||
$csvMockBuilder->disableOriginalConstructor();
|
||||
$onlyMethods = ['insertOne', 'insertAll'];
|
||||
if (method_exists($csvMockBuilder->getMock(), 'getContent')) {
|
||||
$onlyMethods[] = 'getContent';
|
||||
} else {
|
||||
$csvMockBuilder->addMethods(['getContent']);
|
||||
}
|
||||
$onlyMethods = ['__toString', 'insertOne', 'insertAll'];
|
||||
$csvMockBuilder->onlyMethods($onlyMethods);
|
||||
$csvMock = $csvMockBuilder->getMock();
|
||||
|
||||
$csvMock->method('insertOne')->willReturn(1);
|
||||
$csvMock->method('insertAll')->willReturn(1);
|
||||
|
||||
if ($blThrowException) {
|
||||
$csvMock->expects($this->atLeastOnce())->method('getContent')->willThrowException(oxNew(Exception::class));
|
||||
$csvMock->expects($this->atLeastOnce())->method('__toString')->willThrowException(oxNew(Exception::class));
|
||||
$this->expectException(RenderException::class);
|
||||
} else {
|
||||
$csvMock->expects($this->atLeastOnce())->method('getContent')->willReturn($expected);
|
||||
$csvMock->expects($this->atLeastOnce())->method('__toString')->willReturn($expected);
|
||||
}
|
||||
$csvMock->expects($this->atLeastOnce())->method('insertOne')->with($fieldList)->willReturn(1);
|
||||
$csvMock->expects($this->atLeastOnce())->method('insertAll')->with($valueList)->willReturn(1);
|
||||
|
||||
/** @var Csv|MockObject $modelMock */
|
||||
$modelMock = $this->getMockBuilder(Csv::class)
|
||||
@ -99,7 +96,7 @@ class CsvTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetCsv()
|
||||
{
|
||||
@ -115,7 +112,7 @@ class CsvTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetCsvNoSettings()
|
||||
{
|
||||
@ -165,7 +162,7 @@ class CsvTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::d3GetConfig
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetConfig()
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
|
||||
|
||||
use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use ReflectionException;
|
||||
|
||||
abstract class ExportRendererTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -33,7 +34,7 @@ abstract class ExportRendererTest extends d3ModCfgUnitTestCase
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getFileExtension
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getFileExtension
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetFileExtension()
|
||||
{
|
||||
@ -51,7 +52,7 @@ abstract class ExportRendererTest extends d3ModCfgUnitTestCase
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getTitleTranslationId
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getTitleTranslationId
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetTitleTranslationId()
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
|
||||
|
||||
use D3\DataWizard\Application\Model\Exceptions\RenderException;
|
||||
use D3\DataWizard\Application\Model\ExportRenderer\Json;
|
||||
use ReflectionException;
|
||||
|
||||
class JsonTest extends ExportRendererTest
|
||||
{
|
||||
@ -33,7 +34,7 @@ class JsonTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getContent
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @dataProvider canGetContentDataProvider
|
||||
*/
|
||||
public function canGetContent($valueList, $expectException)
|
||||
|
@ -18,6 +18,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
|
||||
use D3\DataWizard\Application\Model\ExportRenderer\Pretty;
|
||||
use MathieuViossat\Util\ArrayToTextTable;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class PrettyTest extends ExportRendererTest
|
||||
{
|
||||
@ -34,7 +35,7 @@ class PrettyTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getContent
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetContent()
|
||||
{
|
||||
@ -69,7 +70,7 @@ class PrettyTest extends ExportRendererTest
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getArrayToTextTableInstance
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetArrayToTextTableInstance()
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ use D3\DataWizard\Application\Model\ExportRenderer\RendererBridge;
|
||||
use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface;
|
||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionException;
|
||||
|
||||
class RendererBridgeTest extends d3ModCfgUnitTestCase
|
||||
{
|
||||
@ -46,7 +47,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getRendererList
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetRendererList()
|
||||
{
|
||||
@ -62,7 +63,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getTranslatedRendererIdList
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canGetTranslatedRendererIdList()
|
||||
{
|
||||
@ -84,7 +85,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
|
||||
/**
|
||||
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::translateRendererId
|
||||
* @test
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function canTranslateRendererId()
|
||||
{
|
||||
@ -108,7 +109,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
|
||||
* @test
|
||||
* @param $format
|
||||
* @param $blThrowException
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @dataProvider canGetRendererDataProvider
|
||||
*/
|
||||
public function canGetRenderer($format, $blThrowException)
|
||||
|
Reference in New Issue
Block a user