-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PT-12973): Fixed log file flooding with continue on error enabled (…
…#58) * fix(PT-12973): Fixed log file flooding with continue on error enabled * fix(PT-12973): Fixed log file flooding with continue on error enabled * fix(PT-12973): Fixed log file flooding with continue on error enabled * fix(PT-12973): Fixed log file flooding with continue on error enabled
- Loading branch information
Dominik Rathmer
authored
Jul 26, 2023
1 parent
363e889
commit eeab0d5
Showing
6 changed files
with
667 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Tests/Functional/Components/Service/Mock/FileIoMockWithBrokenRecords.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* (c) shopware AG <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SwagImportExport\Tests\Functional\Components\Service\Mock; | ||
|
||
use SwagImportExport\Components\FileIO\FileReader; | ||
use SwagImportExport\Components\FileIO\FileWriter; | ||
use SwagImportExport\Tests\Functional\Components\_fixtures\DataSetBrokenProductImages; | ||
|
||
class FileIoMockWithBrokenRecords implements FileWriter, FileReader | ||
{ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* @param mixed|null $headerData | ||
*/ | ||
public function writeHeader(string $fileName, $headerData): void | ||
{ | ||
\file_put_contents($fileName, $headerData); | ||
} | ||
|
||
/** | ||
* @param mixed|null $treeData | ||
*/ | ||
public function writeRecords(string $fileName, $treeData): void | ||
{ | ||
\file_put_contents($fileName, $treeData, \FILE_APPEND); | ||
} | ||
|
||
public function getTotalCount(string $fileName): int | ||
{ | ||
return 0; | ||
} | ||
|
||
/** | ||
* @param array<string> $tree | ||
*/ | ||
public function setTree(array $tree): void | ||
{ | ||
} | ||
|
||
/** | ||
* @return array<string, array<int, array<string, string>>> | ||
*/ | ||
public function readRecords(string $fileName, int $position, int $step): array | ||
{ | ||
return DataSetBrokenProductImages::getDataSet(); | ||
} | ||
|
||
public function supports(string $format): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function writeFooter(string $fileName, ?array $footerData): void | ||
{ | ||
} | ||
|
||
public function hasTreeStructure(): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* (c) shopware AG <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SwagImportExport\Tests\Functional\Components\Service\Mock; | ||
|
||
use SwagImportExport\Components\Logger\LogDataStruct; | ||
use SwagImportExport\Components\Logger\LoggerInterface; | ||
use SwagImportExport\Components\Session\Session; | ||
|
||
class LogMock implements LoggerInterface | ||
{ | ||
/** | ||
* @var array<array<string>|string> | ||
*/ | ||
private array $logs; | ||
|
||
/** | ||
* @param array<string> $messages | ||
*/ | ||
public function write(array $messages, string $status, Session $session): void | ||
{ | ||
$this->logs[] = $messages; | ||
} | ||
|
||
public function logProcessing(string $writeStatus, string $filename, string $profileName, string $logMessage, string $status, Session $session): void | ||
{ | ||
$logDataStruct = new LogDataStruct( | ||
\date('Y-m-d H:i:s'), | ||
$filename, | ||
$profileName, | ||
$logMessage, | ||
$status | ||
); | ||
|
||
$this->writeToFile($logDataStruct); | ||
} | ||
|
||
public function writeToFile(LogDataStruct $logDataStruct): void | ||
{ | ||
$this->logs[] = $logDataStruct->getMessages(); | ||
} | ||
|
||
/** | ||
* @return array<array<string>|string> | ||
*/ | ||
public function getLogs(): array | ||
{ | ||
return $this->logs; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Tests/Functional/Components/Service/Mock/TransformerChainWithBrokenRecordsMock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* (c) shopware AG <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SwagImportExport\Tests\Functional\Components\Service\Mock; | ||
|
||
use SwagImportExport\Components\Transformers\DataTransformerChain; | ||
use SwagImportExport\Tests\Functional\Components\_fixtures\DataSetBrokenProductImages; | ||
|
||
class TransformerChainWithBrokenRecordsMock extends DataTransformerChain | ||
{ | ||
public function __construct() | ||
{ | ||
// DO NOTHING | ||
} | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
public function composeHeader(): array | ||
{ | ||
return ['new | empty | header | test']; | ||
} | ||
|
||
/** | ||
* @param array<string, array<int, mixed>> $data | ||
* | ||
* @return array<string> | ||
*/ | ||
public function transformForward($data): array | ||
{ | ||
return [\PHP_EOL . 'just | another | return | value']; | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $data | ||
* | ||
* @return array<string, array<int, array<string, string>>> | ||
*/ | ||
public function transformBackward(array $data): array | ||
{ | ||
return DataSetBrokenProductImages::getFixedDataSet(); | ||
} | ||
} |
Oops, something went wrong.