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

How would one do unit testing of controllers w/o HTTP requests? #4

Open
AresAndy opened this issue Apr 29, 2018 · 2 comments
Open

How would one do unit testing of controllers w/o HTTP requests? #4

AresAndy opened this issue Apr 29, 2018 · 2 comments

Comments

@AresAndy
Copy link

No description provided.

@diogok
Copy link
Owner

diogok commented May 1, 2018

Hi AresAndy, I see you figured out a way to test it by yourself, which is great.

One could also change the variables $_SERVER["REQUEST_METHOD"] and $_SERVER["REQUEST_URI"] before starting the RestServer to make it will use a certain controller.

A better appoach, I think, would be to create a setRequest and setResponse method on RestServer so we could create it on demand on the tests.

As a side note, this is framework is probably outdated and lacking in comparison with modern alternatives like Slim .

@AresAndy
Copy link
Author

AresAndy commented May 1, 2018

Well, I couldn't resist to try myself 😃.

I thought of that too, but after a first look at the code it seemed to me that in order to do unit testing one should do acceptance testing instead. I also noticed that this framework is quite out of date, but unfortunately I was given the task of maintain a web service written with restserver, and while I suggested to move on a more adequate framework I was heavily forbidden to do so, so I'll see if my slight modification allows one to do phpunit w/o having a server running below.

Thanks

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

No branches or pull requests

2 participants