opencart-module/tests/catalog/ControllerRetailcrmApiCatalogTest.php

65 lines
2.0 KiB
PHP
Raw Permalink 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 ControllerRetailcrmApiCatalogTest extends TestCase
2018-06-13 16:13:08 +03:00
{
private $apiKey;
private $retailcrm;
const ORDER_ID = 1;
2020-02-20 15:26:18 +03:00
const USERNAME = 'Default';
2018-06-13 16:13:08 +03:00
public function setUp()
{
parent::setUp();
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE api_id = 1");
$api = $query->row;
$this->apiKey = $api['key'];
$this->retailcrm = new \retailcrm\Retailcrm(self::$registry);
$this->setSetting(
$this->retailcrm->getModuleTitle(),
array(
$this->retailcrm->getModuleTitle() . '_country' => array(1),
)
);
2020-02-20 15:26:18 +03:00
if (isset($this->request->get['key']) && isset($this->request->get['username'])) {
2018-06-13 16:13:08 +03:00
unset($this->request->get['key']);
2020-02-20 15:26:18 +03:00
unset($this->request->get['username']);
2018-06-13 16:13:08 +03:00
}
}
public function testGetDeliveryTypes()
{
$response = $this->dispatchAction('api/retailcrm/getDeliveryTypes');
$data = json_decode($response->getOutput());
$this->assertEquals('Not found api key', $data->error);
$this->request->get['key'] = $this->apiKey;
2020-02-20 15:26:18 +03:00
$this->request->get['username'] = static::USERNAME;
2018-06-13 16:13:08 +03:00
$response = $this->dispatchAction('api/retailcrm/getDeliveryTypes');
$data = json_decode($response->getOutput());
$this->assertNotEmpty($data);
}
public function testAddOrderHistory()
{
$response = $this->dispatchAction('api/retailcrm/addOrderHistory');
$data = json_decode($response->getOutput());
$this->assertEquals('Not found api key', $data->error);
$this->request->get['key'] = $this->apiKey;
2020-02-20 15:26:18 +03:00
$this->request->get['username'] = static::USERNAME;
2018-06-13 16:13:08 +03:00
$response = $this->dispatchAction('api/retailcrm/addOrderHistory');
$data = json_decode($response->getOutput());
$this->assertEquals('Not found data', $data->error);
}
}