Skip to content

Commit a7d1f68

Browse files
author
denjas
committed
test: created own test for property hooks with default values
1 parent 0d651a0 commit a7d1f68

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Symfony/Component/VarExporter/Tests/Fixtures/LazyProxy/Hooked.php

-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@ class Hooked
2222
get { return $this->backed ??= 234; }
2323
set { $this->backed = $value; }
2424
}
25-
26-
public int $backedWithDefault = 321 {
27-
get => $this->backedWithDefault;
28-
set => $this->backedWithDefault = $value;
29-
}
3025
}

src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Component\VarExporter\Tests\Fixtures\LazyGhost\TestClass;
2828
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\AsymmetricVisibility;
2929
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\Hooked;
30+
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\HookedWithDefaultValue;
3031
use Symfony\Component\VarExporter\Tests\Fixtures\SimpleObject;
3132

3233
class LazyGhostTraitTest extends TestCase
@@ -503,9 +504,20 @@ public function testPropertyHooks()
503504
$object->backed = 345;
504505
$this->assertTrue($initialized);
505506
$this->assertSame(345, $object->backed);
507+
}
506508

509+
public function testPropertyHooksWithDefaultValue()
510+
{
507511
$initialized = false;
508-
$object = $this->createLazyGhost(Hooked::class, function ($instance) use (&$initialized) {
512+
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
513+
$initialized = true;
514+
});
515+
516+
$this->assertSame(321, $object->backedWithDefault);
517+
$this->assertTrue($initialized);
518+
519+
$initialized = false;
520+
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
509521
$initialized = true;
510522
});
511523
$object->backedWithDefault = 654;

0 commit comments

Comments
 (0)