diff --git a/src/Stache/Stores/FormSubmissionsStore.php b/src/Stache/Stores/FormSubmissionsStore.php index 9501732a79f..4660f869168 100644 --- a/src/Stache/Stores/FormSubmissionsStore.php +++ b/src/Stache/Stores/FormSubmissionsStore.php @@ -22,7 +22,7 @@ class FormSubmissionsStore extends ChildStore public function getItemKey($item) { - return $item->id(); + return $item->form()->handle().'::'.$item->id(); } public function getItemFilter(SplFileInfo $file) diff --git a/tests/Stache/Stores/FormSubmissionStoreTest.php b/tests/Stache/Stores/FormSubmissionStoreTest.php index 669e4d3175c..2dd3093e4f4 100644 --- a/tests/Stache/Stores/FormSubmissionStoreTest.php +++ b/tests/Stache/Stores/FormSubmissionStoreTest.php @@ -29,6 +29,24 @@ public function setUp(): void Stache::store('form-submissions')->directory($this->directory); } + #[Test] + public function it_has_handle_in_key() + { + Facades\Form::make('contact_form')->save(); + Facades\Form::make('other_form')->save(); + $contactSubmission = $this->parent->store('contact_form')->makeItemFromFile( + Path::tidy($this->directory).'/contact_form/1631083591.2832.yaml', + "name: John Smith\nmessage: Hello" + ); + $otherSubmission = $this->parent->store('other_form')->makeItemFromFile( + Path::tidy($this->directory).'/other_form/1631083591.2832.yaml', + "name: John Smith\nmessage: Hello" + ); + + $this->assertEquals('contact_form::1631083591.2832', $this->parent->store('contact_form')->getItemKey($contactSubmission)); + $this->assertEquals('other_form::1631083591.2832', $this->parent->store('other_form')->getItemKey($otherSubmission)); + } + #[Test] public function it_makes_entry_instances_from_files() { @@ -72,6 +90,6 @@ public function it_saves_to_disk() @unlink($path); $this->assertFileDoesNotExist($path); - $this->assertEquals($path, $this->parent->store('test_form')->paths()->get($submission->id())); + $this->assertEquals($path, $this->parent->store('test_form')->paths()->get('test_form::'.$submission->id())); } }