ref #90088 create test

This commit is contained in:
Ivan Chaplygin 2023-06-02 16:27:31 +03:00
parent 8b7522ca6c
commit e4cfdd8c9f

View File

@ -41,4 +41,62 @@ class ControllerRetailcrmAdminTest extends TestCase
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector'); $response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
$this->assertRegExp('/Connection settings/', $response->getOutput()); $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'
]
]
]
];
}
} }