Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Dec 20, 2024
1 parent a1a28fb commit 5b0124c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Tags/Form/FormCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Storage;
use Illuminate\Testing\Assert as PHPUnit;
use Illuminate\Testing\Constraints\SeeInOrder;
use Illuminate\Validation\ValidationException;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\AssetContainer;
Expand Down Expand Up @@ -75,6 +77,26 @@ public function it_dynamically_renders_fields_array()
$this->assertEquals(['Full Name', 'Email Address', 'Message'], $fieldOrder[1]);
}

#[Test]
public function it_dynamically_renders_fields_view_using_single_tag()
{
$output = $this->normalizeHtml($this->tag(<<<'EOT'
{{ form:contact }}
{{ fields }}
{{ /form:contact }}
EOT
));

PHPUnit::assertThat([
'<label for="contact-form-name-field">Full Name </label>',
'<input id="contact-form-name-field" type="text" name="name" value="">',
'<label for="contact-form-email-field">Email Address <sup aria-label="Required">*</sup></label>',
'<input id="contact-form-email-field" type="email" name="email" value="" required>',
'<label for="contact-form-message-field">Message<sup aria-label="Required">*</sup></label>',
'<textarea id="contact-form-message-field" name="message" rows="5" required></textarea>',
], new SeeInOrder($output));
}

#[Test]
public function it_dynamically_renders_with_form_handle()
{
Expand Down

0 comments on commit 5b0124c

Please sign in to comment.