-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce NullDriver From v4 (#323)
* Reintroduce NullDriver From v4 * Update composer.json --------- Co-authored-by: Keller Martin <kellerm@schwebdesign.com> Co-authored-by: Freek Van der Herten <freek@spatie.be>
- Loading branch information
1 parent
da64b53
commit 0507ee5
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Spatie\Newsletter\Drivers; | ||
|
||
use Illuminate\Support\Facades\Log; | ||
|
||
class NullDriver | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $logCalls; | ||
|
||
public function __construct(bool $logCalls = false) | ||
{ | ||
$this->logCalls = $logCalls; | ||
} | ||
|
||
public function __call($name, $arguments) | ||
{ | ||
if ($this->logCalls) { | ||
Log::debug('Called Spatie Newsletter facade method: '.$name.' with:', $arguments); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Spatie\Newsletter\Drivers\NullDriver; | ||
|
||
it('uses the NullDriver with null config value', function () { | ||
config()->set('newsletter.driver', null); | ||
|
||
expect(app('newsletter'))->toBeInstanceOf(NullDriver::class); | ||
}); | ||
|
||
it('uses the NullDriver with log config value', function () { | ||
config()->set('newsletter.driver', 'log'); | ||
|
||
expect(app('newsletter'))->toBeInstanceOf(NullDriver::class); | ||
}); | ||
|
||
it('uses the NullDriver with NullDriver::class config', function () { | ||
config()->set('newsletter.driver', NullDriver::class); | ||
|
||
expect(app('newsletter'))->toBeInstanceOf(NullDriver::class); | ||
}); | ||
|
||
it('accepts calls to the NullDriver', function () { | ||
config()->set('newsletter.driver', null); | ||
|
||
expect(app('newsletter')->subscribe('example@example.org'))->toBeNull(); | ||
}); |