Skip to content

Commit

Permalink
Replace commas with dots ...
Browse files Browse the repository at this point in the history
A port of a fix that was added in v2.

Ref statamic/v2-hub#2428
  • Loading branch information
jasonvarga committed Nov 20, 2020
1 parent dea77e8 commit 927890a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Forms/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function id($id = null)
{
return $this->fluentlyGetOrSet('id')
->getter(function ($id) {
return $this->id = $id ?: microtime(true);
return $this->id = $id ?: str_replace(',', '.', microtime(true));
})
->args(func_get_args());
}
Expand Down
12 changes: 12 additions & 0 deletions tests/Forms/SubmissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,16 @@ public function the_id_is_generated_the_first_time_but_can_be_overridden()

$this->assertEquals('123', $submission->id());
}

/** @test */
public function generated_ids_dont_have_commas()
{
// this test becomes unnecessary if we ever move away from using microtime for ids.

setlocale(LC_ALL, 'de_DE');

$submission = Form::make('test')->makeSubmission();

$this->assertStringNotContainsString(',', $submission->id());
}
}

0 comments on commit 927890a

Please sign in to comment.