diff --git a/refactoring/todo b/refactoring/todo new file mode 100644 index 0000000..e69de29 diff --git a/unitTest/PHPUnit/README.md b/unitTest/PHPUnit/README.md index a1ce618..f31ffd0 100644 --- a/unitTest/PHPUnit/README.md +++ b/unitTest/PHPUnit/README.md @@ -1,6 +1,41 @@ # PHPUnit Trainee Story in Section Unit Test +Learn how to write unit tests with the php [de facto](https://en.wikipedia.org/wiki/De_facto) standard implementation [PHPUnit](https://phpunit.de/). + @todo * create empty unit test file * create validator that needs to get covered by a unit test * create a unit test that needs a real implementation to test against + +## Tasks + +* read [getting started](https://phpunit.de/getting-started.html) +* install phpunit +* execute phpunit (php vendor/bin/phpunit) +* read [documentation](https://phpunit.de/documentation.html) +* implement or extend a test using @dataProvider +* implement or extend a test using @depends +* implement or extend a test case using [fixtures](https://phpunit.de/manual/current/en/fixtures.html) +* [organize](https://phpunit.de/manual/current/en/organizing-tests.html) your tests +* generate code coverage report +* watch the [videos](https://phpunit.de/presentations.html) + +## Answer Yourself the Following Questions + +* why is it good to use phpunit in vendor? +* what is the phpunit.xml.dist good for? +* why does it has the suffix ".dist"? +* for what is the "bootstrap.php" good for? +* can you make phpunit more verbose? +* how to test exception throwing? + * can you validate the exception message also (if so, how)? +* whats the difference between "assertSame" and "assertEquals"? +* when to mark a test as incomplete? +* when to mark a test as skipped? +* when to mark a test as risky? +* did you find any useful annotations? +* is it easy to implement databased driven tests? + * what do you have to keep in mind? +* what is unit testing good for? +* can you extend phpunit easily? + * if you, could you find an extension you can implement? diff --git a/unitTest/PHPUnit/phpunit.xml.dist b/unitTest/PHPUnit/phpunit.xml.dist index c34b714..9645776 100644 --- a/unitTest/PHPUnit/phpunit.xml.dist +++ b/unitTest/PHPUnit/phpunit.xml.dist @@ -1,14 +1,16 @@ - - + test/ diff --git a/unitTest/PHPUnit/test/Test/Trainee/LoggerTest.php b/unitTest/PHPUnit/test/Test/Trainee/LoggerTest.php index ee8655c..df2d0f3 100644 --- a/unitTest/PHPUnit/test/Test/Trainee/LoggerTest.php +++ b/unitTest/PHPUnit/test/Test/Trainee/LoggerTest.php @@ -7,6 +7,7 @@ namespace Test\Trainee; use PHPUnit_Framework_TestCase; +use Trainee\Logger; /** * Class LoggerTest @@ -14,5 +15,17 @@ */ class LoggerTest extends PHPUnit_Framework_TestCase { + //begin of test + public function testSetOutput() + { + $this->markTestIncomplete('implement a test that validates if setOutput is working as expected'); + } + //end of test -} \ No newline at end of file + //begin of helper + private function getNewLogger() + { + return new Logger(); + } + //end of helper +} \ No newline at end of file