Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Backend\Tests\Models;
|
|
|
|
use System\Tests\Bootstrap\PluginTestCase;
|
|
use Backend\Models\ImportModel;
|
|
use System\Models\File as FileModel;
|
|
|
|
if (!class_exists('Model')) {
|
|
class_alias('Winter\Storm\Database\Model', 'Model');
|
|
}
|
|
|
|
class ExampleImportModel extends ImportModel
|
|
{
|
|
public $rules = [];
|
|
|
|
public function importData($results, $sessionKey = null)
|
|
{
|
|
return [];
|
|
}
|
|
}
|
|
|
|
class ImportModelTest extends PluginTestCase
|
|
{
|
|
|
|
//
|
|
// Tests
|
|
//
|
|
|
|
public function testDecodeArrayValue()
|
|
{
|
|
$model = new ExampleImportModel;
|
|
$data = 'foo|bar';
|
|
$result = self::callProtectedMethod($model, 'decodeArrayValue', [$data]);
|
|
$this->assertEquals(['foo', 'bar'], $result);
|
|
|
|
$data = 'dps \| heals \| tank|paladin|berserker|gunner';
|
|
$result = self::callProtectedMethod($model, 'decodeArrayValue', [$data]);
|
|
$this->assertEquals(['dps | heals | tank', 'paladin', 'berserker', 'gunner'], $result);
|
|
|
|
$data = 'art direction-roman empire-sci\-fi';
|
|
$result = self::callProtectedMethod($model, 'decodeArrayValue', [$data, '-']);
|
|
$this->assertEquals(['art direction', 'roman empire', 'sci-fi'], $result);
|
|
}
|
|
|
|
public function testGetImportFilePath()
|
|
{
|
|
$model = new ExampleImportModel;
|
|
$sessionKey = uniqid('session_key', true);
|
|
|
|
$file1 = FileModel::create([
|
|
'data' => base_path().'/modules/backend/tests/fixtures/reference/file1.txt',
|
|
'is_public' => false,
|
|
]);
|
|
|
|
$file2 = FileModel::create([
|
|
'data' => base_path().'/modules/backend/tests/fixtures/reference/file2.txt',
|
|
'is_public' => false,
|
|
]);
|
|
|
|
$model->import_file()->add($file1, $sessionKey);
|
|
$model->import_file()->add($file2, $sessionKey);
|
|
|
|
$this->assertEquals(
|
|
$file2->getLocalPath(),
|
|
$model->getImportFilePath($sessionKey),
|
|
'ImportModel::getImportFilePath() should return the last uploaded file.'
|
|
);
|
|
}
|
|
}
|