Skip to content

Commit

Permalink
started test section
Browse files Browse the repository at this point in the history
  • Loading branch information
stevleibelt committed Sep 16, 2014
1 parent a03c674 commit ca8db87
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
Empty file added refactoring/todo
Empty file.
35 changes: 35 additions & 0 deletions unitTest/PHPUnit/README.md
Original file line number Diff line number Diff line change
@@ -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?
24 changes: 13 additions & 11 deletions unitTest/PHPUnit/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<phpunit bootstrap="test/bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false">

<phpunit
bootstrap="test/bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="true"
stopOnSkipped="true"
beStrictAboutTestsThatDoNotTestAnything="true"
>
<testsuites>
<testsuite name="Trainee PHPUnit Test Suite">
<directory>test/</directory>
Expand Down
15 changes: 14 additions & 1 deletion unitTest/PHPUnit/test/Test/Trainee/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@
namespace Test\Trainee;

use PHPUnit_Framework_TestCase;
use Trainee\Logger;

/**
* Class LoggerTest
* @package Test\Trainee
*/
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

}
//begin of helper
private function getNewLogger()
{
return new Logger();
}
//end of helper
}

0 comments on commit ca8db87

Please sign in to comment.