From 0842c47e230f349822c54350e462f9dc2285248e Mon Sep 17 00:00:00 2001 From: lukeraymonddowning Date: Wed, 10 Apr 2024 09:18:52 +0100 Subject: [PATCH] Feedback changes --- src/FormBuilder.php | 12 +----------- tests/Feature/FormTest.php | 30 ------------------------------ 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 0b0cbac1..d5387903 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -27,17 +27,7 @@ class FormBuilder */ public function add(Closure $step, ?string $name = null, bool $ignoreWhenReverting = false): self { - return $this->when(true, $step, $name, $ignoreWhenReverting); - } - - /** - * Add a step if the given condition evaluates to true. - * - * @param bool|(Closure(array): bool) $condition - */ - public function when(bool|Closure $condition, Closure $step, ?string $name = null, bool $ignoreWhenReverting = false): self - { - $this->steps[] = new FormStep($step, $condition, $name, $ignoreWhenReverting); + $this->steps[] = new FormStep($step, true, $name, $ignoreWhenReverting); return $this; } diff --git a/tests/Feature/FormTest.php b/tests/Feature/FormTest.php index 35c7a11c..d43eda6c 100644 --- a/tests/Feature/FormTest.php +++ b/tests/Feature/FormTest.php @@ -110,36 +110,6 @@ expect($responses)->toBe([true]); }); -it('can conditionally run a step', function () { - Prompt::fake([ - Key::ENTER, - Key::DOWN, Key::ENTER, - ]); - - form() - ->when(true, fn () => confirm('Are you sure?'), name: 'confirm') - ->when( - fn (array $responses) => $responses['confirm'], - fn (array $responses) => outro('This should display') - ) - ->submit(); - - form() - ->when(false, fn () => outro('This should not display')) - ->submit(); - - form() - ->confirm('Are you sure?', name: 'confirm') - ->when( - fn (array $responses) => $responses['confirm'], - fn () => outro('This should not display') - ) - ->submit(); - - Prompt::assertOutputContains('This should display'); - Prompt::assertOutputDoesntContain('This should not display'); -}); - it('skips steps over steps that have no user input when reverting', function () { Prompt::fake([ '3', Key::ENTER,