Skip to content

Commit

Permalink
Adjust test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Dec 20, 2024
1 parent 13f953e commit a1a28fb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/Tags/Form/FormCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\AssetContainer;
use Statamic\Facades\Form;
use Statamic\Forms\FieldsVariable;
use Statamic\Statamic;

class FormCreateTest extends FormTestCase
Expand Down Expand Up @@ -504,20 +505,20 @@ public function it_dynamically_renders_sections_array()
$output = $this->normalizeHtml($this->tag(<<<'EOT'
{{ form:survey }}
{{ sections }}
<div class="section">{{ if display}}{{ display }} - {{ /if }}{{ if instructions }}{{ instructions }} - {{ /if }}{{ fields | pluck('handle') | join(',') }}</div>
<div class="section">{{ if display}}{{ display }} - {{ /if }}{{ if instructions }}{{ instructions }} - {{ /if }}{{ fields }}[{{ handle }}]{{ /fields }}</div>
{{ /sections }}
<div class="fields">{{ fields | pluck('handle') | join(',') }}</div>
<div class="fields">{{ fields }}[{{ handle }}]{{ /fields }}</div>
{{ /form:survey }}
EOT
));

$this->assertStringContainsString('<div class="section">One - One Instructions - alpha,bravo</div>', $output);
$this->assertStringContainsString('<div class="section">Two - Two Instructions - charlie,delta</div>', $output);
$this->assertStringContainsString('<div class="section">echo,fox</div>', $output);
$this->assertStringContainsString('<div class="section">One - One Instructions - [alpha][bravo]</div>', $output);
$this->assertStringContainsString('<div class="section">Two - Two Instructions - [charlie][delta]</div>', $output);
$this->assertStringContainsString('<div class="section">[echo][fox]</div>', $output);

// Even though the fields are all nested within sections,
// we should still be able to get them via `{{ fields }}` array at top level...
$this->assertStringContainsString('<div class="fields">alpha,bravo,charlie,delta,echo,fox</div>', $output);
$this->assertStringContainsString('<div class="fields">[alpha][bravo][charlie][delta][echo][fox]</div>', $output);
}

#[Test]
Expand Down Expand Up @@ -835,7 +836,7 @@ public function it_fetches_form_data()
$this->assertArrayHasKey('_token', $form['params']);

$this->assertIsArray($form['errors']);
$this->assertIsArray($form['fields']);
$this->assertInstanceOf(FieldsVariable::class, $form['fields']);

$this->assertEquals($form['honeypot'], 'winnie');
$this->assertEquals($form['js_driver'], 'alpine');
Expand Down

0 comments on commit a1a28fb

Please sign in to comment.