From 80bf05c1b4dba6cc532d6bd4429232df2888adb0 Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Tue, 1 Jan 2019 13:47:43 +0100 Subject: [PATCH 1/3] Fix config closure and added tests --- src/Config.php | 8 +----- tests/ConfigTest.php | 59 ++++++++++++++++++++++++++++++++++++++++++++ tests/TestCase.php | 2 ++ 3 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 tests/ConfigTest.php diff --git a/src/Config.php b/src/Config.php index 8e81d61..a52c6a4 100644 --- a/src/Config.php +++ b/src/Config.php @@ -31,13 +31,7 @@ public static function encryptEmails() */ public static function testing() { - $testing = config('laravel-database-emails.testing.enabled', function () { - return function () { - return false; - }; - }); - - return $testing(); + return (boolean) config('laravel-database-emails.testing.enabled', false); } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..ed8bac8 --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,59 @@ +assertEquals(3, Config::maxAttemptCount()); + + $this->app['config']->set('laravel-database-emails.attempts', 5); + + $this->assertEquals(5, Config::maxAttemptCount()); + } + + /** @test */ + public function test_encrypt_emails() + { + $this->assertFalse(Config::encryptEmails()); + + $this->app['config']->set('laravel-database-emails.encrypt', true); + + $this->assertTrue(Config::encryptEmails()); + } + + /** @test */ + public function test_testing() + { + $this->assertFalse(Config::testing()); + + $this->app['config']->set('laravel-database-emails.testing.enabled', true); + + $this->assertTrue(Config::testing()); + } + + /** @test */ + public function test_test_email_address() + { + $this->assertEquals('test@email.com', Config::testEmailAddress()); + + $this->app['config']->set('laravel-database-emails.testing.email', 'test+update@email.com'); + + $this->assertEquals('test+update@email.com', Config::testEmailAddress()); + } + + /** @test */ + public function test_cronjob_email_limit() + { + $this->assertEquals(20, Config::cronjobEmailLimit()); + + $this->app['config']->set('laravel-database-emails.limit', 15); + + $this->assertEquals(15, Config::cronjobEmailLimit()); + } +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index 4fdc19a..1e7aa16 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -79,6 +79,8 @@ protected function getPackageProviders($app) protected function getEnvironmentSetUp($app) { $app['config']->set('laravel-database-emails.attempts', 3); + $app['config']->set('laravel-database-emails.testing.enabled', false); + $app['config']->set('laravel-database-emails.testing.email', 'test@email.com'); $app['config']->set('database.default', 'testbench'); $app['config']->set('database.connections.testbench', [ From e73ebaf521d3ebeef02efa6b534d561a9cd6d2dd Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Tue, 1 Jan 2019 13:48:11 +0100 Subject: [PATCH 2/3] Fix phpunit.xml --- phpunit.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 13c3008..24fb777 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,8 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" - syntaxCheck="false"> + stopOnFailure="false"> From 6f05d2178a3eb95d8bafaa38e085ba16c72e34ee Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Tue, 1 Jan 2019 12:54:59 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI --- src/Config.php | 2 +- tests/ConfigTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Config.php b/src/Config.php index a52c6a4..af8cd1e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -31,7 +31,7 @@ public static function encryptEmails() */ public static function testing() { - return (boolean) config('laravel-database-emails.testing.enabled', false); + return (bool) config('laravel-database-emails.testing.enabled', false); } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index ed8bac8..e6c376d 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -2,7 +2,6 @@ namespace Tests; - use Stackkit\LaravelDatabaseEmails\Config; class ConfigTest extends TestCase @@ -56,4 +55,4 @@ public function test_cronjob_email_limit() $this->assertEquals(15, Config::cronjobEmailLimit()); } -} \ No newline at end of file +}