From 5f9919c0785a0112bc670dc6c09595019b167215 Mon Sep 17 00:00:00 2001 From: heynazmul Date: Tue, 4 Feb 2025 20:07:39 +0600 Subject: [PATCH] Fix x-transition attribute handling in Blade components - Added test case for x-transition attribute - Ensures x-transition doesn't get value='x-transition' Fixes #54015 --- .../Blade/BladeComponentTagCompilerTest.php | 19 +++++++++++++++++-- .../Components/TestTransitionComponent.php | 13 +++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/View/Blade/Components/TestTransitionComponent.php diff --git a/tests/View/Blade/BladeComponentTagCompilerTest.php b/tests/View/Blade/BladeComponentTagCompilerTest.php index 5ebfbb104648..3d00ac33ff99 100644 --- a/tests/View/Blade/BladeComponentTagCompilerTest.php +++ b/tests/View/Blade/BladeComponentTagCompilerTest.php @@ -378,6 +378,7 @@ public function testClassNamesCanBeGuessed() { $container = new Container; $container->instance(Application::class, $app = m::mock(Application::class)); + $container->instance(Factory::class, $factory = m::mock(Factory::class)); $app->shouldReceive('getNamespace')->once()->andReturn('App\\'); Container::setInstance($container); @@ -392,6 +393,7 @@ public function testClassNamesCanBeGuessedWithNamespaces() { $container = new Container; $container->instance(Application::class, $app = m::mock(Application::class)); + $container->instance(Factory::class, $factory = m::mock(Factory::class)); $app->shouldReceive('getNamespace')->once()->andReturn('App\\'); Container::setInstance($container); @@ -570,8 +572,8 @@ public function testPackagesClasslessComponents() $container = new Container; $container->instance(Application::class, $app = m::mock(Application::class)); $container->instance(Factory::class, $factory = m::mock(Factory::class)); - $app->shouldReceive('getNamespace')->andReturn('App\\'); - $factory->shouldReceive('exists')->andReturn(true); + $app->shouldReceive('getNamespace')->once()->andReturn('App\\'); + $factory->shouldReceive('exists')->once()->andReturn(true); Container::setInstance($container); $result = $this->compiler()->compileTags(''); @@ -915,6 +917,19 @@ public function testOriginalAttributesAreRestoredAfterRenderingChildComponentWit $this->assertSame($attributes->get('other'), 'ok'); } + public function testTransitionAttributeIsHandledCorrectly() + { + $this->mockViewFactory(); + + $result = $this->compiler(['test' => TestTransitionComponent::class]) + ->compileTags('content'); + + $this->assertStringContainsString( + "'x-transition' => true", + $result + ); + } + protected function mockViewFactory($existsSucceeds = true) { $container = new Container; diff --git a/tests/View/Blade/Components/TestTransitionComponent.php b/tests/View/Blade/Components/TestTransitionComponent.php new file mode 100644 index 000000000000..e1d3c657617c --- /dev/null +++ b/tests/View/Blade/Components/TestTransitionComponent.php @@ -0,0 +1,13 @@ +{{ $slot }}'; + } +}