first commit
This commit is contained in:
14
modules/gamification/tests/autoload.php
Normal file
14
modules/gamification/tests/autoload.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// ========== Mocks ===========
|
||||
require_once __DIR__ . '/mocks/ObjectModel.php';
|
||||
|
||||
// ======== Classes ===========
|
||||
require_once __DIR__ . '/../classes/Advice.php';
|
||||
require_once __DIR__ . '/../classes/GamificationTools.php';
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
define('_PS_VERSION_', 'TEST_VERSION');
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CallToGamificationServerTest extends TestCase
|
||||
{
|
||||
public function testContentIsGzipped()
|
||||
{
|
||||
$workingCallUrl = 'https://gamification.prestashop.com/json/data_EN_IDR_ID.json';
|
||||
|
||||
$response = GamificationTools::retrieveJsonApiFile($workingCallUrl, true);
|
||||
$this->assertContains('Content-Encoding: gzip', $response);
|
||||
}
|
||||
}
|
||||
20
modules/gamification/tests/mocks/ObjectModel.php
Normal file
20
modules/gamification/tests/mocks/ObjectModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class ObjectModel
|
||||
{
|
||||
const TYPE_INT = 1;
|
||||
|
||||
const TYPE_BOOL = 2;
|
||||
|
||||
const TYPE_STRING = 3;
|
||||
|
||||
const TYPE_FLOAT = 4;
|
||||
|
||||
const TYPE_DATE = 5;
|
||||
|
||||
const TYPE_HTML = 6;
|
||||
|
||||
const TYPE_NOTHING = 7;
|
||||
|
||||
const TYPE_SQL = 8;
|
||||
}
|
||||
58
modules/gamification/tests/unit/AdviceTest.php
Normal file
58
modules/gamification/tests/unit/AdviceTest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AdviceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var array the list of expected properties of Advice model
|
||||
*/
|
||||
const ADVICE_PROPERTIES = [
|
||||
'table',
|
||||
'primary',
|
||||
'multilang',
|
||||
'fields',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array the list of fields of Advice model
|
||||
*/
|
||||
const ADVICE_FIELDS = [
|
||||
'id_ps_advice',
|
||||
'id_tab',
|
||||
'selector',
|
||||
'location',
|
||||
'validated',
|
||||
'start_day',
|
||||
'stop_day',
|
||||
'weight',
|
||||
'html',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array the Advice
|
||||
*/
|
||||
private $advice;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->advice = new Advice();
|
||||
}
|
||||
|
||||
public function testAdviceDefinitionIsValid()
|
||||
{
|
||||
$definition = Advice::$definition;
|
||||
|
||||
$this->assertInternalType('array', $definition);
|
||||
|
||||
foreach (self::ADVICE_PROPERTIES as $property) {
|
||||
$this->assertArrayHasKey($property, $definition);
|
||||
}
|
||||
|
||||
$fieldsProperty = $definition['fields'];
|
||||
|
||||
foreach (self::ADVICE_FIELDS as $field) {
|
||||
$this->assertArrayHasKey($field, $fieldsProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user