1 | <?php |
||
2 | |||
3 | /** |
||
4 | * MIT License |
||
5 | * For full license information, please view the LICENSE file that was distributed with this source code. |
||
6 | */ |
||
7 | |||
8 | namespace Zed\ProductOfferValidityDataImport\Communication\Plugin; |
||
9 | |||
10 | use Codeception\Test\Unit; |
||
11 | use Generated\Shared\Transfer\DataImporterConfigurationTransfer; |
||
12 | use Generated\Shared\Transfer\DataImporterReaderConfigurationTransfer; |
||
13 | use Generated\Shared\Transfer\DataImporterReportTransfer; |
||
14 | use Generated\Shared\Transfer\ProductOfferTransfer; |
||
15 | use Spryker\Zed\ProductOfferValidityDataImport\Communication\DataImport\ProductOfferValidityDataImportPlugin; |
||
16 | use Spryker\Zed\ProductOfferValidityDataImport\ProductOfferValidityDataImportConfig; |
||
17 | |||
18 | /** |
||
19 | * Auto-generated group annotations |
||
20 | * |
||
21 | * @group Zed |
||
22 | * @group ProductOfferValidityDataImport |
||
23 | * @group Communication |
||
24 | * @group Plugin |
||
25 | * @group ProductOfferValidityDataImportPluginTest |
||
26 | * Add your own group annotations below this line |
||
27 | */ |
||
28 | class ProductOfferValidityDataImportPluginTest extends Unit |
||
29 | { |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected const PRODUCT_OFFER_REFERENCE_VALUE = 'offer10'; |
||
34 | |||
35 | /** |
||
36 | * @var \SprykerTest\Zed\ProductOfferValidityDataImport\ProductOfferValidityDataImportCommunicationTester |
||
37 | */ |
||
38 | protected $tester; |
||
39 | |||
40 | /** |
||
41 | * @return void |
||
42 | */ |
||
43 | protected function setUp(): void |
||
44 | { |
||
45 | parent::setUp(); |
||
46 | |||
47 | $this->tester->ensureProductOfferValidityTableIsEmpty(); |
||
48 | $this->tester->ensureProductOfferTableIsEmpty(); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return void |
||
53 | */ |
||
54 | public function testImportImportsData(): void |
||
55 | { |
||
56 | $this->tester->haveProductOffer([ |
||
57 | ProductOfferTransfer::PRODUCT_OFFER_REFERENCE => static::PRODUCT_OFFER_REFERENCE_VALUE, |
||
58 | ]); |
||
59 | |||
60 | $dataImporterReaderConfigurationTransfer = (new DataImporterReaderConfigurationTransfer()) |
||
61 | ->setFileName(codecept_data_dir() . 'import/product_offer_validity.csv'); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
62 | |||
63 | $dataImportConfigurationTransfer = (new DataImporterConfigurationTransfer()) |
||
64 | ->setReaderConfiguration($dataImporterReaderConfigurationTransfer); |
||
65 | |||
66 | // Act |
||
67 | $productOfferValidityDataImportPlugin = new ProductOfferValidityDataImportPlugin(); |
||
68 | $dataImporterReportTransfer = $productOfferValidityDataImportPlugin->import($dataImportConfigurationTransfer); |
||
69 | |||
70 | // Assert |
||
71 | $this->assertInstanceOf(DataImporterReportTransfer::class, $dataImporterReportTransfer); |
||
72 | $this->tester->assertProductOfferValidityDatabaseTablesContainsData(); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return void |
||
77 | */ |
||
78 | public function testGetImportTypeReturnsTypeOfImporter(): void |
||
79 | { |
||
80 | // Act |
||
81 | $productOfferValidityDataImportPlugin = new ProductOfferValidityDataImportPlugin(); |
||
82 | |||
83 | // Assert |
||
84 | $this->assertSame(ProductOfferValidityDataImportConfig::IMPORT_TYPE_PRODUCT_OFFER_VALIDITY, $productOfferValidityDataImportPlugin->getImportType()); |
||
85 | } |
||
86 | } |
||
87 |