Skip to content

Instantly share code, notes, and snippets.

View ndedonald's full-sized avatar

NDE DONALD ndedonald

  • ITGSTORE SA
  • Douala
View GitHub Profile
@bigonese
bigonese / example.php
Last active October 22, 2019 13:51
Example of how a "test mode" can be incorporated into a class (eg, a class that interacts with a database) so that it can be unit tested as much as possible.
<?php
// Used to make sure test mode isn't entered into on accident
class TestModeException extends Exception { }
// Used to return a testable value as far into the logic that the test can reach
class TestResultsException extends Exception { }
// The class which will be tested
class TestableClass {