Skip to content

Commit

Permalink
Test tags get models
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Dec 5, 2024
1 parent ee0c947 commit 752f419
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Antlers/Runtime/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Casts\Attribute;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Tags\Tags;
use Tests\Antlers\ParserTestCase;

class ModelTest extends ParserTestCase
Expand Down Expand Up @@ -35,6 +36,24 @@ public static function modelProvider()
'old accessor' => ['delta_echo', 'foxtrot'],
];
}

#[Test]
public function variable_references_receive_models()
{
(new class extends Tags
{
public static $handle = 'tag';

public function index()
{
$src = $this->params->get('value');

return $src instanceof FakeModel ? 'Yes' : 'No';
}
})::register();

$this->assertSame('Yes', $this->renderString('{{ %tag :value="model" }}', ['model' => new FakeModel]));
}
}

class FakeModel extends \Illuminate\Database\Eloquent\Model
Expand Down

0 comments on commit 752f419

Please sign in to comment.