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

PHPUnit - Test Loop and Event on ConnectionInterface :: Dummy question #234

Closed
gravataLonga opened this issue May 17, 2020 · 2 comments
Closed
Labels

Comments

@gravataLonga
Copy link

gravataLonga commented May 17, 2020

Hello i have a really dumb quesiton, i'm trying to test some application that use reactphp/socket over TCP connection it's half-duplex communication..

Who i can simulate the event loop and test the on event, like on('data',, etc..

p.s.: I don't want to use mock, i think that mocking isn't a good case for me, or at least i think using "real" colaborator is better.

@gravataLonga gravataLonga changed the title Dummy question PHPUnit - Test Loop and Event on ConnectionInterface :: Dummy question May 17, 2020
@clue clue added the question label Aug 3, 2021
@clue
Copy link
Member

clue commented Aug 3, 2021

@gravataLonga Good question!

There are multiple ways to test socket connections. On a lower level, you may want to (partially) mock the ConnectionInterface to test event handlers for unit testing. On a higher level, you may want to create actual socket connections and transmit data for some integration tests. On the highest level, you may want to run your actual network service in a CI environment and run actual commands against this service for some integration and/or acceptance tests.

There's really no right or wrong here, it all depends on what you're trying to build specifically. As a starting point, I would always recommend taking a look at existing implementations with high test coverage, e.g. https://github.com/clue/reactphp-redis/tree/main/tests or https://github.com/friends-of-reactphp/mysql/tree/master/tests.

I hope this helps 👍

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can always reopen this 👍

@clue clue closed this as completed Aug 3, 2021
@gravataLonga
Copy link
Author

@clue let me search more about that links, thanks for reply! :)

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

No branches or pull requests

2 participants