From d14c52b04c08223563afcd4ddeb873770e83283a Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 6 Oct 2021 18:11:51 +0800 Subject: [PATCH] add currentStepIndex to $wizard in blade view --- src/AbstractWizard.php | 1 + tests/WizardTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/AbstractWizard.php b/src/AbstractWizard.php index dcea530..6e3732d 100644 --- a/src/AbstractWizard.php +++ b/src/AbstractWizard.php @@ -266,6 +266,7 @@ public function summary(): array return [ 'id' => $this->id, + 'currentStepIndex' => $this->currentStep, 'slug' => static::$slug, 'title' => $this->title(), 'steps' => collect($this->steps)->map(fn (WizardStep $step) => [ diff --git a/tests/WizardTest.php b/tests/WizardTest.php index 3f11547..f0ab13e 100644 --- a/tests/WizardTest.php +++ b/tests/WizardTest.php @@ -241,6 +241,17 @@ public function it_returns_the_wizards_slug_in_the_summary(): void self::assertEquals($wizard::$slug, $summary['slug']); } + /** @test */ + public function it_returns_the_wizards_current_step_index_in_the_summary(): void + { + $wizard = $this->createWizard(TestWizard::class); + $wizard->show(new Request(), '1', 'step-with-view-data'); + + $summary = $wizard->summary(); + + self::assertEquals(1, $summary['currentStepIndex']); + } + /** @test */ public function it_returns_the_slug_of_each_step_in_the_summary(): void {