Compare commits

...

4 Commits

5 changed files with 61 additions and 15 deletions

View File

@ -225,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();
@ -260,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;
}
}

View File

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

View File

@ -29,10 +29,7 @@
"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": {

View File

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

View File

@ -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']
)
);
}
}