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

LinkedIn Learning

Writing and Refactoring Testable PHP

via LinkedIn Learning

Overview

Discover how to leverage test-driven development (TDD) in new PHP projects and refactor code in existing projects.

Syllabus

Introduction
  • Test-driven development and refactoring in PHP
  • Concepts and technologies you should know
  • Using GitHub Codespaces with this course
1. What Are You Doing Here?
  • Automated testing
  • Define types of testing
  • What is refactoring?
  • When to refactor
2. TDD a New Project
  • Configure a project for tests
  • Write an acceptance test
  • Write a failing unit test, make the test pass, refactor
  • Write testable code
3. What to Refactor in Existing (Legacy) Projects
  • Large chunks of logic
  • Incorrect OOP logic
  • Change lots of files for one feature
  • Unnecessary code
  • Strong coupling
  • Using mocks
  • Files that are modified often
  • Identifying the best place to start
4. Examples of Test-Driven Refactoring
  • Add one passing test
  • Identify a brittle function and add tests
  • Extract functionality (using TDD)
  • Simplify conditionals
  • Simplify function signatures
5. OOP Examples of Test-Driven Refactoring
  • Identify objects from related functions
  • Replace arrays with objects
  • Add value objects (easy to test)
  • Add null objects
  • Replace conditionals with interfaced classes
6. Moving Fast by Moving Slower
  • Make steady progress
  • Prevent regressions
  • Cleaner code
  • Decoupled code
  • Become a better developer
7. TDD and Refactoring in the Real World
  • On a spaghetti-code project
  • With a looming deadline
  • With a team that doesn't understand TDD and refactoring
  • With a PM that doesn’t understand TDD and refactoring
Conclusion
  • Next steps

Taught by

Gary Kovar

Reviews

4.6 rating at LinkedIn Learning based on 8 ratings

Start your review of Writing and Refactoring Testable PHP

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.