2021-11-25 23:42:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace D3\DataWizard\tests\unit\Application\Model\ExportRenderer;
|
|
|
|
|
2021-11-26 23:16:32 +01:00
|
|
|
use D3\DataWizard\Application\Model\Exceptions\RenderException;
|
2021-11-25 23:42:41 +01:00
|
|
|
use D3\DataWizard\Application\Model\ExportRenderer\Json;
|
2021-12-20 13:41:24 +01:00
|
|
|
use ReflectionException;
|
2021-11-25 23:42:41 +01:00
|
|
|
|
|
|
|
class JsonTest extends ExportRendererTest
|
|
|
|
{
|
|
|
|
/** @var Json */
|
|
|
|
protected $_oModel;
|
|
|
|
|
2022-01-17 10:59:18 +01:00
|
|
|
public function setUp(): void
|
2021-11-25 23:42:41 +01:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->_oModel = oxNew(Json::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \D3\DataWizard\Application\Model\ExportRenderer\Json::getContent
|
|
|
|
* @test
|
2021-12-20 13:41:24 +01:00
|
|
|
* @throws ReflectionException
|
2021-11-26 23:16:32 +01:00
|
|
|
* @dataProvider canGetContentDataProvider
|
2021-11-25 23:42:41 +01:00
|
|
|
*/
|
2021-11-26 23:16:32 +01:00
|
|
|
public function canGetContent($valueList, $expectException)
|
2021-11-25 23:42:41 +01:00
|
|
|
{
|
|
|
|
$fieldList = ['field1', 'field2'];
|
2021-11-26 23:16:32 +01:00
|
|
|
|
|
|
|
if ($expectException) {
|
|
|
|
$this->expectException(RenderException::class);
|
|
|
|
}
|
2021-11-25 23:42:41 +01:00
|
|
|
|
|
|
|
$this->assertJson(
|
|
|
|
$this->callMethod(
|
|
|
|
$this->_oModel,
|
|
|
|
'getContent',
|
|
|
|
[$valueList, $fieldList]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2021-11-26 23:16:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \string[][]
|
|
|
|
*/
|
|
|
|
public function canGetContentDataProvider(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'valid' => [['value1', 'value2'], false],
|
2022-01-17 10:59:18 +01:00
|
|
|
'invalid' => [["text" => "\xB1\x31"], true], // malformed UTF8 chars
|
2021-11-26 23:16:32 +01:00
|
|
|
];
|
|
|
|
}
|
2022-01-17 10:59:18 +01:00
|
|
|
}
|