Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

SymfonyCasts

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

via SymfonyCasts

Overview

phpspec: a tool for unit testing? Sure... but, oof, it's so much cooler than that!

Yes, 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. But, phpspec goes one step beyond "just writing tests": it helps you think about the design of your classes first through "specifications" and "examples". And as a side-effect, yes! You get tests, code generation and, with a little bit of work, a nyan cat to tell us if our tests pass:

  • Getting phpspec set up
  • What's a specification?
  • Writing examples
  • Generating code from our specifications! Nice!
  • Understanding matchers and writing out own for custom "assertions"
  • How does phpspec fit into TDD, BDD, PHPUnit & Behat?
  • Demystifying the ObjectBehavior class
  • The red, green, refactor cycle
  • Testing exceptions
  • Prophecy & test doubles! Dummies, stubs, spies & mocks
  • The let() method for set up

Let's finally design a dinosaur park that will scale with every sequel!

Syllabus

  • Installing phpspec
  • Buzzwords! Specification & Examples
  • Matchers, Examples & Generation
  • Custom Inline Matcher
  • Registering & Autoloading a Custom Matcher
  • Coding up the Custom Matcher
  • phpspec? PHPUnit? BDD? TDD? Buzzwords?
  • Red, Green, Refactor Cycle + More Dinosaurs
  • The ObjectBehavior Magic
  • The Magic of the Subject
  • Describing Object Construction
  • Coding & Debugging
  • Instantiation with a static Factory Method
  • Describing the Factory Service
  • Object Dependencies: To Mock, or Not?
  • Expecting Exceptions
  • The ObjectStateMatcher
  • Describing for Exception Messages
  • When Existing Tests Break & Exceptions in __construct()
  • Test Doubles
  • The EnclosureBuilderService
  • Dummies
  • Stubs
  • Promises (control return values) & Arguments
  • Advanced Argument Matching
  • Mocks & Spies - shouldBeCalledTimes()
  • Test Doubles, Dummies, Mocks & Spies
  • Let: The Setup Function

Taught by

Andrew Marcinkevičius and Ryan Weaver

Reviews

Start your review of phpspec: Testing... *Designing* with a Bite

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.