Skip to main content
deleted 1 character in body
Source Link
Potherca
  • 530
  • 3
  • 10

Personally, I'd refactor the CURL functionality out of the PayjunctionClientPayJunctionClient class. That way you could easily test the functionality of the PayjunctionClientPayJunctionClient class by feeding it a mock CURL wrapper class. (Defining an interface could be of even more help.)

Having the CURL functionwfunction in it's own class would also have the advantage of not having more than one curl_setopt call, making the code a lot more readable.

That said, I am one of those people that will go to great length to make sure my unit tests don't touch the filesystem or network.

In regards to testing a class wrapping CURL functions, I would suggest using PHPT. A good example of how this could look is this test.

Personally, I'd refactor the CURL functionality out of the PayjunctionClient class. That way you could easily test the functionality of the PayjunctionClient class by feeding it a mock CURL wrapper class. (Defining an interface could be of even more help.)

Having the CURL functionw in it's own class would also have the advantage of not having more than one curl_setopt call, making the code a lot more readable.

That said, I am one of those people that will go to great length to make sure my unit tests don't touch the filesystem or network.

In regards to testing a class wrapping CURL functions, I would suggest using PHPT. A good example of how this could look is this test.

Personally, I'd refactor the CURL functionality out of the PayJunctionClient class. That way you could easily test the functionality of the PayJunctionClient class by feeding it a mock CURL wrapper class. (Defining an interface could be of even more help.)

Having the CURL function in it's own class would also have the advantage of not having more than one curl_setopt call, making the code a lot more readable.

That said, I am one of those people that will go to great length to make sure my unit tests don't touch the filesystem or network.

In regards to testing a class wrapping CURL functions, I would suggest using PHPT. A good example of how this could look is this test.

Source Link
Potherca
  • 530
  • 3
  • 10

Personally, I'd refactor the CURL functionality out of the PayjunctionClient class. That way you could easily test the functionality of the PayjunctionClient class by feeding it a mock CURL wrapper class. (Defining an interface could be of even more help.)

Having the CURL functionw in it's own class would also have the advantage of not having more than one curl_setopt call, making the code a lot more readable.

That said, I am one of those people that will go to great length to make sure my unit tests don't touch the filesystem or network.

In regards to testing a class wrapping CURL functions, I would suggest using PHPT. A good example of how this could look is this test.