Skip to content

Commit

Permalink
Merge pull request #83 from phpbb-extensions/iMattPro-patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
iMattPro authored Oct 1, 2024
2 parents 10ba38e + 31f0dcc commit 8960d27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ To run this extension from the repo (and not from a pre-built package) on a loca

## Testing Push Notifications

Testing push notifications necessitates user-to-user interactions to observe the notification behavior accurately. Follow the steps outlined below to effectively test push notifications:
Testing push notifications necessitates user-to-user interactions to observe the notification behavior accurately. Follow the steps outlined below to effectively test push notifications (the browser recommendations are what we have seen work in local environments):

1. **User Account Setup:**
- Create at least two distinct user accounts for testing purposes.
- In the notifications preferences for _**User Account 1**_, subscribe to receive Push Notifications (and assign web push notification types if necessary).
- Create at least two distinct board user accounts for testing purposes.
- Using Google Chrome, visit `UCP -> Board Preferences -> Edit notification options` for _**User Account 1**_ and enable Push Notifications (and enable all web push notification types if necessary). Your browser may ask you to allow notifications, which you should accept. Leave Chrome open and running the background.

2. **Message, Quote, or Reply Interaction:**
- Initiate a user-to-user interaction by performing one of the following actions using _**User Account 2**_:
- Initiate a user-to-user interaction by performing one of the following actions using _**User Account 2**_ in separate browser such as Firefox, Edge or Safari:
- **Private Message:** Send a direct message from _**User Account 2**_ to _**User Account 1**_.
- **Quote:** Quote a post or message authored by _**User Account 1**_ using _**User Account 2**_.
- **Reply:** Respond to a post or message authored by _**User Account 1**_ using _**User Account 2**_.

3. **Observing Push Notifications:**
- Once the interaction is performed from _**User Account 2**_ to engage with _**User Account 1**_, you promptly should see a notification for _**User Account 1**_.
- Once the interaction is performed from _**User Account 2**_ to engage with _**User Account 1**_, you promptly should see a notification from Google Chrome for _**User Account 1**_.

4. **Caveats for Local Testing**
- Local testing of Push Notifications only works from a `localhost` address or if your local server has a secure SSL certificate.
- We have seen success on Windows using manually installed PHP, Apache and MySQL. However, for reasons not yet known we do not see success on Mac using MAMP.
- Local testing of Push Notifications only works from a `http://localhost` address or if your local test server has a secure SSL certificate, e.g.: `https://local.phpbb.board`.
- Depending on your local server's setup, operating system, and browsers, it is still possible that testing push notifications may not work (for example, in a local environment running on macOS, only Chrome will show notifications).

## License

Expand Down
20 changes: 10 additions & 10 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ public function test_load_template_data($user_id, $method_data, $subscriptions,
{
$this->config['wpn_webpush_dropdown_subscribe'] = true;
$this->user->data['user_id'] = $user_id;

$this->set_listener();

$method_data['method'] = $this->notification_method_webpush;

$this->notifications->expects(self::once())
->method('get_subscription_methods')
->willReturn([$method_data['id'] => $method_data]);

$this->template->expects($expected ? self::once() : self::never())
->method('assign_vars')
->with([
Expand All @@ -243,16 +252,7 @@ public function test_load_template_data($user_id, $method_data, $subscriptions,
'U_WEBPUSH_WORKER_URL' => $this->controller_helper->route('phpbb_webpushnotifications_ucp_push_worker_controller'),
'SUBSCRIPTIONS' => $subscriptions,
'WEBPUSH_FORM_TOKENS' => $this->form_helper->get_form_tokens(\phpbb\webpushnotifications\ucp\controller\webpush::FORM_TOKEN_UCP),
]
);

$this->set_listener();

$method_data['method'] = $this->notification_method_webpush;

$this->notifications->expects(self::once())
->method('get_subscription_methods')
->willReturn([$method_data['id'] => $method_data]);
]);

$dispatcher = new \phpbb\event\dispatcher();
$dispatcher->addListener('core.page_header_after', [$this->listener, 'load_template_data']);
Expand Down

0 comments on commit 8960d27

Please sign in to comment.