Test Drive Development and Objet Oriented in SPS: A Case Study in fighting Drupal

Post on 10-May-2015

2,648 views 4 download

Tags:

description

These are the slides Erik Summerfield (e2thex) presented at DrupalCamp Austin 2013. During his talk, he explored the benefits of Test Driven Development (TDD) that he saw in writing the SPS module and how an Object Oriented (OO) approach helped make this process work. In addition, he discussed the challenges of doing TDD in Drupal and how to work through the using OO ideas.

transcript

OO and TDD in SPS is cool

by Erik Summerfield Phase2 Technology esummerfield@phase2technology.com e2thex most other places

What is SPS?

The Site Preview System developed as part of the Content Staging Initative, fund by a Aquia's Large Scale Drupal Project

What is TDD?

.------------. .-------| edit Test | | '------------' v ^ .------------. .----------. | | write Test |---->| run Test |--Pass---' '------------' '----------' .------------. | .------| Edit Code | Fails | '------------' v v ^ .------------. .----------. | | write code |----->| run Test |--Fails-' '------------' '----------' | Pass v .---------------. | refactor code | '---------------'

✩ Refactoring is so nice✩ Collaboration was smooth✩ Early Detection of Design Flaws

Doing TDD in Drupal

Unit vs Web

Tell Drupal about your tests

Base Class

Example at http://drupalcode.org/project/sps.git/blob/refs/heads/7.x-1.x:/tests/SPSBase.test

Writing Tests

Example at http://drupalcode.org/project/sps.git/blob/refs/heads/7.x-1.x:/tests/SPSDrupalUnit.test

Running Tests

✩ php scripts/run-tests.sh --color GROUPNAME [output of command]✩ php scripts/run-tests.sh --verbose --color --class CLASSNAME[output of command]

Why OO for SPS?

✩-SPS was a relatively comlicated system✩ Need to allow for extendablity✩ We could! (php 5.3)

Plugins

Plugins Class Interfaces

Fighting Drupal

Workaround hooks

Workaround for Forms

Questions?