Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Stache/Stores/FormSubmissionsStore.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
20 changes: 19 additions & 1 deletion tests/Stache/Stores/FormSubmissionStoreTest.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()
{
Expand DownExpand Up@@ -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()));
}
}
Loading