Cette révision appartient à :
Daniel Seifert 2021-12-20 13:41:24 +01:00
Parent 67c462ccda
révision e604b84849
Signé par: DanielS
ID de la clé GPG: 8A7C4C6ED1915C6F
23 fichiers modifiés avec 77 ajouts et 75 suppressions

Voir le fichier

@ -19,14 +19,11 @@ use D3\DataWizard\Application\Model\Configuration;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException; use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException; use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\ModCfg\Application\Model\d3database; 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 Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
class d3ActionWizard extends AdminDetailsController class d3ActionWizard extends AdminDetailsController
@ -43,7 +40,7 @@ class d3ActionWizard extends AdminDetailsController
$this->configuration = oxNew(Configuration::class); $this->configuration = oxNew(Configuration::class);
} }
public function getGroups() public function getGroups(): array
{ {
return $this->configuration->getActionGroups(); return $this->configuration->getActionGroups();
} }
@ -55,9 +52,6 @@ class d3ActionWizard extends AdminDetailsController
/** /**
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
* @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/ */
public function runTask() public function runTask()
{ {
@ -93,7 +87,7 @@ class d3ActionWizard extends AdminDetailsController
/** /**
* @return Config * @return Config
*/ */
public function d3GetConfig() public function d3GetConfig(): Config
{ {
return Registry::getConfig(); return Registry::getConfig();
} }

Voir le fichier

@ -45,7 +45,7 @@ class d3ExportWizard extends AdminDetailsController
$this->configuration = oxNew(Configuration::class); $this->configuration = oxNew(Configuration::class);
} }
public function getGroups() public function getGroups(): array
{ {
return $this->configuration->getExportGroups(); return $this->configuration->getExportGroups();
} }
@ -101,7 +101,7 @@ class d3ExportWizard extends AdminDetailsController
/** /**
* @return Config * @return Config
*/ */
public function d3GetConfig() public function d3GetConfig(): Config
{ {
return Registry::getConfig(); return Registry::getConfig();
} }

Voir le fichier

@ -95,7 +95,7 @@ abstract class ActionBase implements QueryBase
* @return DatabaseInterface|null * @return DatabaseInterface|null
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function d3GetDb() public function d3GetDb(): ?DatabaseInterface
{ {
return DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC ); return DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC );
} }

Voir le fichier

@ -15,11 +15,7 @@ declare(strict_types=1);
namespace D3\DataWizard\Application\Model; namespace D3\DataWizard\Application\Model;
use D3\DataWizard\Application\Model\Actions\FixArtextendsItems;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException; 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 class Configuration
{ {

Voir le fichier

@ -25,6 +25,7 @@ use Doctrine\DBAL\DBALException;
use FormManager\Inputs\Checkbox; use FormManager\Inputs\Checkbox;
use FormManager\Inputs\Input; use FormManager\Inputs\Input;
use FormManager\Inputs\Radio; use FormManager\Inputs\Radio;
use OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface;
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
@ -94,7 +95,7 @@ abstract class ExportBase implements QueryBase
/** /**
* @return RendererBridge * @return RendererBridge
*/ */
public function getRendererBridge() public function getRendererBridge(): RendererBridge
{ {
return oxNew(RendererBridge::class); return oxNew(RendererBridge::class);
} }
@ -244,10 +245,10 @@ abstract class ExportBase implements QueryBase
} }
/** /**
* @return \OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface|null * @return DatabaseInterface|null
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
protected function d3GetDb(): ?\OxidEsales\Eshop\Core\Database\Adapter\DatabaseInterface protected function d3GetDb(): ?DatabaseInterface
{ {
return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
} }

Voir le fichier

@ -37,7 +37,7 @@ class Csv implements RendererInterface
$csv = $this->getCsv(); $csv = $this->getCsv();
$csv->insertOne( $fieldNames ); $csv->insertOne( $fieldNames );
$csv->insertAll( $rows ); $csv->insertAll( $rows );
return method_exists($csv, 'getContent') ? $csv->getContent() : (string) $csv; return (string) $csv;
} catch (Exception $e) { } catch (Exception $e) {
/** @var RenderException $newException */ /** @var RenderException $newException */
$newException = oxNew(RenderException::class, $e->getMessage(), $e->getCode(), $e ); $newException = oxNew(RenderException::class, $e->getMessage(), $e->getCode(), $e );
@ -86,7 +86,7 @@ class Csv implements RendererInterface
/** /**
* @return Config * @return Config
*/ */
public function d3GetConfig() public function d3GetConfig(): Config
{ {
return Registry::getConfig(); return Registry::getConfig();
} }

