1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,71 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace Illuminate\Support\Facades; |
|
4 |
- |
|
5 |
-use Illuminate\Database\Eloquent\Model; |
|
6 |
-use Illuminate\Support\Testing\Fakes\EventFake; |
|
7 |
- |
|
8 |
-/** |
|
9 |
- * @method static void listen(string|array $events, mixed $listener) |
|
10 |
- * @method static bool hasListeners(string $eventName) |
|
11 |
- * @method static void push(string $event, array $payload = []) |
|
12 |
- * @method static void flush(string $event) |
|
13 |
- * @method static void subscribe(object|string $subscriber) |
|
14 |
- * @method static array|null until(string|object $event, mixed $payload = []) |
|
15 |
- * @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false) |
|
16 |
- * @method static array getListeners(string $eventName) |
|
17 |
- * @method static \Closure makeListener(\Closure|string $listener, bool $wildcard = false) |
|
18 |
- * @method static \Closure createClassListener(string $listener, bool $wildcard = false) |
|
19 |
- * @method static void forget(string $event) |
|
20 |
- * @method static void forgetPushed() |
|
21 |
- * @method static \Illuminate\Events\Dispatcher setQueueResolver(callable $resolver) |
|
22 |
- * |
|
23 |
- * @see \Illuminate\Events\Dispatcher |
|
24 |
- */ |
|
25 |
-class Event extends Facade |
|
26 |
-{ |
|
27 |
- /** |
|
28 |
- * Replace the bound instance with a fake. |
|
29 |
- * |
|
30 |
- * @param array|string $eventsToFake |
|
31 |
- * @return \Illuminate\Support\Testing\Fakes\EventFake |
|
32 |
- */ |
|
33 |
- public static function fake($eventsToFake = []) |
|
34 |
- { |
|
35 |
- static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake)); |
|
36 |
- |
|
37 |
- Model::setEventDispatcher($fake); |
|
38 |
- |
|
39 |
- return $fake; |
|
40 |
- } |
|
41 |
- |
|
42 |
- /** |
|
43 |
- * Replace the bound instance with a fake during the given callable's execution. |
|
44 |
- * |
|
45 |
- * @param callable $callable |
|
46 |
- * @param array $eventsToFake |
|
47 |
- * @return callable |
|
48 |
- */ |
|
49 |
- public static function fakeFor(callable $callable, array $eventsToFake = []) |
|
50 |
- { |
|
51 |
- $originalDispatcher = static::getFacadeRoot(); |
|
52 |
- |
|
53 |
- static::fake($eventsToFake); |
|
54 |
- |
|
55 |
- return tap($callable(), function () use ($originalDispatcher) { |
|
56 |
- static::swap($originalDispatcher); |
|
57 |
- |
|
58 |
- Model::setEventDispatcher($originalDispatcher); |
|
59 |
- }); |
|
60 |
- } |
|
61 |
- |
|
62 |
- /** |
|
63 |
- * Get the registered name of the component. |
|
64 |
- * |
|
65 |
- * @return string |
|
66 |
- */ |
|
67 |
- protected static function getFacadeAccessor() |
|
68 |
- { |
|
69 |
- return 'events'; |
|
70 |
- } |
|
71 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,71 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace Illuminate\Support\Facades; |
|
4 |
+ |
|
5 |
+use Illuminate\Database\Eloquent\Model; |
|
6 |
+use Illuminate\Support\Testing\Fakes\EventFake; |
|
7 |
+ |
|
8 |
+/** |
|
9 |
+ * @method static void listen(string|array $events, mixed $listener) |
|
10 |
+ * @method static bool hasListeners(string $eventName) |
|
11 |
+ * @method static void push(string $event, array $payload = []) |
|
12 |
+ * @method static void flush(string $event) |
|
13 |
+ * @method static void subscribe(object|string $subscriber) |
|
14 |
+ * @method static array|null until(string|object $event, mixed $payload = []) |
|
15 |
+ * @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false) |
|
16 |
+ * @method static array getListeners(string $eventName) |
|
17 |
+ * @method static \Closure makeListener(\Closure|string $listener, bool $wildcard = false) |
|
18 |
+ * @method static \Closure createClassListener(string $listener, bool $wildcard = false) |
|
19 |
+ * @method static void forget(string $event) |
|
20 |
+ * @method static void forgetPushed() |
|
21 |
+ * @method static \Illuminate\Events\Dispatcher setQueueResolver(callable $resolver) |
|
22 |
+ * |
|
23 |
+ * @see \Illuminate\Events\Dispatcher |
|
24 |
+ */ |
|
25 |
+class Event extends Facade |
|
26 |
+{ |
|
27 |
+ /** |
|
28 |
+ * Replace the bound instance with a fake. |
|
29 |
+ * |
|
30 |
+ * @param array|string $eventsToFake |
|
31 |
+ * @return \Illuminate\Support\Testing\Fakes\EventFake |
|
32 |
+ */ |
|
33 |
+ public static function fake($eventsToFake = []) |
|
34 |
+ { |
|
35 |
+ static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake)); |
|
36 |
+ |
|
37 |
+ Model::setEventDispatcher($fake); |
|
38 |
+ |
|
39 |
+ return $fake; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ /** |
|
43 |
+ * Replace the bound instance with a fake during the given callable's execution. |
|
44 |
+ * |
|
45 |
+ * @param callable $callable |
|
46 |
+ * @param array $eventsToFake |
|
47 |
+ * @return callable |
|
48 |
+ */ |
|
49 |
+ public static function fakeFor(callable $callable, array $eventsToFake = []) |
|
50 |
+ { |
|
51 |
+ $originalDispatcher = static::getFacadeRoot(); |
|
52 |
+ |
|
53 |
+ static::fake($eventsToFake); |
|
54 |
+ |
|
55 |
+ return tap($callable(), function () use ($originalDispatcher) { |
|
56 |
+ static::swap($originalDispatcher); |
|
57 |
+ |
|
58 |
+ Model::setEventDispatcher($originalDispatcher); |
|
59 |
+ }); |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ /** |
|
63 |
+ * Get the registered name of the component. |
|
64 |
+ * |
|
65 |
+ * @return string |
|
66 |
+ */ |
|
67 |
+ protected static function getFacadeAccessor() |
|
68 |
+ { |
|
69 |
+ return 'events'; |
|
70 |
+ } |
|
71 |
+} |