Skip to content

Fix config closure #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">

<testsuites>
<testsuite name="Orchestra\Testbench Test Suite">
Expand Down
8 changes: 1 addition & 7 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
58 changes: 58 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Tests;

use Stackkit\LaravelDatabaseEmails\Config;

class ConfigTest extends TestCase
{
/** @test */
public function test_max_attempt_count()
{
$this->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('[email protected]', Config::testEmailAddress());

$this->app['config']->set('laravel-database-emails.testing.email', '[email protected]');

$this->assertEquals('[email protected]', 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());
}
}
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]');

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