Voir le fichier

@ -35,7 +35,7 @@ class Pretty implements RendererInterface
* @param $rows * @param $rows
* @return ArrayToTextTable * @return ArrayToTextTable
*/ */
public function getArrayToTextTableInstance($rows) public function getArrayToTextTableInstance($rows): ArrayToTextTable
{ {
return oxNew(ArrayToTextTable::class, $rows); return oxNew(ArrayToTextTable::class, $rows);
} }

Voir le fichier

@ -35,7 +35,7 @@ class RendererBridge
]; ];
} }
public function getTranslatedRendererIdList() public function getTranslatedRendererIdList(): array
{ {
$rendererList = $this->getRendererList(); $rendererList = $this->getRendererList();
array_walk($rendererList, [$this, 'translateRendererId']); array_walk($rendererList, [$this, 'translateRendererId']);

Voir le fichier

@ -11,5 +11,5 @@
* @link https://www.oxidmodule.com * @link https://www.oxidmodule.com
*/ */
define('D3DATAWIZARD_REQUIRE_MODCFG', true); const D3DATAWIZARD_REQUIRE_MODCFG = true;

Voir le fichier

@ -13,6 +13,6 @@ class d3TestExport extends ExportBase
public function getQuery(): array public function getQuery(): array
{ {
return "SELECT 1"; return ["SELECT 1"];
} }
} }

Voir le fichier

