Build tests in Ruby for PHP code?
Context: Took a job for a Rails dev position. There was the stipulation I would transition to the dev team after learning the system from the QA side. Well, the QA side turns out to be their legacy PHP application... and I haven't touched PHP since I graduated. Couple people left and now I'm basically running the QA boat unfortunately - so my stay might be more extended than I'd like. Every bug fix / feature is QA'd manually - and that has to change.
About the system in place:
- Current test "suite" is Cucumber + a Selenium driver : low coverage, basically an automated user running through different use paths. Tests fail intermittently. This happens with timeouts due to bloated PHP code, slow unpredictable AJAX UI changes necessary to navigate pages, chromedriver losing focus on javascript alert boxes.
- Every cucumber feature is preceded and predicated with a login / logout because there are different user access contexts (admin / staff / member / etc.), and that's the only way to encapsulate the tests. So a single run of the test "suite" will check against 118ish scenarios... and authenticate about 600ish times. Horribly inefficient.
- The "senior" dev's on the ruby team, for whatever reason, don't build rspec tests on their features. So I'm hoping I can transition whatever way I test out this application to the ruby system as well... because I foresee getting stuck with that QA as well.
I'm trying to test below the user level - unit test on PHP classes / files / behaviors directly. I DON'T want to relearn php just to build out these tests so can I go about this with Ruby in some way? Anyone have some ideas?
TLDR ; Is there a tool / approach to unit test PHP code with Ruby?
Posted May 23, 2015, 5:49 PM UTC
There's no way to unit test code in PHP with Ruby.
Just suck it up and refresh your PHP. Modern PHP really isn't that bad.
...and if these Ruby devs are the same people who build this slow, bloated PHP mess, then they're also writing slow, bloated messes in Ruby too. Sounds like you got bait and switched anyway.
Yes it is.
A majority of the PHP application was outsourced to overseas contractors and we all know what a bitch it is to refactor legacy php code, so I hope that's not the case with the ruby code base (if it is I'm on my way out lol)
Thanks for responding - I was hoping that was not the case, I don't really want to give them a reason to keep me around the PHP team longer than necessary.
I don't know if "bait and switch" is a common thing in the industry or how other companies go about it, it's my first full-time gig, but this just seems the process they bring new dev's along on here. I definitely feel slightly cheated and misled - but I couldn't have predicted the other team members around me leaving abruptly like this
Surely you can make system calls and get responses back. Or spin up a server and make requests.
Can you elaborate on what you mean by "There's no way"? Or is there some semantics involved here on "unit test"?
Unit tests are, essentially, testing individuals functions in code. This usually means invoking function calls, passing in mocked objects, and asserting expected output.
You can't invoke PHP functions and pass in PHP objects to those functions from Ruby.