Comparer les révisions

...

4 Révisions

5 fichiers modifiés avec 61 ajouts et 15 suppressions

Voir le fichier

@ -225,9 +225,7 @@ abstract class ExportBase implements QueryBase
*/ */
protected function executeExport(string $format, $path): string protected function executeExport(string $format, $path): string
{ {
[$rows, $fieldNames] = $this->getExportData($this->getQuery()); $content = $this->getContent( $format );
$content = $this->renderContent($rows, $fieldNames, $format);
/** @var $oFS d3filesystem */ /** @var $oFS d3filesystem */
$oFS = $this->getFileSystem(); $oFS = $this->getFileSystem();
@ -260,4 +258,21 @@ abstract class ExportBase implements QueryBase
{ {
return oxNew(d3filesystem::class); 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;
}
} }

Voir le fichier

@ -1,6 +1,13 @@
# Changelog # Changelog
## 2.0.0.0 ## 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 #### Added
- add tests - add tests

Voir le fichier

@ -29,10 +29,7 @@
"oxid-esales/oxideshop-ce": "6.8 - 6.10", "oxid-esales/oxideshop-ce": "6.8 - 6.10",
"league/csv": "^9.0", "league/csv": "^9.0",
"mathieuviossat/arraytotexttable": "^1.0", "mathieuviossat/arraytotexttable": "^1.0",
"form-manager/form-manager": "^5.1 || ^6.1" "form-manager/form-manager": "^6.1"
},
"require-dev": {
"oxid-esales/oxideshop-ce": "6.8 - 6.9"
}, },
"extra": { "extra": {
"oxideshop": { "oxideshop": {

Voir le fichier

@ -32,7 +32,7 @@ $aModule = [
'en' => '', 'en' => '',
], ],
'thumbnail' => '', 'thumbnail' => '',
'version' => '2.0.0.0', 'version' => '2.1.0.0',
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',

Voir le fichier

@ -285,16 +285,12 @@ class ExportBaseTest extends d3ModCfgUnitTestCase
/** @var d3TestExport|MockObject $modelMock */ /** @var d3TestExport|MockObject $modelMock */
$modelMock = $this->getMockBuilder(d3TestExport::class) $modelMock = $this->getMockBuilder(d3TestExport::class)
->onlyMethods([ ->onlyMethods([
'getQuery', 'getContent',
'getExportData',
'renderContent',
'getFileSystem', 'getFileSystem',
'getExportFileName' 'getExportFileName'
]) ])
->getMock(); ->getMock();
$modelMock->expects($this->atLeastOnce())->method('getQuery')->willReturn(['SELECT 1', ['arg1', 'arg2']]); $modelMock->expects($this->atLeastOnce())->method('getContent')->willReturn('some content');
$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('getFileSystem')->willReturn($fsMock); $modelMock->expects($this->atLeastOnce())->method('getFileSystem')->willReturn($fsMock);
$modelMock->expects($this->atLeastOnce())->method('getExportFileName')->willReturn('exportFileName'); $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']]], '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']
)
);
}
} }