Skip to content

Commit

Permalink
Updates validator tests for decimal validation
Browse files Browse the repository at this point in the history
  • Loading branch information
artstorm committed Aug 27, 2015
1 parent 0df802e commit 19818f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/resources/lang/en/validation.php
Expand Up @@ -74,7 +74,7 @@
"url" => "The :attribute format is invalid.",
"timezone" => "The :attribute must be a valid zone.",
'uuid' => "The :attribute must be an UUID string.",
'float' => "The :attribute must be a float.",
'decimal' => "The :attribute must be a decimal.",
'not_found' => "The selected :attribute is invalid.",
'country' => 'The :attribute must be a valid country code.',
'alpha_dash_space' => 'The :attribute may only contain letters, numbers, dashes and spaces.',
Expand Down
20 changes: 11 additions & 9 deletions api/tests/ValidatorTest.php
Expand Up @@ -14,25 +14,27 @@ public function setUp()

public function testSpiraValidator()
{
$data = ['float' => 'foo'];
$validation = $this->validator->make($data, ['float'=>'float']);
$data = ['decimal' => 'foo'];
$validation = $this->validator->make($data, ['decimal'=>'decimal']);
$this->assertInstanceOf(SpiraValidator::class, $validation);
}

public function testPassingFloatValidation()
public function testPassingDecimalValidation()
{
$data = ['float' => 12.042];
$data = ['decimal' => 12.042];
$this->assertTrue($this->validator->make($data, ['decimal'=>'decimal'])->passes());

$this->assertTrue($this->validator->make($data, ['float'=>'float'])->passes());
$data = ['decimal' => 12];
$this->assertTrue($this->validator->make($data, ['decimal'=>'decimal'])->passes());
}

public function testFailingFloatValidation()
public function testFailingDecimalValidation()
{
$data = ['float' => 'foo'];
$validation = $this->validator->make($data, ['float'=>'float']);
$data = ['decimal' => 'foo'];
$validation = $this->validator->make($data, ['decimal'=>'decimal']);
$this->assertFalse($validation->passes());

$this->assertStringEndsWith('must be a float.', $validation->messages()->get('float')[0]);
$this->assertStringEndsWith('must be a decimal.', $validation->messages()->get('decimal')[0]);
}

public function testPassingUuidValidation()
Expand Down

1 comment on commit 19818f3

@zakhenry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for doing this @artstorm

Please sign in to comment.