From 19e0cd5b835e3cc98fcfa3524ad8b0de181fc9d0 Mon Sep 17 00:00:00 2001 From: Dorian Neto Date: Tue, 19 Sep 2017 19:09:29 -0300 Subject: [PATCH] Add TestCase class in tests --- composer.json | 3 ++- tests/ProfaneValidatorTest.php | 31 +++-------------------- tests/StrTest.php | 5 +++- tests/TestCase.php | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 29 deletions(-) create mode 100644 tests/TestCase.php diff --git a/composer.json b/composer.json index b9b4643..9b4987e 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ ], "autoload": { "psr-4": { - "LaravelProfane\\": "src/" + "LaravelProfane\\": "src/", + "LaravelProfaneTests\\": "tests/" } }, "minimum-stability": "stable", diff --git a/tests/ProfaneValidatorTest.php b/tests/ProfaneValidatorTest.php index 83ea6d5..9654201 100644 --- a/tests/ProfaneValidatorTest.php +++ b/tests/ProfaneValidatorTest.php @@ -1,22 +1,12 @@ 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); - } } diff --git a/tests/StrTest.php b/tests/StrTest.php index 3e674da..f80a64a 100644 --- a/tests/StrTest.php +++ b/tests/StrTest.php @@ -1,8 +1,11 @@ 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); + } +}