I have a very small test suite for testing CRUD operations on a REST API. My controller displays a form, table, etc, based on the information provided by the API. My test class create a new Buzz object and makes requests to the API server.
Unfortunately, this sucks, because if i update or delete something, it is deleted in the API. This is a very bad test practice. How can i unit test my application, when using an external data source like this?
Look into test doubles and stubs in the PHPUnit docs:
http://www.phpunit.de/manual/current/en/test-doubles.html
You can use them to replace API functionality.
Unfortunately, this sucks, because if i update or delete something, it is deleted in the API. This is a very bad test practice. How can i unit test my application, when using an external data source like this?
Create some fake, erasable data.. matter of fact you should be not even running PHPUnit tests on a production database/server.