opencart-module/tests/admin/ControllerRetailcrmAdminTest.php

45 lines
1.7 KiB
PHP
Raw Normal View History

2018-06-13 16:13:08 +03:00
<?php
2020-02-19 21:50:16 +03:00
require_once __DIR__ . '/../' . getenv('TEST_SUITE') . '/TestCase.php';
2020-02-19 12:37:03 +03:00
class ControllerRetailcrmAdminTest extends TestCase
2018-06-13 16:13:08 +03:00
{
const MODULE_TITLE = 'retailcrm';
public function setUp()
{
2020-02-20 15:26:18 +03:00
parent::setUp();
2018-06-13 16:13:08 +03:00
$query = $this->db->query("SELECT permission from ".DB_PREFIX."user_group WHERE name = 'Administrator'");
$permissions = json_decode($query->row['permission'],true);
2020-02-20 15:26:18 +03:00
if (!in_array('extension/module/retailcrm', $permissions['access'])) {
2018-06-13 16:13:08 +03:00
$permissions['access'][] = 'extension/module/retailcrm';
$this->db->query("UPDATE ".DB_PREFIX."user_group SET permission='".$this->db->escape(json_encode($permissions))."' WHERE name = 'Administrator'");
}
$this->retailcrm = $this->getMockBuilder('\retailcrm\Retailcrm')
->disableOriginalConstructor()
->getMock();
}
public function testController()
2018-06-13 16:13:08 +03:00
{
$this->login('admin', 'admin');
$response = $this->dispatchAction('extension/module/retailcrm');
$this->assertRegExp('/Connection settings/', $response->getOutput());
$response = $this->dispatchAction('extension/module/retailcrm/icml');
$this->assertRegExp('/Connection settings/', $response->getOutput());
$this->assertFileExists(DIR_SYSTEM . '../' . 'retailcrm.xml');
$response = $this->dispatchAction('extension/module/retailcrm/install_collector');
$this->assertRegExp('/Connection settings/', $response->getOutput());
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
$this->assertRegExp('/Connection settings/', $response->getOutput());
}
}