@ -94,7 +94,7 @@ class ActionBaseTest extends d3ModCfgUnitTestCase
); );
} }
public function canGetHasFormElementsDataProvider() public function canGetHasFormElementsDataProvider(): array
{ {
return [ return [
'hasFormElements' => [['abc', 'def'], true], 'hasFormElements' => [['abc', 'def'], true],

Voir le fichier

@ -21,6 +21,7 @@ use D3\DataWizard\tests\tools\d3TestAction;
use D3\DataWizard\tests\tools\d3TestExport; use D3\DataWizard\tests\tools\d3TestExport;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class ConfigurationTest extends d3ModCfgUnitTestCase class ConfigurationTest extends d3ModCfgUnitTestCase
{ {
@ -44,7 +45,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::__construct * @covers \D3\DataWizard\Application\Model\Configuration::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
@ -65,7 +66,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::configure() * @covers \D3\DataWizard\Application\Model\Configuration::configure()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConfigure() public function canConfigure()
{ {
@ -80,7 +81,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::registerAction * @covers \D3\DataWizard\Application\Model\Configuration::registerAction
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canRegisterAction() public function canRegisterAction()
{ {
@ -113,7 +114,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::registerExport * @covers \D3\DataWizard\Application\Model\Configuration::registerExport
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canRegisterExport() public function canRegisterExport()
{ {
@ -166,7 +167,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getGroupedActions() * @covers \D3\DataWizard\Application\Model\Configuration::getGroupedActions()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetGroupedActions() public function canGetGroupedActions()
{ {
@ -190,7 +191,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getGroupedExports() * @covers \D3\DataWizard\Application\Model\Configuration::getGroupedExports()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetGroupedExports() public function canGetGroupedExports()
{ {
@ -214,7 +215,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getActionGroups() * @covers \D3\DataWizard\Application\Model\Configuration::getActionGroups()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetActionGroups() public function canGetActionGroups()
{ {
@ -238,7 +239,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getExportGroups() * @covers \D3\DataWizard\Application\Model\Configuration::getExportGroups()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetExportGroups() public function canGetExportGroups()
{ {
@ -262,7 +263,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getActionsByGroup() * @covers \D3\DataWizard\Application\Model\Configuration::getActionsByGroup()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetActionsByGroup() public function canGetActionsByGroup()
{ {
@ -287,7 +288,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getExportsByGroup() * @covers \D3\DataWizard\Application\Model\Configuration::getExportsByGroup()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetExportsByGroup() public function canGetExportsByGroup()
{ {
@ -312,7 +313,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getAllActions() * @covers \D3\DataWizard\Application\Model\Configuration::getAllActions()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetAllActions() public function canGetAllActions()
{ {
@ -343,7 +344,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getAllExports() * @covers \D3\DataWizard\Application\Model\Configuration::getAllExports()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetAllExports() public function canGetAllExports()
{ {
@ -374,7 +375,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getActionById() * @covers \D3\DataWizard\Application\Model\Configuration::getActionById()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
* @dataProvider canGetActionByIdDataProvider * @dataProvider canGetActionByIdDataProvider
*/ */
public function canGetActionById($id, $throwException) public function canGetActionById($id, $throwException)
@ -409,7 +410,7 @@ class ConfigurationTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Configuration::getExportById() * @covers \D3\DataWizard\Application\Model\Configuration::getExportById()
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
* @dataProvider canGetActionByIdDataProvider * @dataProvider canGetActionByIdDataProvider
*/ */
public function canGetExportById($id, $throwException) public function canGetExportById($id, $throwException)

Voir le fichier

@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
use D3\DataWizard\Application\Model\Exceptions\DebugException; use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class DebugExceptionTest extends d3ModCfgUnitTestCase class DebugExceptionTest extends d3ModCfgUnitTestCase
{ {
@ -27,13 +29,13 @@ class DebugExceptionTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Exceptions\DebugException::__construct * @covers \D3\DataWizard\Application\Model\Exceptions\DebugException::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
$code = '500'; $code = '500';
$exception = oxNew(\Exception::class); $exception = oxNew( Exception::class);
/** @var DebugException|MockObject $modelMock */ /** @var DebugException|MockObject $modelMock */
$modelMock = $this->getMockBuilder(DebugException::class) $modelMock = $this->getMockBuilder(DebugException::class)

Voir le fichier

@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
use D3\DataWizard\Application\Model\Exceptions\ExportFileException; use D3\DataWizard\Application\Model\Exceptions\ExportFileException;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class ExportFileExceptionTest extends d3ModCfgUnitTestCase class ExportFileExceptionTest extends d3ModCfgUnitTestCase
{ {
@ -27,13 +29,13 @@ class ExportFileExceptionTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Exceptions\ExportFileException::__construct * @covers \D3\DataWizard\Application\Model\Exceptions\ExportFileException::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
$code = '500'; $code = '500';
$exception = oxNew(\Exception::class); $exception = oxNew( Exception::class);
/** @var ExportFileException|MockObject $modelMock */ /** @var ExportFileException|MockObject $modelMock */
$modelMock = $this->getMockBuilder(ExportFileException::class) $modelMock = $this->getMockBuilder(ExportFileException::class)

Voir le fichier

@ -19,8 +19,10 @@ use D3\DataWizard\Application\Model\Exceptions\InputUnvalidException;
use D3\DataWizard\Application\Model\ExportBase; use D3\DataWizard\Application\Model\ExportBase;
use D3\DataWizard\tests\tools\d3TestExport; use D3\DataWizard\tests\tools\d3TestExport;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use Exception;
use FormManager\Inputs\Number; use FormManager\Inputs\Number;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase
{ {
@ -30,15 +32,14 @@ class InputUnvalidExceptionTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Exceptions\InputUnvalidException::__construct * @covers \D3\DataWizard\Application\Model\Exceptions\InputUnvalidException::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
$code = '500'; $code = '500';
$exception = oxNew(\Exception::class); $exception = oxNew( Exception::class);
/** @var Number $invalidField */
$invalidField = new Number(null, [ $invalidField = new Number(null, [
'required' => true, 'required' => true,
'min' => 1, 'min' => 1,

Voir le fichier

@ -17,7 +17,9 @@ namespace D3\DataWizard\tests\unit\Application\Model\Exceptions;
use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException; use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class NoSuitableRendererExceptionTest extends d3ModCfgUnitTestCase class NoSuitableRendererExceptionTest extends d3ModCfgUnitTestCase
{ {
@ -27,13 +29,13 @@ class NoSuitableRendererExceptionTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException::__construct * @covers \D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
$code = '500'; $code = '500';
$exception = oxNew(\Exception::class); $exception = oxNew( Exception::class);
/** @var NoSuitableRendererException|MockObject $modelMock */ /** @var NoSuitableRendererException|MockObject $modelMock */
$modelMock = $this->getMockBuilder(NoSuitableRendererException::class) $modelMock = $this->getMockBuilder(NoSuitableRendererException::class)

Voir le fichier

@ -19,7 +19,9 @@ use D3\DataWizard\Application\Model\Exceptions\TaskException;
use D3\DataWizard\Application\Model\ExportBase; use D3\DataWizard\Application\Model\ExportBase;
use D3\DataWizard\tests\tools\d3TestExport; use D3\DataWizard\tests\tools\d3TestExport;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class TaskExceptionTest extends d3ModCfgUnitTestCase class TaskExceptionTest extends d3ModCfgUnitTestCase
{ {
@ -29,13 +31,13 @@ class TaskExceptionTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\Exceptions\TaskException::__construct * @covers \D3\DataWizard\Application\Model\Exceptions\TaskException::__construct
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canConstruct() public function canConstruct()
{ {
$code = '500'; $code = '500';
$exception = oxNew(\Exception::class); $exception = oxNew( Exception::class);
/** @var ExportBase|MockObject $taskMock */ /** @var ExportBase|MockObject $taskMock */
$taskMock = $this->getMockBuilder(d3TestExport::class) $taskMock = $this->getMockBuilder(d3TestExport::class)

Voir le fichier

@ -99,7 +99,7 @@ class ExportBaseTest extends d3ModCfgUnitTestCase
); );
} }
public function canGetHasFormElementsDataProvider() public function canGetHasFormElementsDataProvider(): array
{ {
return [ return [
'hasFormElements' => [['abc', 'def'], true], 'hasFormElements' => [['abc', 'def'], true],

Voir le fichier

@ -22,6 +22,7 @@ use League\Csv\Writer;
use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class CsvTest extends ExportRendererTest class CsvTest extends ExportRendererTest
{ {
@ -38,7 +39,7 @@ class CsvTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getContent * @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getContent
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
* @dataProvider canGetContentDataProvider * @dataProvider canGetContentDataProvider
*/ */
public function canGetContent($blThrowException) public function canGetContent($blThrowException)
@ -48,25 +49,21 @@ class CsvTest extends ExportRendererTest
$valueList = ['value1', 'value2']; $valueList = ['value1', 'value2'];
/** @var Writer|MockObject $csvMock */ /** @var Writer|MockObject $csvMock */
$csvMockBuilder = $this->getMockBuilder(Writer::class); $csvMockBuilder = $this->getMockBuilder( Writer::class);
$csvMockBuilder->disableOriginalConstructor(); $csvMockBuilder->disableOriginalConstructor();
$onlyMethods = ['insertOne', 'insertAll']; $onlyMethods = ['__toString', 'insertOne', 'insertAll'];
if (method_exists($csvMockBuilder->getMock(), 'getContent')) {
$onlyMethods[] = 'getContent';
} else {
$csvMockBuilder->addMethods(['getContent']);
}
$csvMockBuilder->onlyMethods($onlyMethods); $csvMockBuilder->onlyMethods($onlyMethods);
$csvMock = $csvMockBuilder->getMock(); $csvMock = $csvMockBuilder->getMock();
$csvMock->method('insertOne')->willReturn(1);
$csvMock->method('insertAll')->willReturn(1);
if ($blThrowException) { 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); $this->expectException(RenderException::class);
} else { } 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 */ /** @var Csv|MockObject $modelMock */
$modelMock = $this->getMockBuilder(Csv::class) $modelMock = $this->getMockBuilder(Csv::class)
@ -99,7 +96,7 @@ class CsvTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv * @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetCsv() public function canGetCsv()
{ {
@ -115,7 +112,7 @@ class CsvTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv * @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::getCsv
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetCsvNoSettings() public function canGetCsvNoSettings()
{ {
@ -165,7 +162,7 @@ class CsvTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::d3GetConfig * @covers \D3\DataWizard\Application\Model\ExportRenderer\Csv::d3GetConfig
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetConfig() public function canGetConfig()
{ {

Voir le fichier

@ -15,6 +15,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface; use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use ReflectionException;
abstract class ExportRendererTest extends d3ModCfgUnitTestCase 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\Json::getFileExtension
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getFileExtension * @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getFileExtension
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetFileExtension() 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\Json::getTitleTranslationId
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getTitleTranslationId * @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getTitleTranslationId
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetTitleTranslationId() public function canGetTitleTranslationId()
{ {

Voir le fichier

@ -17,6 +17,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
use D3\DataWizard\Application\Model\Exceptions\RenderException; use D3\DataWizard\Application\Model\Exceptions\RenderException;
use D3\DataWizard\Application\Model\ExportRenderer\Json; use D3\DataWizard\Application\Model\ExportRenderer\Json;
use ReflectionException;
class JsonTest extends ExportRendererTest class JsonTest extends ExportRendererTest
{ {
@ -33,7 +34,7 @@ class JsonTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getContent * @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getContent
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
* @dataProvider canGetContentDataProvider * @dataProvider canGetContentDataProvider
*/ */
public function canGetContent($valueList, $expectException) public function canGetContent($valueList, $expectException)

Voir le fichier

@ -18,6 +18,7 @@ namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
use D3\DataWizard\Application\Model\ExportRenderer\Pretty; use D3\DataWizard\Application\Model\ExportRenderer\Pretty;
use MathieuViossat\Util\ArrayToTextTable; use MathieuViossat\Util\ArrayToTextTable;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class PrettyTest extends ExportRendererTest class PrettyTest extends ExportRendererTest
{ {
@ -34,7 +35,7 @@ class PrettyTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getContent * @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getContent
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetContent() public function canGetContent()
{ {
@ -69,7 +70,7 @@ class PrettyTest extends ExportRendererTest
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getArrayToTextTableInstance * @covers \D3\DataWizard\Application\Model\ExportRenderer\Pretty::getArrayToTextTableInstance
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetArrayToTextTableInstance() public function canGetArrayToTextTableInstance()
{ {

Voir le fichier

@ -23,6 +23,7 @@ use D3\DataWizard\Application\Model\ExportRenderer\RendererBridge;
use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface; use D3\DataWizard\Application\Model\ExportRenderer\RendererInterface;
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class RendererBridgeTest extends d3ModCfgUnitTestCase class RendererBridgeTest extends d3ModCfgUnitTestCase
{ {
@ -46,7 +47,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getRendererList * @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getRendererList
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetRendererList() public function canGetRendererList()
{ {
@ -62,7 +63,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getTranslatedRendererIdList * @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::getTranslatedRendererIdList
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canGetTranslatedRendererIdList() public function canGetTranslatedRendererIdList()
{ {
@ -84,7 +85,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
/** /**
* @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::translateRendererId * @covers \D3\DataWizard\Application\Model\ExportRenderer\RendererBridge::translateRendererId
* @test * @test
* @throws \ReflectionException * @throws ReflectionException
*/ */
public function canTranslateRendererId() public function canTranslateRendererId()
{ {
@ -108,7 +109,7 @@ class RendererBridgeTest extends d3ModCfgUnitTestCase
* @test * @test
* @param $format * @param $format
* @param $blThrowException * @param $blThrowException
* @throws \ReflectionException * @throws ReflectionException
* @dataProvider canGetRendererDataProvider * @dataProvider canGetRendererDataProvider
*/ */
public function canGetRenderer($format, $blThrowException) public function canGetRenderer($format, $blThrowException)