Skip to content

Commit

Permalink
SUPESC-158 Adjusted CSV dataimport validation, twig path reader. (#10…
Browse files Browse the repository at this point in the history
…906)

SUPESC-158 Adjusted CSV dataimport validation, twig path reader.
  • Loading branch information
vol4onok authored Apr 17, 2024
1 parent c0a9749 commit 4edd0fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
namespace Spryker\Zed\DataImport\Business\Model\DataReader\CsvReader;

use Countable;
use Exception;
use Generated\Shared\Transfer\DataImporterReaderConfigurationTransfer;
use SplFileObject;
use Spryker\Zed\DataImport\Business\Exception\DataReaderException;
use Spryker\Zed\DataImport\Business\Exception\DataSetWithHeaderCombineFailedException;
use Spryker\Zed\DataImport\Business\Model\DataReader\ConfigurableDataReaderInterface;
use Spryker\Zed\DataImport\Business\Model\DataReader\DataReaderInterface;
use Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface;
use ValueError;

class CsvReader implements DataReaderInterface, ConfigurableDataReaderInterface, Countable
{
Expand Down Expand Up @@ -173,7 +173,7 @@ public function current(): DataSetInterface
try {
/** @var array $dataSet */
$dataSet = array_combine($this->dataSetKeys, $dataSet);
} catch (Exception $e) {
} catch (ValueError $e) {
throw new DataSetWithHeaderCombineFailedException(sprintf(
'Can not combine data set header with current data set. Keys: "%s", Values "%s"',
implode(', ', $this->dataSetKeys),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Spryker\Zed\DataImport\Business\Exception\DataSetWithHeaderCombineFailedException;
use Spryker\Zed\DataImport\Business\Model\DataReader\CsvReader\CsvReaderConfiguration;
use Spryker\Zed\DataImport\Business\Model\DataSet\DataSet;
use ValueError;

/**
* Auto-generated group annotations
Expand Down Expand Up @@ -227,8 +226,7 @@ public function testThrowsExceptionWhenFileInvalid(): void
*/
public function testThrowsExceptionWhenHeaderAndDataSetLengthDoesNotMatch(): void
{
$exceptionClass = ValueError::class;
$this->expectException($exceptionClass);
$this->expectException(DataSetWithHeaderCombineFailedException::class);
$csvReader = $this->getCsvReader(Configuration::dataDir() . 'import-header-dataset-length-missmatch.csv');

$csvReader->current();
Expand Down

0 comments on commit 4edd0fe

Please sign in to comment.