Skip to content

Commit

Permalink
Unit test for RBValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
hakobyansen committed Jan 20, 2019
1 parent c1323b5 commit 2b3bb8a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/unit/HttpStatusCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PHPUnit\Framework\TestCase;
use RB\Core\HttpStatusCode;

class HttpStatusCodesTest extends TestCase
class HttpStatusCodeTest extends TestCase
{
public function testGetCodeWithMessage()
{
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/RBValidatorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Tests\Unit;

use Orchestra\Testbench\TestCase;
use RB\Core\RBValidator;

class RBValidatorTest extends TestCase
{
protected function setUp()
{
parent::setUp();
}

public function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);

$app['config']->set('response_builder.messages.failed_validation', 'Validation failed.');
}

public function testValidate()
{
$data = [
'name' => 'John',
'age' => 26,
'city' => 'New York'
];

$rules = [
'name' => 'string',
'age' => 'integer',
'city' => 'required'
];

$this->assertTrue( RBValidator::validate( $data, $rules ) );
}
}

0 comments on commit 2b3bb8a

Please sign in to comment.