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 SprykerTest\Zed\BusinessOnBehalfDataImport\Communication\Plugin\DataImport; |
||
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 Spryker\Zed\BusinessOnBehalfDataImport\BusinessOnBehalfDataImportConfig; |
||
15 | use Spryker\Zed\BusinessOnBehalfDataImport\Communication\Plugin\DataImport\BusinessOnBehalfCompanyUserDataImportPlugin; |
||
16 | |||
17 | /** |
||
18 | * Auto-generated group annotations |
||
19 | * |
||
20 | * @group SprykerTest |
||
21 | * @group Zed |
||
22 | * @group BusinessOnBehalfDataImport |
||
23 | * @group Communication |
||
24 | * @group Plugin |
||
25 | * @group DataImport |
||
26 | * @group BusinessOnBehalfCompanyUserDataImportPluginTest |
||
27 | * Add your own group annotations below this line |
||
28 | * |
||
29 | * @group DataImport |
||
30 | * @group CompanyUser |
||
31 | */ |
||
32 | class BusinessOnBehalfCompanyUserDataImportPluginTest extends Unit |
||
33 | { |
||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected const COMPANY_KEY = 'test-company'; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected const BUSINESS_UNIT_KEY = 'test-business-unit'; |
||
43 | |||
44 | /** |
||
45 | * @var \SprykerTest\Zed\BusinessOnBehalfDataImport\BusinessOnBehalfDataImportCommunicationTester |
||
46 | */ |
||
47 | protected $tester; |
||
48 | |||
49 | /** |
||
50 | * @return void |
||
51 | */ |
||
52 | protected function setUp(): void |
||
53 | { |
||
54 | parent::setUp(); |
||
55 | $this->prepareTestData(); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return void |
||
60 | */ |
||
61 | public function testImportImportsData(): void |
||
62 | { |
||
63 | $this->tester->ensureCompanyUserDatabaseTableIsEmpty(); |
||
64 | |||
65 | $dataImporterReaderConfigurationTransfer = new DataImporterReaderConfigurationTransfer(); |
||
66 | $dataImporterReaderConfigurationTransfer->setFileName(codecept_data_dir() . 'import/company_user.csv'); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
67 | |||
68 | $dataImportConfigurationTransfer = new DataImporterConfigurationTransfer(); |
||
69 | $dataImportConfigurationTransfer->setReaderConfiguration($dataImporterReaderConfigurationTransfer); |
||
70 | |||
71 | $businessOnBehalfCompanyUserDataImportPlugin = new BusinessOnBehalfCompanyUserDataImportPlugin(); |
||
72 | $dataImporterReportTransfer = $businessOnBehalfCompanyUserDataImportPlugin->import($dataImportConfigurationTransfer); |
||
73 | |||
74 | $this->assertInstanceOf(DataImporterReportTransfer::class, $dataImporterReportTransfer); |
||
75 | |||
76 | $this->tester->assertDatabaseTableContainsData(); |
||
77 | $this->tester->assertDatabaseTableContainsCorrectData(); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return void |
||
82 | */ |
||
83 | public function testGetImportTypeReturnsTypeOfImporter(): void |
||
84 | { |
||
85 | $businessOnBehalfCompanyUserDataImportPlugin = new BusinessOnBehalfCompanyUserDataImportPlugin(); |
||
86 | $this->assertSame(BusinessOnBehalfDataImportConfig::IMPORT_TYPE_COMPANY_USER, $businessOnBehalfCompanyUserDataImportPlugin->getImportType()); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return void |
||
91 | */ |
||
92 | protected function prepareTestData(): void |
||
93 | { |
||
94 | $this->tester->prepareTestData(); |
||
95 | $companyTransfer = $this->tester->haveCompany(['key' => static::COMPANY_KEY]); |
||
96 | $this->tester->haveCompanyBusinessUnit([ |
||
97 | 'key' => static::BUSINESS_UNIT_KEY, |
||
98 | 'fkCompany' => $companyTransfer->getIdCompany(), |
||
99 | ]); |
||
100 | } |
||
101 | } |
||
102 |