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\CompanyRoleDataImport\Communication\Plugin\DataImport; |
||||
9 | |||||
10 | use Generated\Shared\Transfer\DataImporterConfigurationTransfer; |
||||
11 | use Generated\Shared\Transfer\DataImporterReaderConfigurationTransfer; |
||||
12 | use Generated\Shared\Transfer\DataImporterReportTransfer; |
||||
13 | use Spryker\Zed\CompanyRoleDataImport\Communication\Plugin\DataImport\CompanyUserRoleDataImportPlugin; |
||||
14 | use Spryker\Zed\CompanyRoleDataImport\CompanyRoleDataImportConfig; |
||||
15 | use Spryker\Zed\DataImport\Business\Exception\DataImportException; |
||||
16 | |||||
17 | /** |
||||
18 | * Auto-generated group annotations |
||||
19 | * |
||||
20 | * @group SprykerTest |
||||
21 | * @group Zed |
||||
22 | * @group CompanyRoleDataImport |
||||
23 | * @group Communication |
||||
24 | * @group Plugin |
||||
25 | * @group DataImport |
||||
26 | * @group CompanyUserRoleDataImportPluginTest |
||||
27 | * Add your own group annotations below this line |
||||
28 | */ |
||||
29 | class CompanyUserRoleDataImportPluginTest extends AbstractCompanyRoleDataImportMock |
||||
30 | { |
||||
31 | /** |
||||
32 | * @return void |
||||
33 | */ |
||||
34 | public function testImportCompanyUserRoleData(): void |
||||
35 | { |
||||
36 | $this->tester->truncateCompanyToCompanyUserRoles(); |
||||
37 | $this->tester->assertCompanyRoleToCompanyUserTableIsEmtpy(); |
||||
38 | |||||
39 | $dataImporterReaderConfigurationTransfer = (new DataImporterReaderConfigurationTransfer()) |
||||
40 | ->setFileName(codecept_data_dir() . 'import/company_user_role.csv'); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
41 | |||||
42 | $dataImportConfigurationTransfer = (new DataImporterConfigurationTransfer()) |
||||
43 | ->setReaderConfiguration($dataImporterReaderConfigurationTransfer) |
||||
44 | ->setThrowException(true); |
||||
45 | |||||
46 | $dataImporterReportTransfer = $this->getCompanyUserRoleDataImportPlugin()->import($dataImportConfigurationTransfer); |
||||
47 | |||||
48 | $this->assertInstanceOf(DataImporterReportTransfer::class, $dataImporterReportTransfer); |
||||
49 | $this->assertTrue($dataImporterReportTransfer->getIsSuccess()); |
||||
50 | |||||
51 | $this->tester->assertCompanyRoleToCompanyUserTableHasRecords(); |
||||
52 | } |
||||
53 | |||||
54 | /** |
||||
55 | * @return void |
||||
56 | */ |
||||
57 | public function testImportCompanyUserRoleWithInvlaidCompanyUser(): void |
||||
58 | { |
||||
59 | // Arrange |
||||
60 | $this->tester->truncateCompanyToCompanyUserRoles(); |
||||
61 | $this->tester->assertCompanyRoleToCompanyUserTableIsEmtpy(); |
||||
62 | |||||
63 | $dataImporterReaderConfigurationTransfer = (new DataImporterReaderConfigurationTransfer()) |
||||
64 | ->setFileName(codecept_data_dir() . 'import/company_user_role_with_invalid_company_user.csv'); |
||||
0 ignored issues
–
show
The function
codecept_data_dir was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
65 | |||||
66 | $dataImportConfigurationTransfer = (new DataImporterConfigurationTransfer()) |
||||
67 | ->setReaderConfiguration($dataImporterReaderConfigurationTransfer) |
||||
68 | ->setThrowException(true); |
||||
69 | |||||
70 | // Assert |
||||
71 | $this->expectException(DataImportException::class); |
||||
72 | |||||
73 | // Act |
||||
74 | $this->getCompanyUserRoleDataImportPlugin()->import($dataImportConfigurationTransfer); |
||||
75 | } |
||||
76 | |||||
77 | /** |
||||
78 | * @return void |
||||
79 | */ |
||||
80 | public function testGetImportTypeReturnsTypeOfImporter(): void |
||||
81 | { |
||||
82 | $this->assertSame( |
||||
83 | CompanyRoleDataImportConfig::IMPORT_TYPE_COMPANY_USER_ROLE, |
||||
84 | $this->getCompanyUserRoleDataImportPlugin()->getImportType(), |
||||
85 | ); |
||||
86 | } |
||||
87 | |||||
88 | /** |
||||
89 | * @return \Spryker\Zed\CompanyRoleDataImport\Communication\Plugin\DataImport\CompanyUserRoleDataImportPlugin |
||||
90 | */ |
||||
91 | protected function getCompanyUserRoleDataImportPlugin(): CompanyUserRoleDataImportPlugin |
||||
92 | { |
||||
93 | return new CompanyUserRoleDataImportPlugin(); |
||||
94 | } |
||||
95 | } |
||||
96 |