Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Blog\AttachEmbed;
|
||||
use App\Domain\Blog\ContentFormat;
|
||||
use App\Domain\Blog\ContentRenderer;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AttachEmbedTest extends TestCase
|
||||
{
|
||||
public function test_legacy_token_converts_to_markdown_safe_reference(): void
|
||||
{
|
||||
$md = app(AttachEmbed::class)->legacyToMarkdownReference('see [attach=12] please');
|
||||
|
||||
$this->assertStringContainsString('(attach:12)', $md);
|
||||
$this->assertStringNotContainsString('[attach=12]', $md);
|
||||
}
|
||||
|
||||
public function test_markdown_render_expands_attach_protocol_to_entry_url(): void
|
||||
{
|
||||
$html = app(ContentRenderer::class)->toHtml(
|
||||
"\n",
|
||||
ContentFormat::MARKDOWN,
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('/attachment.php?id=42', $html);
|
||||
$this->assertStringNotContainsString('attach:42', $html);
|
||||
}
|
||||
|
||||
public function test_html_render_hydrates_legacy_attach_token(): void
|
||||
{
|
||||
$html = app(ContentRenderer::class)->toHtml(
|
||||
'<p>file [attach=7]</p>',
|
||||
ContentFormat::HTML,
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('/attachment.php?id=7', $html);
|
||||
$this->assertStringNotContainsString('[attach=7]', $html);
|
||||
}
|
||||
|
||||
public function test_html_img_src_attach_attribute_is_not_nested(): void
|
||||
{
|
||||
$html = app(ContentRenderer::class)->toHtml(
|
||||
'<p><img src="[attach=1]" alt="pic"></p>',
|
||||
ContentFormat::HTML,
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('src="'.url('/attachment.php?id=1').'"', $html);
|
||||
$this->assertStringNotContainsString('src="<img', $html);
|
||||
$this->assertStringNotContainsString('[attach=1]', $html);
|
||||
}
|
||||
|
||||
public function test_markdown_import_conversion_protects_attach_tokens(): void
|
||||
{
|
||||
$md = app(ContentRenderer::class)->convertImportedHtmlToMarkdown(
|
||||
'<p><img src="[attach=1]" alt="pic"> and [attach=2]</p>'
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('(attach:1)', $md);
|
||||
$this->assertStringContainsString('(attach:2)', $md);
|
||||
$this->assertStringNotContainsString(';
|
||||
$this->assertStringNotContainsString('\[attach=', $md);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Blog\ContentFormat;
|
||||
use App\Domain\Blog\ContentRenderer;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContentRendererTest extends TestCase
|
||||
{
|
||||
public function test_markdown_renders_to_html(): void
|
||||
{
|
||||
$html = app(ContentRenderer::class)->toHtml("# Hello\n\n**world**", ContentFormat::MARKDOWN);
|
||||
|
||||
$this->assertMatchesRegularExpression('/<h1[^>]*>Hello<\/h1>/', $html);
|
||||
$this->assertStringContainsString('<strong>world</strong>', $html);
|
||||
}
|
||||
|
||||
public function test_html_format_passes_through_purifier(): void
|
||||
{
|
||||
$html = app(ContentRenderer::class)->toHtml(
|
||||
'<p>ok</p><script>alert(1)</script>',
|
||||
ContentFormat::HTML,
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('<p>ok</p>', $html);
|
||||
$this->assertStringNotContainsString('<script>', $html);
|
||||
}
|
||||
|
||||
public function test_html_to_markdown_roundtrip_basic(): void
|
||||
{
|
||||
$md = app(ContentRenderer::class)->htmlToMarkdown('<h2>Title</h2><p>Hello <strong>x</strong></p>');
|
||||
|
||||
$this->assertStringContainsString('Title', $md);
|
||||
$this->assertStringContainsString('Hello', $md);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Blog\ContentFormat;
|
||||
use App\Domain\Blog\ContentRenderer;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContentTocTest extends TestCase
|
||||
{
|
||||
public function test_markdown_headings_produce_toc_and_ids(): void
|
||||
{
|
||||
$markdown = <<<'MD'
|
||||
Intro paragraph.
|
||||
|
||||
## First Section
|
||||
|
||||
Hello.
|
||||
|
||||
### Nested
|
||||
|
||||
More.
|
||||
|
||||
## Second Section
|
||||
|
||||
End.
|
||||
MD;
|
||||
|
||||
$result = app(ContentRenderer::class)->render($markdown, ContentFormat::MARKDOWN);
|
||||
|
||||
$this->assertCount(3, $result['toc']);
|
||||
$this->assertSame('First Section', $result['toc'][0]['text']);
|
||||
$this->assertSame(2, $result['toc'][0]['level']);
|
||||
$this->assertSame('Nested', $result['toc'][1]['text']);
|
||||
$this->assertSame(3, $result['toc'][1]['level']);
|
||||
$this->assertStringContainsString('id="', $result['html']);
|
||||
$this->assertStringContainsString($result['toc'][0]['id'], $result['html']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_that_true_is_true(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Theme\ThemeManager;
|
||||
use App\Domain\Theme\ThemeSlot;
|
||||
use App\Domain\Theme\ThemeSlotReport;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ThemeSlotReportTest extends TestCase
|
||||
{
|
||||
public function test_star_declares_all_standard_slots(): void
|
||||
{
|
||||
$this->assertSame(ThemeSlot::all(), ThemeSlotReport::normalizeDeclared('*'));
|
||||
}
|
||||
|
||||
public function test_default_and_example_themes_report_full(): void
|
||||
{
|
||||
$manager = app(ThemeManager::class);
|
||||
|
||||
foreach (['default', 'example'] as $slug) {
|
||||
$report = $manager->slotReport($slug);
|
||||
$this->assertSame('full', $report['status'], $slug.' should be full: '.json_encode($report));
|
||||
$this->assertSame([], $report['missing_standard']);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_undeclared_manifest_status(): void
|
||||
{
|
||||
$report = ThemeSlotReport::analyze('tmp', [], base_path('themes/default'));
|
||||
$this->assertSame('undeclared', $report['status']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user