Skip to content

Commit 2c8f2e9

Browse files
Merge pull request #19 from stackkit/development
Fix config closure
2 parents d670ad6 + df1dda2 commit 2c8f2e9

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

phpunit.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false">
10+
stopOnFailure="false">
1211

1312
<testsuites>
1413
<testsuite name="Orchestra\Testbench Test Suite">

src/Config.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ public static function encryptEmails()
3131
*/
3232
public static function testing()
3333
{
34-
$testing = config('laravel-database-emails.testing.enabled', function () {
35-
return function () {
36-
return false;
37-
};
38-
});
39-
40-
return $testing();
34+
return (bool) config('laravel-database-emails.testing.enabled', false);
4135
}
4236

4337
/**

tests/ConfigTest.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
use Stackkit\LaravelDatabaseEmails\Config;
6+
7+
class ConfigTest extends TestCase
8+
{
9+
/** @test */
10+
public function test_max_attempt_count()
11+
{
12+
$this->assertEquals(3, Config::maxAttemptCount());
13+
14+
$this->app['config']->set('laravel-database-emails.attempts', 5);
15+
16+
$this->assertEquals(5, Config::maxAttemptCount());
17+
}
18+
19+
/** @test */
20+
public function test_encrypt_emails()
21+
{
22+
$this->assertFalse(Config::encryptEmails());
23+
24+
$this->app['config']->set('laravel-database-emails.encrypt', true);
25+
26+
$this->assertTrue(Config::encryptEmails());
27+
}
28+
29+
/** @test */
30+
public function test_testing()
31+
{
32+
$this->assertFalse(Config::testing());
33+
34+
$this->app['config']->set('laravel-database-emails.testing.enabled', true);
35+
36+
$this->assertTrue(Config::testing());
37+
}
38+
39+
/** @test */
40+
public function test_test_email_address()
41+
{
42+
$this->assertEquals('[email protected]', Config::testEmailAddress());
43+
44+
$this->app['config']->set('laravel-database-emails.testing.email', '[email protected]');
45+
46+
$this->assertEquals('[email protected]', Config::testEmailAddress());
47+
}
48+
49+
/** @test */
50+
public function test_cronjob_email_limit()
51+
{
52+
$this->assertEquals(20, Config::cronjobEmailLimit());
53+
54+
$this->app['config']->set('laravel-database-emails.limit', 15);
55+
56+
$this->assertEquals(15, Config::cronjobEmailLimit());
57+
}
58+
}

tests/TestCase.php

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ protected function getPackageProviders($app)
7979
protected function getEnvironmentSetUp($app)
8080
{
8181
$app['config']->set('laravel-database-emails.attempts', 3);
82+
$app['config']->set('laravel-database-emails.testing.enabled', false);
83+
$app['config']->set('laravel-database-emails.testing.email', '[email protected]');
8284

8385
$app['config']->set('database.default', 'testbench');
8486
$app['config']->set('database.connections.testbench', [

0 commit comments

Comments
 (0)