From 86755a7aa8d7fa26bc05067478a9d7b6560bfb2f Mon Sep 17 00:00:00 2001 From: John Koster Date: Sun, 5 May 2024 10:13:33 -0500 Subject: [PATCH] Ensures values are resolved when checking Antlers parsing settings --- src/Fields/Value.php | 4 ++++ tests/Antlers/Runtime/RuntimeValuesTest.php | 22 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Fields/Value.php b/src/Fields/Value.php index 6dd929dfde..a656540612 100644 --- a/src/Fields/Value.php +++ b/src/Fields/Value.php @@ -116,6 +116,8 @@ public function getIterator() public function shouldParseAntlers() { + $this->resolve(); + return $this->fieldtype && $this->fieldtype->config('antlers'); } @@ -147,6 +149,8 @@ public function antlersValue(Parser $parser, $variables) public function field() { + $this->resolve(); + return $this->fieldtype->field(); } diff --git a/tests/Antlers/Runtime/RuntimeValuesTest.php b/tests/Antlers/Runtime/RuntimeValuesTest.php index d8c627393a..68130ae56b 100644 --- a/tests/Antlers/Runtime/RuntimeValuesTest.php +++ b/tests/Antlers/Runtime/RuntimeValuesTest.php @@ -2,9 +2,12 @@ namespace Tests\Antlers\Runtime; +use Facades\Statamic\Fields\BlueprintRepository; use Facades\Tests\Factories\EntryFactory; use Statamic\Entries\Entry; +use Statamic\Facades; use Statamic\Facades\Collection; +use Statamic\Facades\GlobalSet; use Statamic\Tags\Tags; use Statamic\View\Antlers\Language\Utilities\StringUtilities; use Tests\Antlers\ParserTestCase; @@ -63,4 +66,23 @@ public function mePlease() $this->assertSame($expected, $content); } + + public function test_fieldtype_information_is_resolved_when_augmenting() + { + // https://github.com/statamic/cms/issues/10001 + + $blueprint = Facades\Blueprint::makeFromFields([ + 'the_text' => ['type' => 'text', 'antlers' => true], + ]); + + BlueprintRepository::shouldReceive('find')->with('globals.the_global')->andReturn($blueprint); + + $global = GlobalSet::make('the_global'); + $variables = $global->makeLocalization('en'); + + $variables->set('the_text', 'The Value'); + $theText = $variables->toDeferredAugmentedArray()['the_text']; + + $this->assertTrue($theText->shouldParseAntlers()); + } }