-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
223 additions
and
77 deletions.
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
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,36 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Config; | ||
use Lunarstorm\LaravelDDD\Support\DomainAutoloader; | ||
use Symfony\Component\Console\Exception\CommandNotFoundException; | ||
|
||
beforeEach(function () { | ||
Config::set('ddd.domain_path', 'src/Domain'); | ||
Config::set('ddd.domain_namespace', 'Domain'); | ||
|
||
$this->setupTestApplication(); | ||
|
||
DomainAutoloader::clearCache(); | ||
}); | ||
|
||
describe('without autoload', function () { | ||
it('does not register the command', function () { | ||
expect(class_exists('Domain\Invoicing\Commands\InvoiceDeliver'))->toBeTrue(); | ||
expect(fn () => Artisan::call('invoice:deliver'))->toThrow(CommandNotFoundException::class); | ||
}); | ||
}); | ||
|
||
describe('with autoload', function () { | ||
beforeEach(function () { | ||
$this->afterApplicationCreated(function () { | ||
(new DomainAutoloader())->autoload(); | ||
}); | ||
}); | ||
|
||
it('registers the command', function () { | ||
expect(class_exists('Domain\Invoicing\Commands\InvoiceDeliver'))->toBeTrue(); | ||
Artisan::call('invoice:deliver'); | ||
expect(Artisan::output())->toContain('Invoice delivered!'); | ||
}); | ||
}); |
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,32 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Config; | ||
use Lunarstorm\LaravelDDD\Support\DomainAutoloader; | ||
|
||
beforeEach(function () { | ||
Config::set('ddd.domain_path', 'src/Domain'); | ||
Config::set('ddd.domain_namespace', 'Domain'); | ||
|
||
$this->setupTestApplication(); | ||
|
||
DomainAutoloader::clearCache(); | ||
}); | ||
|
||
describe('without autoload', function () { | ||
it('does not register the provider', function () { | ||
expect(fn () => app('invoicing'))->toThrow(Exception::class); | ||
}); | ||
}); | ||
|
||
describe('with autoload', function () { | ||
beforeEach(function () { | ||
$this->afterApplicationCreated(function () { | ||
(new DomainAutoloader())->autoload(); | ||
}); | ||
}); | ||
|
||
it('registers the provider', function () { | ||
expect(app('invoicing'))->toEqual('invoicing-singleton'); | ||
$this->artisan('invoice:deliver')->expectsOutputToContain('invoice-secret'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
24 changes: 24 additions & 0 deletions
24
tests/resources/Domain/Invoicing/Commands/InvoiceDeliver.php
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,24 @@ | ||
<?php | ||
|
||
namespace Domain\Invoicing\Commands; | ||
|
||
use Domain\Invoicing\Models\Invoice; | ||
use Illuminate\Console\Command; | ||
|
||
class InvoiceDeliver extends Command | ||
{ | ||
protected $signature = 'invoice:deliver'; | ||
|
||
protected $description = 'Deliver invoice.'; | ||
|
||
public function handle() | ||
{ | ||
$this->info('Invoice delivered!'); | ||
|
||
if ($secret = Invoice::getSecret()) { | ||
$this->line($secret); | ||
|
||
return; | ||
} | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
tests/resources/Domain/Invoicing/Providers/InvoiceServiceProvider.php
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 | ||
|
||
namespace Domain\Invoicing\Providers; | ||
|
||
use Domain\Invoicing\Models\Invoice; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class InvoiceServiceProvider extends ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$this->app->singleton('invoicing', function (Application $app) { | ||
return 'invoicing-singleton'; | ||
}); | ||
} | ||
|
||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
Invoice::setSecret('invoice-secret'); | ||
} | ||
} |
Oops, something went wrong.