Skip to content

Commit d0f62f7

Browse files
vitgramsclaude
andcommitted
docs: polish the notifications assertion section
- give the assertion its own heading with a typed signature, so the phpdoc can link straight at it, and point that link at the rendered documentation instead of an unresolvable relative path - say why the notification id never reaches the fixture, unfold the sentence about the notifiable attributes and drop the bullet repeating what the paragraph below already says about non-public members Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 459f47a commit d0f62f7

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

documentation/traits.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ public function testCreate()
4242
}
4343
```
4444

45-
Methods list:
46-
* `assertNotificationsSent($fixture, $options = [], $exportMode = false)` - compares all the sent
47-
notifications with the `$fixture`, exporting it instead of comparing when `$exportMode` is enabled,
48-
the same way the other fixture assertions of the package work.
45+
### assertNotificationsSent()
46+
47+
`assertNotificationsSent(string $fixture, array $options = [], bool $exportMode = false): void`
48+
49+
Compares all the sent notifications with the `$fixture`, exporting it instead of comparing when
50+
`$exportMode` is enabled, the same way the other fixture assertions of the package work.
4951

5052
Every entry of the fixture is placed under the notification class name and contains the
5153
`notification` properties of any visibility except `id`, the `channels` returned by `via()`, the
52-
`notifiable` and the `locale`. The `notifiable` always keeps its `class` next to the `attributes`, so
53-
notifiables of different classes sharing a primary key stay distinguishable. The attributes of a
54-
model are its primary key, of any other notifiable, e.g. `Illuminate\Notifications\AnonymousNotifiable`,
55-
its public properties:
54+
`notifiable` and the `locale`. The `id` is dropped because it is a random uuid assigned on sending,
55+
which would make every fixture unstable. The `notifiable` always keeps its `class` next to the
56+
`attributes`, so notifiables of different classes sharing a primary key stay distinguishable. The
57+
attributes of a model are its primary key. For any other notifiable, e.g.
58+
`Illuminate\Notifications\AnonymousNotifiable`, they are its public properties:
5659

5760
```json
5861
{
@@ -81,7 +84,7 @@ notifiable key, and only then by the send order within that group. Sending a not
8184
notifiable, then to another one, and then to the first one again puts the third entry before the
8285
second one, so the fixture must not be read as a chronological sequence.
8386

84-
The properties of a notification rarely describe what a channel delivers, the channel methods do.
87+
The properties of a notification rarely describe what a channel delivers the channel methods do.
8588
The `$options` argument adds such data to every entry, describing each field by a chain of steps
8689
resolved on the notification:
8790

@@ -91,7 +94,6 @@ properties, the magic ones exposed via `__isset()` and the attributes of an Eloq
9194
* the notifiable is passed as the first argument to every method that accepts at least one parameter,
9295
the way Laravel dispatches channel methods, so parameterless methods of nested objects, e.g.
9396
`DateTimeImmutable::getTimestamp()`, are called without arguments,
94-
* a non-public member is not resolvable, a step pointing at one fails the test,
9597
* field names must not collide with the reserved ones: `notification`, `channels`, `notifiable`,
9698
`locale`.
9799

@@ -108,8 +110,8 @@ $this->assertNotificationsSent(
108110
);
109111
```
110112

111-
The chain of a channel is the same in every test, so declare an assertion per channel in the project
112-
`TestCase` and keep the tests free of the chain definitions.
113+
The chain of a channel is usually the same in every test, so declare an assertion per channel in the
114+
project `TestCase` and keep the tests free of the chain definitions.
113115

114116
**Example**
115117

@@ -150,7 +152,7 @@ An internal helper of `NotificationsMockTrait`, not meant to be used directly.
150152
Methods list:
151153
* `getObjectAttributes($object)` - dumps the object properties of any visibility into an array,
152154
skipping the static ones and the typed ones that were never initialized. Private properties declared
153-
on parent classes are not captured, since they are not accessible on the object class reflection.
155+
on parent classes are not captured.
154156

155157
## SearchTrait
156158

src/Traits/NotificationsMockTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait NotificationsMockTrait
3535
*
3636
* Field names must not collide with {@see self::RESERVED_NOTIFICATION_FIELDS}.
3737
*
38-
* @see documentation/traits.md#notificationsmocktrait
38+
* @see https://github.com/RonasIT/laravel-helpers/blob/master/documentation/traits.md#assertnotificationssent
3939
*
4040
* @param array<string, string[]> $options
4141
*/

0 commit comments

Comments
 (0)