Page MenuHomeDevCentral

D234.id551.diff
No OneTemporary

D234.id551.diff

diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -6,7 +6,7 @@
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
-use File;
+use Config;
class EventServiceProvider extends ServiceProvider {
@@ -14,12 +14,7 @@
* Registers all our listeners as subscriber classes
*/
private function subscribeListeners () {
- $namespace = Container::getInstance()->getNamespace() . 'Listeners\\';
- $files = File::allFiles(app_path('Listeners'));
- foreach ($files as $file) {
- $class = $namespace . $file->getBasename('.php');
- $this->subscribe[] = $class;
- }
+ $this->subscribe += Config::get('app.listeners');
}
/**
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -180,6 +180,23 @@
/*
|--------------------------------------------------------------------------
+ | Events listeners
+ |--------------------------------------------------------------------------
+ |
+ | The events listeners listed here will be automatically loaded on the
+ | request to your application.
+ |
+ */
+
+ 'listeners' => [
+ Nasqueron\Notifications\Listeners\AMQPEventListener::class,
+ Nasqueron\Notifications\Listeners\LastPayloadSaver::class,
+ Nasqueron\Notifications\Listeners\NotificationListener::class,
+ Nasqueron\Notifications\Listeners\PhabricatorListener::class,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
diff --git a/tests/Providers/EventServiceProviderTest.php b/tests/Providers/EventServiceProviderTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Providers/EventServiceProviderTest.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Providers;
+
+use Nasqueron\Notifications\Providers\EventServiceProvider;
+
+use Config;
+use File;
+
+class EventServiceProviderTest extends TestCase {
+
+ public function testType () {
+ $this->assertServiceInstanceOf(
+ 'Illuminate\Contracts\Events\Dispatcher',
+ 'events'
+ );
+ }
+
+ ///
+ /// Tests specific to this service provider
+ ///
+
+ public function testOmittedFiles () {
+ $subscribe = [];
+
+ $namespace = $this->app->getInstance()->getNamespace() . 'Listeners\\';
+ $files = File::allFiles(app_path('Listeners'));
+ foreach ($files as $file) {
+ $class = $namespace . $file->getBasename('.php');
+ $subscribe[] = $class;
+ }
+
+ $this->assertEquals(
+ $subscribe, Config::get('app.listeners'),
+ 'The files in the app/Listeners folder and the array of classes ' .
+ 'defined in config/app.php at listeners key diverge.',
+ 0.0, 10, true // delta, maxDepth, canonicalize
+ );
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 23:03 (14 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2308327
Default Alt Text
D234.id551.diff (3 KB)

Event Timeline