Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
175bcdd956
|
|||
532e5f6960
|
@ -224,9 +224,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();
|
||||||
@ -259,4 +257,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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,11 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.5.0.0 (2021-12-20)
|
## 1.5.0.0 (2021-12-21)
|
||||||
|
|
||||||
#### Added
|
#### Added
|
||||||
- add tests
|
- add tests
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
|
- adjust to CLI extension which can export to STDOUT
|
||||||
- restrict dependencies to OXID 6.2, use 2.x for newer installations
|
- restrict dependencies to OXID 6.2, use 2.x for newer installations
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -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']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user