Skip to content

Commit ee481d4

Browse files
vitgramsclaude
andcommitted
docs: trim the assertion phpdoc to the call site facts
- keep the options shape, a chain example covering both step forms and the resolution rules, and point to the traits documentation for the fixture structure, the entry order and the channel wrappers - refer to `RESERVED_NOTIFICATION_FIELDS` instead of listing the reserved names, they had already drifted apart once Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 52cd305 commit ee481d4

1 file changed

Lines changed: 13 additions & 32 deletions

File tree

src/Traits/NotificationsMockTrait.php

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,27 @@ trait NotificationsMockTrait
1414
protected const array RESERVED_NOTIFICATION_FIELDS = ['notification', 'channels', 'notifiable', 'locale'];
1515

1616
/**
17+
* Asserts the notifications sent during the test against the $fixture.
18+
*
1719
* $options should look like the following construction:
1820
* [
1921
* 'field_name' => ['step1', 'step2', ...],
2022
* ]
2123
*
22-
* where each step is either a method call or a property access resolved sequentially
23-
* on the notification object. The test fails when any step cannot be resolved (e.g. a
24-
* misspelled method or property name), so the chain definition is validated loudly.
25-
*
26-
* Steps format:
27-
* 'method()' — calls the method on the notification or the result of the previous step
28-
* 'property' — accesses the property on the notification or the result of the previous step
29-
*
30-
* Only public members are resolvable, a non-public one fails the test instead of raising a PHP
31-
* error. Note that the 'notification' fixture key still contains all the properties of the
32-
* notification, including the non-public ones.
33-
*
34-
* The notifiable is passed as the first argument to every method that accepts at least one
35-
* parameter, like Laravel's channel dispatch (e.g. toMail($notifiable)); parameterless methods
36-
* are called without arguments, so chaining into internal classes (e.g. DateTimeImmutable::getTimestamp())
37-
* works as well. Intended for the notification's own channel methods.
38-
*
39-
* Field names must not collide with the reserved keys: 'notification', 'channels', 'notifiable', 'locale'.
24+
* It adds a field to every fixture entry, resolving it by a chain of steps on the notification:
25+
* [
26+
* 'message' => ['toExpoPush()', 'toArray()'], // $notification->toExpoPush($notifiable)->toArray($notifiable)
27+
* 'broadcast_data' => ['toBroadcast()', 'data'], // $notification->toBroadcast($notifiable)->data
28+
* ]
4029
*
41-
* Entries are ordered the way the Notification fake groups them: by notifiable class, then by
42-
* notifiable key, and only then by the send order within that group. Sending a notification to
43-
* one notifiable, then to another one, and then to the first one again puts the third entry
44-
* before the second one, so the fixture must not be read as a chronological sequence.
30+
* A step ending with '()' is a method call, any other step is a property access, applied to the
31+
* notification on the first step and to the result of the previous one afterwards. The notifiable
32+
* is passed as the first argument to every method that accepts at least one parameter. Only public
33+
* members are resolvable, an unresolvable step fails the test.
4534
*
46-
* The 'notifiable' fixture key always contains the notifiable class, so notifiables of different
47-
* classes sharing a primary key stay distinguishable. Models are reduced to their class and
48-
* primary key, other notifiables to their class and public properties, override
49-
* prepareNotifiableFixtureData() to change that.
35+
* Field names must not collide with self::RESERVED_NOTIFICATION_FIELDS.
5036
*
51-
* Example:
52-
* [
53-
* 'message' => ['toExpoPush()', 'toArray()'], // $notification->toExpoPush($notifiable)->toArray($notifiable)
54-
* 'broadcast_on' => ['broadcastOn()'], // $notification->broadcastOn($notifiable)
55-
* 'broadcast_data' => ['toBroadcast()', 'data'], // $notification->toBroadcast($notifiable)->data
56-
* ]
37+
* @see documentation/traits.md#notificationsmocktrait
5738
*
5839
* @param array<string, string[]> $options
5940
*/

0 commit comments

Comments
 (0)