Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Throw exception on empty collection #31471

Merged
merged 1 commit into from
Feb 14, 2020
Merged

[6.x] Throw exception on empty collection #31471

merged 1 commit into from
Feb 14, 2020

Conversation

driesvints
Copy link
Member

When someone passes an empty collection of notifiables to the assertSentTo or assertNotSentTo methods of a NotificationFake then the test will be marked as risky because no assertions were made. It seems to me that if you want to perform the assertion that you'd always want to make sure that you're passing at least one notifiable. Throwing an exception on an empty collection will make it more obvious why the test isn't run.

Fixes #31459

@SjorsO
Copy link
Contributor

SjorsO commented Feb 14, 2020

maybe PHPUnit::assertNotCount(0, $notifiable, 'No notifiable given.'); would be nicer

@driesvints
Copy link
Member Author

@SjorsO you don't want to mark these as failing tests. This should indicate that the provided data for the test to run is incorrect.

@taylorotwell taylorotwell merged commit 3399284 into 6.x Feb 14, 2020
@driesvints driesvints deleted the fix-empty-fakes branch February 14, 2020 14:24
voku added a commit to voku/framework that referenced this pull request Feb 15, 2020
* upstream/master: (78 commits)
  [7.x] Implement anonymous components (laravel#31363)
  Apply fixes from StyleCI (laravel#31480)
  Apply fixes from StyleCI (laravel#31479)
  revert broken table feature
  move files
  add test for event payload of type object (laravel#31477)
  [7.x] Refactor route caching (laravel#31188)
  [6.x] Fixes appendRow on console table (laravel#31469)
  Apply fixes from StyleCI (laravel#31474)
  formatting
  Throw exception on empty collection (laravel#31471)
  Add tests for Query Builder when array value given (laravel#31464)
  Remove addHidden method (laravel#31463)
  allow afterResponse chain
  add getRawOriginal
  Remove unused use-statement
  Update comment
  [6.x] Change MySql nullable modifier to allow generated columns to be not null (laravel#31452)
  [6.x] Test for pushed events (laravel#31451)
  Fixed phpdoc
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notification mock returning PHPUnit artefacts
3 participants