Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Multiple expect calls to chainable expect #6

Open
olivernybroe opened this issue Feb 10, 2023 · 2 comments
Open

Multiple expect calls to chainable expect #6

olivernybroe opened this issue Feb 10, 2023 · 2 comments

Comments

@olivernybroe
Copy link
Contributor

When having multiple expect calls right after each other, this can be changed to one expect call using and statements instead

- expect($user)->name->toEqual('Oliver');
- expect($otherUser)->name->toEqual('Tomas');
+ expect($user)->name->toEqual('Oliver')
+     ->and($otherUser)->name->toEqual('Tomas')

Other chainables that can be done is when it is on the same object

- expect($user)->firstName->toEqual('oliver');
- expect($user)->lastName->toEqual('Nybroe');
+ expect($user)
+     ->firstName->toEqual('oliver')
+     ->lastName->toEqual('Nybroe');
@TomasVotruba
Copy link
Member

Personally, I find the fluent super hard to read, as it seems the calls are connected - the 1st example.
The 2nd example looks fine 👍

@olivernybroe
Copy link
Contributor Author

Makes sense.

I agree that the second example is a much nicer place.
Then let's go with that being the first thing a rector for chainable should handle.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants