Add TestCase class in tests

This commit is contained in:
Dorian Neto 2017-09-19 19:09:29 -03:00
parent aa54e614ed
commit 19e0cd5b83
4 changed files with 56 additions and 29 deletions

View File

@ -10,7 +10,8 @@
],
"autoload": {
"psr-4": {
"LaravelProfane\\": "src/"
"LaravelProfane\\": "src/",
"LaravelProfaneTests\\": "tests/"
}
},
"minimum-stability": "stable",

View File

@ -1,22 +1,12 @@
<?php
namespace LaravelProfaneTests;
use LaravelProfaneTests\TestCase;
use LaravelProfane\ProfaneValidator;
use Illuminate\Support\Facades\Config;
use \Mockery as m;
class ProfaneValidatorTest extends PHPUnit_Framework_TestCase
class ProfaneValidatorTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->mockConfigs();
}
public function tearDown()
{
parent::tearDown();
m::close();
}
public function test_can_validate_a_word_with_numbers()
{
$attribute = 'username';
@ -148,17 +138,4 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase
$this->assertFalse($profane->validate($attribute, $text, $parameters));
}
private function mockConfigs()
{
Config::shouldReceive('get')
->once()
->with('app.locale')
->andReturn('en');
Config::shouldReceive('has')
->once()
->with('app.locale')
->andReturn(true);
}
}

View File

@ -1,8 +1,11 @@
<?php
namespace LaravelProfaneTests;
use LaravelProfaneTests\TestCase;
use LaravelProfane\Str;
class StrTest extends PHPUnit_Framework_TestCase
class StrTest extends TestCase
{
public function test_remove_accents_in_spanish_text()
{

46
tests/TestCase.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace LaravelProfaneTests;
use Illuminate\Support\Facades\Config;
use PHPUnit_Framework_TestCase;
use \Mockery;
class TestCase extends PHPUnit_Framework_TestCase
{
/**
* [setUp description]
*/
public function setUp()
{
parent::setUp();
$this->mockConfigs();
}
/**
* [tearDown description]
* @return [type] [description]
*/
public function tearDown()
{
parent::tearDown();
Mockery::close();
}
/**
* [mockConfigs description]
* @return void
*/
protected function mockConfigs()
{
Config::shouldReceive('get')
->once()
->with('app.locale')
->andReturn('en');
Config::shouldReceive('has')
->once()
->with('app.locale')
->andReturn(true);
}
}