55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\View;
|
|
use cPad\Plugins\Blocks\Components\Block as BlockComponent;
|
|
|
|
it('renders block html exactly as stored', function () {
|
|
View::addNamespace('plugin.block', base_path('packages/klevze/Plugins/Blocks/Resources/views'));
|
|
|
|
config()->set('app.debug', false);
|
|
app()->setLocale('en');
|
|
|
|
if (! Schema::hasTable('blocks')) {
|
|
Schema::create('blocks', function (Blueprint $table) {
|
|
$table->increments('block_id');
|
|
$table->string('keycode', 64)->unique();
|
|
$table->text('attributes')->nullable();
|
|
$table->text('notes')->nullable();
|
|
$table->boolean('active')->default(true);
|
|
$table->string('block_group', 16)->nullable();
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
$keycode = 'test-block-render-html';
|
|
$html = '<section class="hero"><h1>Title</h1><p><strong>Bold</strong> <em>Italic</em></p><svg><path d="M0 0"></path></svg></section>';
|
|
|
|
DB::table('blocks')->where('keycode', $keycode)->delete();
|
|
DB::table('blocks')->insert([
|
|
'keycode' => $keycode,
|
|
'attributes' => json_encode([
|
|
app()->getLocale() => [
|
|
'content' => $html,
|
|
],
|
|
]),
|
|
'notes' => null,
|
|
'active' => true,
|
|
'block_group' => null,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
try {
|
|
$output = (new BlockComponent($keycode))->render()->render();
|
|
|
|
expect(trim($output))->toBe($html);
|
|
expect($output)->not->toContain('<');
|
|
expect($output)->not->toContain('&');
|
|
} finally {
|
|
DB::table('blocks')->where('keycode', $keycode)->delete();
|
|
}
|
|
});
|