Skip to main content
CF

PHPUnit: Testing with a Bite

28m 8s
English
Paid

It's Friday night... it's stormy... the office is empty... and you're deploying fresh code to production. Suddenly, an alarm! What!? The fences are down!? The dinosaurs are escaping! Somehow, your beautiful code contained a bug! As the raptors surround you, one thought keeps coming back: If only we had written tests.

In this tutorial, we're going to jump over the hurdle of learning how to test so you can save the day!

What You'll Learn

  • Basic Unit Testing: Understand the fundamentals.
  • Test-Driven Development: How to do it, when to do it!
  • Mocking and Test Doubles: Creating mocks in PHPUnit & Prophecy.
  • Data Providers: Run tests repeatedly with different input.
  • Test Lifecycle Management: Execute code before and after each test.
  • Exception Testing: Ensure your code handles errors properly.
  • Database Handling: Manage and test database interactions.
  • Integration Tests: Test with real objects.
  • Functional Testing: Ensure your application works optimally end-to-end.
  • Continuous Integration (CI): Let the robots run your tests for seamless deployment.

About the Author: KnpUniversity

KnpUniversity thumbnail

KnpUniversity (now known as SymfonyCasts) is a US-based PHP / Symfony training platform run by Ryan Weaver, a Symfony core team member. The platform is the closest thing to an official video-tutorial source for the Symfony framework — Ryan's tutorials are the path most working Symfony developers learned the framework through.

The CourseFlix listing carries two KnpUniversity courses: Learn Symfony 3 and PHPUnit — Testing with a Bite. Material is paid and aimed at PHP developers picking up Symfony or PHPUnit testing.

Watch Online 29 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 29 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: PHPUnit: Secure the Park
All Course Lessons (29)
#Lesson TitleDurationAccess
1
PHPUnit: Secure the Park Demo
05:44
2
Tests, Assertions & Coding
06:41
3
TDD & Unit, Integration & Functional Tests
03:41
4
TDD in Practice
04:59
5
Factory Testing
07:03
6
Hooks: setUp, tearDown & Skipping Tests
00:00
7
Data Providers!
00:00
8
Coding, Adding Features, Refactoring
00:00
9
Handling Object Dependencies
00:00
10
Testing Exceptions
00:00
11
Exceptions Part 2: Adding Fence Security
00:00
12
Refactoring & Dependency Injection
00:00
13
Mocks & Test Doubles
00:00
14
Mocks: Control the Return Value
00:00
15
Mocks: expects() Assert Method is Called Correctly
00:00
16
Full Mock Example
00:00
17
Full Mock Example: the Sequel
00:00
18
Mocking with Prophecy
00:00
19
The Important CLI Options & phpunit.xml.dist
00:00
20
Integration Tests
00:00
21
Clearing the Database
00:00
22
Partial Mocking
00:00
23
Functional Tests
00:00
24
DomCrawler: Epic Beast of the Night
00:00
25
Test Fixtures & Fast Databases!
00:00
26
Loading Fixtures References
00:00
27
Testing a Form Submit
00:00
28
Continuous Integration: Activate the Robots
00:00
29
CircleCI Artifacts
00:00
Unlock unlimited learning

Get instant access to all 28 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

Related courses

Frequently asked questions

What prerequisites are needed before enrolling in this course?
Before enrolling in this course, students should have a basic understanding of PHP programming. Familiarity with object-oriented programming concepts will also be beneficial, as the course involves topics like dependency injection and handling object dependencies. No prior knowledge of PHPUnit or testing frameworks is required, as the course starts with basic unit testing fundamentals.
What projects or exercises will I work on during the course?
The course involves several practical exercises, including handling object dependencies, testing exceptions, and managing database interactions. Students will also work on setting up and executing integration and functional tests using real objects, as well as implementing continuous integration to automate testing during deployment. These exercises are designed to provide hands-on experience with PHPUnit and related testing concepts.
Who is the target audience for this course?
This course is targeted at PHP developers who want to learn how to effectively implement testing in their applications. It is suitable for those new to testing frameworks or experienced developers looking to deepen their understanding of test-driven development, including mocking, data providers, and continuous integration techniques.
How does the depth of this course compare to other testing courses?
The course offers a comprehensive exploration of testing in PHP, covering basic unit tests to more advanced topics such as test-driven development, mocking techniques with PHPUnit and Prophecy, and functional testing. Unlike some introductory courses, it delves into continuous integration and database handling, providing a well-rounded understanding of testing practices in real-world scenarios.
What specific tools and platforms will I learn to use?
Students will learn to use PHPUnit for writing and running tests, as well as Prophecy for creating test doubles. The course also covers the use of DomCrawler for functional testing and CircleCI for implementing continuous integration. Additionally, students will work with phpunit.xml.dist for configuring test environments and explore various command-line options for PHPUnit.
What topics are not covered in this course?
The course does not cover testing frameworks outside of PHPUnit and Prophecy. It also does not delve into non-PHP specific testing tools or techniques. While it includes database handling, it does not provide an in-depth exploration of database design or management outside the context of testing. Additionally, front-end testing tools and methodologies are not part of this course.
How can the skills learned in this course be applied to other areas or careers?
The skills acquired in this course, such as unit testing, test-driven development, and continuous integration, are applicable to a wide range of software development roles. Understanding these testing practices can enhance code quality and reliability, making these skills valuable for backend developers, software testers, and DevOps engineers. The concepts learned can also be transferred to testing frameworks in other programming languages, broadening career opportunities.