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"> diff --git a/src/Config.php b/src/Config.php index 8e81d61..af8cd1e 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 (bool) config('laravel-database-emails.testing.enabled', false); } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..e6c376d --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,58 @@ +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()); + } +} 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', [