3 Commits

7 changed files with 66 additions and 13 deletions

View File

@ -224,9 +224,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();
@ -259,4 +257,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,5 +1,16 @@
# Changelog
## 1.5.0.0 (2021-12-21)
#### Added
- add tests
#### Changed
- adjust to CLI extension which can export to STDOUT
- restrict dependencies to OXID 6.2, use 2.x for newer installations
---
## 1.4.0.0 (2021-11-11)
#### Added

View File

@ -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:^1.0
```
Activate the module in the admin area of the shop in "Extensions -> Modules".

View File

@ -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:^1.0
```
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".

View File

@ -26,7 +26,7 @@
],
"require": {
"php": ">=7.1",
"oxid-esales/oxideshop-ce": "6.3 - 6.9",
"oxid-esales/oxideshop-ce": "6.3 - 6.7",
"league/csv": "^9.0",
"mathieuviossat/arraytotexttable": "^1.0",
"form-manager/form-manager": "^5.1 || ^6.1"

View File

@ -32,7 +32,7 @@ $aModule = [
'en' => '',
],
'thumbnail' => '',
'version' => '1.4.0.0',
'version' => '1.5.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']
)
);
}
}