From c9640139970f34412686737e6464446996a4b135 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Tue, 12 Jul 2022 14:13:21 -0400 Subject: [PATCH 1/2] restore previous default value for BlockBuilder placeholder/get methods --- src/Html/BlockBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Html/BlockBuilder.php b/src/Html/BlockBuilder.php index 575071ea7..9c2d03192 100644 --- a/src/Html/BlockBuilder.php +++ b/src/Html/BlockBuilder.php @@ -103,7 +103,7 @@ public function append(string $name, string $content): void * * If the block does not exist, then the `$default` content will be returned instead. */ - public function placeholder(string $name, string $default = ''): string + public function placeholder(string $name, string $default = null): ?string { $result = $this->get($name, $default); unset($this->blocks[$name]); @@ -120,7 +120,7 @@ public function placeholder(string $name, string $default = ''): string * * If the block does not exist, then the `$default` content will be returned instead. */ - public function get(string $name, string $default = ''): string + public function get(string $name, string $default = null): ?string { if (!isset($this->blocks[$name])) { return $default; From 84edabb35adf1ff96d3698552586bcc48768ef68 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Tue, 12 Jul 2022 14:24:25 -0400 Subject: [PATCH 2/2] add unit test for Block::get --- tests/Html/BlockBuilderTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Html/BlockBuilderTest.php b/tests/Html/BlockBuilderTest.php index eede6e329..bcc0b28d4 100644 --- a/tests/Html/BlockBuilderTest.php +++ b/tests/Html/BlockBuilderTest.php @@ -229,4 +229,13 @@ public function testContainBetweenBlocks() ); $this->assertEquals('In between', $content); } + + public function testGetBlock() + { + $result = $this->Block->get('non-existent-block'); + $this->assertNull($result); + + $result = $this->Block->get('non-existent-block', 'default value'); + $this->assertEquals('default value', $result); + } }