Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Ensures values are resolved when checking Antlers parsing settings #10003

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Fields/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public function getIterator()

public function shouldParseAntlers()
{
$this->resolve();

return $this->fieldtype && $this->fieldtype->config('antlers');
}

Expand Down Expand Up @@ -147,6 +149,8 @@ public function antlersValue(Parser $parser, $variables)

public function field()
{
$this->resolve();

return $this->fieldtype->field();
}

Expand Down
22 changes: 22 additions & 0 deletions tests/Antlers/Runtime/RuntimeValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}