Skip to main content

phpspec: Testing... *Designing* with a Bite

2h 54m 25s
English
Paid

phpspec: a tool for unit testing? Sure... but, oof, it's so much cooler than that! Just like with our phpunit tutorial, when we finally launch our dinosaur park during a hurricane, on a Friday night, we do not want all the dinosaurs to escape. However, phpspec goes one step beyond "just writing tests": it helps you think about the design of your classes first through "specifications" and "examples".

Why Choose phpspec?

phpspec is more than a testing tool; it's a design tool. As a side-effect of using phpspec, you get tests, code generation, and with a bit of creativity, even a nyan cat to show us if our tests pass:

Course Outline

  • Getting phpspec set up: Start with installation and configuration.
  • What is a Specification? Understand how specifications guide your design process.
  • Writing Examples: Learn how to write effective examples that serve as tests.
  • Generating Code: Automatically generate code from specifications!
  • Matchers and Custom Assertions: Dive into matchers and learn how to write your own.
  • phpspec, TDD, BDD, PHPUnit & Behat: Discover how phpspec fits into the testing and development landscape.
  • Understanding ObjectBehavior: Unravel the mysteries of the ObjectBehavior class.
  • The Red, Green, Refactor Cycle: Master the essential TDD cycle.
  • Testing Exceptions: Learn how to handle exceptions in your tests.
  • Prophecy & Test Doubles: Grasp the use of dummies, stubs, spies, and mocks.
  • The let() Method for Set Up: Simplify setup with the let() method.

About the Author: symfonycasts

symfonycasts thumbnail
Woh, hey! I'm Ryan - the lead trainer and one of your friends here at SymfonyCasts. Look, I love being a developer, but the road to becoming a productive programmer is not easy. When I started, good information was buried by theory and real-world examples were non-existent. There's a great developer stuck inside each of us! And in 2011, I started SymfonyCasts (formerly: KnpUniversity) to help more people discover and unlock that potential by using better methods of learning. Being the documentation lead for a massive open source project (Symfony), a frequent speaker and an in-person trainer for 5 years has helped us craft our strict philosophy for real, significant learning. Build real-world projects from end-to-end, via beautiful video tutorials NEVER use slides (gross!) Have some fun! We promise energy, space-ship animations, and embarrassing (I mean intelligent) jokes Practice, practice, practice using our realistic coding challenges. Then enjoy a sandwich! Keep things simple and save the heroically difficult details for later (or never!) Now, it's your turn. So suit up (pajamas are the official uniform), get ready to work hard, and finally awaken the amazing developer that's hiding inside of you!

Watch Online 28 lessons

This is a demo lesson (10:00 remaining)

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

View Pricing
0:00
/
#1: Installing phpspec
All Course Lessons (28)
#Lesson TitleDurationAccess
1
Installing phpspec Demo
06:14
2
Buzzwords! Specification & Examples
07:48
3
Matchers, Examples & Generation
09:44
4
Custom Inline Matcher
05:36
5
Registering & Autoloading a Custom Matcher
05:27
6
Coding up the Custom Matcher
05:45
7
phpspec? PHPUnit? BDD? TDD? Buzzwords?
06:47
8
Red, Green, Refactor Cycle + More Dinosaurs
05:42
9
The ObjectBehavior Magic
05:31
10
The Magic of the Subject
03:45
11
Describing Object Construction
06:14
12
Coding & Debugging
04:23
13
Instantiation with a static Factory Method
05:39
14
Describing the Factory Service
07:39
15
Object Dependencies: To Mock, or Not?
08:16
16
Expecting Exceptions
06:15
17
The ObjectStateMatcher
07:12
18
Describing for Exception Messages
08:15
19
When Existing Tests Break & Exceptions in __construct()
07:20
20
Test Doubles
06:09
21
The EnclosureBuilderService
04:47
22
Dummies
06:25
23
Stubs
07:03
24
Promises (control return values) & Arguments
06:04
25
Advanced Argument Matching
04:00
26
Mocks & Spies - shouldBeCalledTimes()
05:04
27
Test Doubles, Dummies, Mocks & Spies
04:12
28
Let: The Setup Function
07:09
Unlock unlimited learning

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

Learn more about subscription