Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Tokenizer/Tokens/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
abstract class Token
{
abstract public function getType(): string;

abstract public function toArray(): array;
}
}
4 changes: 1 addition & 3 deletions tests/BenchmarkTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Artisan;

beforeEach(function () {
// Register anonymous components used by the benchmark
Expand Down Expand Up @@ -58,4 +56,4 @@ function clearCache() {
fwrite(STDOUT, "Blaze enabled but no folding - render 25k component loop: " . number_format($duration, 2) . " ms\n");

expect(true)->toBeTrue();
})->skip();
});
18 changes: 9 additions & 9 deletions tests/BlazeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Configure Blade to find our test components and views
app('blade.compiler')->anonymousComponentNamespace('', 'x');
app('blade.compiler')->anonymousComponentPath(__DIR__ . '/fixtures/components');

// Add view path for our test pages
View::addLocation(__DIR__ . '/fixtures/pages');
});
Expand All @@ -22,18 +22,18 @@
<x-alert message="Success!" />
</x-card>
</div>';

$rendered = \Illuminate\Support\Facades\Blade::render($template);

// Pure components should be folded to optimized HTML
expect($rendered)->toContain('<button type="button">Save Changes</button>');
expect($rendered)->toContain('<div class="card">');
expect($rendered)->toContain('<div class="alert">Success!</div>');

expect($rendered)->not->toContain('<x-button>');
expect($rendered)->not->toContain('<x-card>');
expect($rendered)->not->toContain('<x-alert');

// Should contain the page structure
expect($rendered)->toContain('<div class="page">');
expect($rendered)->toContain('<h1>Integration Test</h1>');
Expand All @@ -42,11 +42,11 @@
it('leaves non-pure components unchanged through blade facade', function () {
$template = '<div><x-impure-button>Test Button</x-impure-button></div>';
$rendered = \Illuminate\Support\Facades\Blade::render($template);

// Non-pure component should render normally (not folded)
expect($rendered)->toContain('<button type="button">Test Button</button>');
expect($rendered)->not->toContain('<x-impure-button>');

// Just verify it renders normally
});

Expand All @@ -58,12 +58,12 @@
it('preserves slot content when folding components', function () {
$template = '<x-card><h2>Dynamic Title</h2><p>Dynamic content with <em>emphasis</em></p></x-card>';
$rendered = \Illuminate\Support\Facades\Blade::render($template);

// Should preserve all slot content in folded output
expect($rendered)->toContain('<h2>Dynamic Title</h2>');
expect($rendered)->toContain('<p>Dynamic content with <em>emphasis</em></p>');
expect($rendered)->toContain('<div class="card">');
expect($rendered)->not->toContain('<x-card>');
});

});
});
28 changes: 13 additions & 15 deletions tests/InfiniteRecursionTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Illuminate\Support\Facades\View;

describe('infinite recursion bugs', function () {
beforeEach(function () {
// Configure Blade to find our test components and views
Expand All @@ -11,10 +9,10 @@

it('should handle dynamic attributes without infinite recursion', function () {
$template = '<x-button type="submit" class="btn-primary">Submit</x-button>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<button');
expect($rendered)->toContain('type="submit"');
expect($rendered)->toContain('class="btn-primary"');
Expand All @@ -24,10 +22,10 @@

it('should handle nested pure components without infinite recursion', function () {
$template = '<x-card><x-alert message="Nested alert!" /></x-card>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<div class="card">');
expect($rendered)->toContain('<div class="alert">');
expect($rendered)->toContain('Nested alert!');
Expand All @@ -42,10 +40,10 @@
<x-alert message="Alert in card" />
<x-button type="submit" class="secondary">Button 2</x-button>
</x-card>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<div class="card">');
expect($rendered)->toContain('Button 1');
expect($rendered)->toContain('Button 2');
Expand All @@ -69,10 +67,10 @@
<x-button type="submit">Outer Button</x-button>
</x-card>
</div>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<div class="wrapper">');
expect($rendered)->toContain('<h1>Outer Card</h1>');
expect($rendered)->toContain('<h2>Inner Card</h2>');
Expand All @@ -94,10 +92,10 @@ class="btn-primary btn-large"
aria-label="Save changes">
Save Changes
</x-button>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<button');
expect($rendered)->toContain('type="submit"');
expect($rendered)->toContain('class="btn-primary btn-large"');
Expand All @@ -110,12 +108,12 @@ class="btn-primary btn-large"
it('should handle edge case with quotes and special characters', function () {
// Test edge case that might trigger recursion issues
$template = '<x-button class="btn \'quoted\' &amp; escaped" data-test=\'{"key": "value"}\'>Complex</x-button>';

// This should complete without hanging or crashing
$rendered = \Illuminate\Support\Facades\Blade::render($template);

expect($rendered)->toContain('<button');
expect($rendered)->toContain('Complex');
expect($rendered)->not->toContain('<x-button');
});
});
});