/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/View/Blade/BladePropsTest.php
63 строки
2 KB
Lucas Michot
Flip misordered assertions arguments (#59691)
14 апр 2026, 20:44
Не верифицирован
14 апр 2026, 20:44
dcebf75
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\View\Blade; use Illuminate\View\ComponentAttributeBag; class BladePropsTest extends AbstractBladeTestCase { public function testPropsAreCompiled() { $this->assertSame('<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag; $__newAttributes = []; $__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([\'one\' => true, \'two\' => \'string\'])); foreach ($attributes->all() as $__key => $__value) { if (in_array($__key, $__propNames)) { $$__key = $$__key ?? $__value; } else { $__newAttributes[$__key] = $__value; } } $attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes); unset($__propNames); unset($__newAttributes); foreach (array_filter(([\'one\' => true, \'two\' => \'string\']), \'is_string\', ARRAY_FILTER_USE_KEY) as $__key => $__value) { $$__key = $$__key ?? $__value; } $__defined_vars = get_defined_vars(); foreach ($attributes->all() as $__key => $__value) { if (array_key_exists($__key, $__defined_vars)) unset($$__key); } unset($__defined_vars, $__key, $__value); ?>', $this->compiler->compileString('@props([\'one\' => true, \'two\' => \'string\'])')); } public function testPropsAreExtractedFromParentAttributesCorrectly() { $test1 = $test2 = $test4 = null; $attributes = new ComponentAttributeBag(['test1' => 'value1', 'test2' => 'value2', 'test3' => 'value3']); $template = $this->compiler->compileString('@props([\'test1\' => \'default\', \'test2\', \'test4\' => \'default\'])'); ob_start(); eval(" ?> $template <?php "); ob_get_clean(); $this->assertSame('value1', $test1); $this->assertSame('value2', $test2); $this->assertFalse(isset($test3)); $this->assertSame('default', $test4); $this->assertNull($attributes->get('test1')); $this->assertNull($attributes->get('test2')); $this->assertSame('value3', $attributes->get('test3')); } }