phphooligans / tdd-workshop
🏫 Package to be used with the PhpHooligans Unit-testing Workshop 🎓
Requires
This package is auto-updated.
Last update: 2024-06-08 21:49:14 UTC
README
Introduction
This workshop is a first introductory course to isolated automated checks (also known as unit-testing). It is geared towards explaining how to create and run automated checks on a PHP code-base with PhpUnit.
After a short theoretical introduction, participants will gain the knowledge and ability to create unit-tests, and run them on a local or remote environment (such as build/CI server).
Overview
The workshop is structured as follows:
Preparation:
- Make sure PHP + Xdebug is installed and correctly configured
- Open the PhpUnit manual
Theory
A brief introduction on what automated checks are and how they work
- What is an automated check?
- What is an automated check not? (i.e. exploratory)
- How do automated checks work?
- Various benefits
- A word on xUnit
- Testing old Code vs. Checking new Code
Practice
- Installing PHPUnit
- Globally
- Per project
- Using different versions (using phpunit.phar)
- Pick a project to use for testing (or use the WordWrapper example from
PHPHOOLIGANS/workshop-unit-testing
) - Basic Configuration
- Commandline options
--configuration
- Local configuration file (phpunit.xml)
--
<testsuites>
- Project configuration file (
phpunit.xml.dist
)
- Commandline options
- Where do the tests go? (Directory structure, Namespaces and Autoloading)
- Creating an empty automated check
- Pick (or create) a class to test
- Creating a Test class
- Creating an automated check
- Running automated checks
- Creating an actual automated check
- Using Asserts to validate assumptions
Follow-up Intermediate workshops
Once the basics are under control, developers might want to learn more features that PHPUnit offers. There is a workshop aimed at intermediate knowledge.
- Configuring the IDE or text-editor. Supported options are: a. PhpStorm b. Atom c. Vim d. Sublime e. Other editor (an external tools is used)
- Providing data to tests using DataProviders
- Using test doubles
- Setting up test dependencies
- More configuration
- Strictness
forceCoversAnnotation="true"
<logging>
- TestDox
- Coverage Text
- Coverage Clover XML
<filter>
- Strictness
- Code Coverage
- Adding annotation
@coversDefaultClass
and@covers
- Adding annotation
Follow-up Advanced workshops
There more advanced or topic-specific workshops beyond the knowledge the intermediate workshop offers:
- Acceptance Tests with Selenium and the php-webdriver
- Generating Test Data with QuickCheck
- Test Mutation with Humbug
- Mocking build-in or legacy functionality with php-mock
- Working with other Mock libraries such as Mockery or Phony
- Writing tests using PHP's native PHPT
- Speeding up deploy with phpunit-clever-and-smart
/EOF/