Skip to content

Commit

Permalink
ref #90088 create test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Chaplygin committed Jun 2, 2023
1 parent 8b7522c commit e4cfdd8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/admin/ControllerRetailcrmAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,62 @@ public function testController()
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
$this->assertRegExp('/Connection settings/', $response->getOutput());
}

public function testGetAvailableTypes()
{
$data = $this->getDataForTestAvailableTypes();
$sites = $data['sites'];
$types = $data['types'];

$class = new ReflectionClass(ControllerExtensionModuleRetailcrm::class);
$method = $class->getMethod('getAvailableTypes');
$method->setAccessible(true);

$result = $method->invokeArgs(ControllerExtensionModuleRetailcrm::class, [$sites, $types]);

$this->assertNotEmpty($result['opencart']);
$this->assertNotEmpty($result['retailcrm']);
$this->assertCount(2, $result['retailcrm']);
$this->assertNotEmpty($result['retailcrm']['test1']['code']);
$this->assertNotEmpty($result['retailcrm']['test4']['code']);
}

private function getDataForTestAvailableTypes(): array
{
return [
'sites' => [
'opencart' => [
'code' => 'opencart',
'name' => 'OpenCart'
]
],
'types' => [
'opencart' => [
'test'
],
'retailcrm' => [
'test1' => [
'active' => true,
'sites' => [],
'code' => 'test1'
],
'test2' => [
'active' => false,
'sites' => [],
'code' => 'test2'
],
'test3' => [
'active' => true,
'sites' => ['otherSite'],
'code' => 'test3'
],
'test4' => [
'active' => 'true',
'sites' => ['cms1', 'cms2', 'opencart'],
'code' => 'test4'
]
]
]
];
}
}

0 comments on commit e4cfdd8

Please sign in to comment.