feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
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
This commit is contained in:
94
modules/backend/tests/models/ExportModelTest.php
Normal file
94
modules/backend/tests/models/ExportModelTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Backend\Tests\Models;
|
||||
|
||||
use System\Tests\Bootstrap\TestCase;
|
||||
use Backend\Models\ExportModel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
if (!class_exists('Model')) {
|
||||
class_alias('Winter\Storm\Database\Model', 'Model');
|
||||
}
|
||||
|
||||
class ExampleExportModel extends ExportModel
|
||||
{
|
||||
public function exportData($columns, $sessionKey = null)
|
||||
{
|
||||
return [
|
||||
[
|
||||
'foo' => 'bar',
|
||||
'bar' => 'foo',
|
||||
'foobar' => 'Hello World!',
|
||||
],
|
||||
[
|
||||
'foo' => 'bar2',
|
||||
'bar' => 'foo2',
|
||||
'foobar' => 'Hello World2!',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class ExportModelTest extends TestCase
|
||||
{
|
||||
|
||||
//
|
||||
// Tests
|
||||
//
|
||||
|
||||
public function testEncodeArrayValue()
|
||||
{
|
||||
$model = new ExampleExportModel;
|
||||
$data = ['foo', 'bar'];
|
||||
$result = self::callProtectedMethod($model, 'encodeArrayValue', [$data]);
|
||||
$this->assertEquals('foo|bar', $result);
|
||||
|
||||
$data = ['dps | heals | tank', 'paladin', 'berserker', 'gunner'];
|
||||
$result = self::callProtectedMethod($model, 'encodeArrayValue', [$data]);
|
||||
$this->assertEquals('dps \| heals \| tank|paladin|berserker|gunner', $result);
|
||||
|
||||
$data = ['art direction', 'roman empire', 'sci-fi'];
|
||||
$result = self::callProtectedMethod($model, 'encodeArrayValue', [$data, '-']);
|
||||
$this->assertEquals('art direction-roman empire-sci\-fi', $result);
|
||||
}
|
||||
|
||||
public function testDownload()
|
||||
{
|
||||
$model = new ExampleExportModel;
|
||||
|
||||
$csvName = $model->export(['foo' => 'title', 'bar' => 'title2'], []);
|
||||
|
||||
$response = $model->download($csvName);
|
||||
|
||||
$request = new Request();
|
||||
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertTrue($response->headers->has('Content-Type'), "Response is missing the Content-Type header!");
|
||||
|
||||
$contentType = $response->headers->get('Content-Type');
|
||||
$this->assertTrue(
|
||||
str_contains($contentType, 'application/csv')
|
||||
|| str_contains($contentType, 'text/plain')
|
||||
|| str_contains($contentType, 'text/csv'),
|
||||
"Content-Type is not as expected, provided: " . $contentType
|
||||
);
|
||||
|
||||
ob_start();
|
||||
$response->send();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$utf8BOM = chr(239) . chr(187) . chr(191);
|
||||
|
||||
$this->assertEquals($utf8BOM . "title,title2\nbar,foo\nbar2,foo2\n", $output, "CSV is not right!");
|
||||
|
||||
$filePath = temp_path($csvName);
|
||||
|
||||
$fileGotDeleted = !is_file($filePath);
|
||||
|
||||
$this->assertTrue($fileGotDeleted, "Export-CSV doesn't get deleted.");
|
||||
if (!$fileGotDeleted) {
|
||||
unlink($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user