/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php
61 строка
1 KB
Jamie York
[11.x] Allow `TestComponent` to be macroable (#54359)
26 янв 2025, 22:09
Не верифицирован
26 янв 2025, 22:09
4673387
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Foundation\Testing\Concerns; use Illuminate\Foundation\Testing\Concerns\InteractsWithViews; use Illuminate\Testing\TestComponent; use Illuminate\View\Component; use Orchestra\Testbench\TestCase; class InteractsWithViewsTest extends TestCase { use InteractsWithViews; public function testBladeCorrectlyRendersString() { $string = (string) $this->blade('@if(true)test @endif'); $this->assertSame('test ', $string); } public function testComponentCanAccessPublicProperties() { $exampleComponent = new class extends Component { public $foo = 'bar'; public function speak() { return 'hello'; } public function render() { return 'rendered content'; } }; $component = $this->component(get_class($exampleComponent)); $this->assertSame('bar', $component->foo); $this->assertSame('hello', $component->speak()); $component->assertSee('content'); } public function testComponentMacroable() { TestComponent::macro('foo', fn (): string => 'bar'); $exampleComponent = new class extends Component { public function render() { return 'rendered content'; } }; $component = $this->component(get_class($exampleComponent)); $this->assertSame('bar', $component->foo()); } }