More Related Content Similar to Specking Interactors with PHPSpec and YOLO (DDD) at PHPConference Argentina 2013 Similar to Specking Interactors with PHPSpec and YOLO (DDD) at PHPConference Argentina 2013 (20) Specking Interactors with PHPSpec and YOLO (DDD) at PHPConference Argentina 20132. Take control of your
project and live a
simpler life
Toward the scorners he is scornful,
but to the humble he gives favor.
~ Proverbs 3:34
Friday, October 4, 13
15. But we are not
solving
The Problem
Friday, October 4, 13
28. Problem: some don’t want to pay for
certification exams, so let’s build a community
site for those exams.
Friday, October 4, 13
29. Before we jump into the sauce:
Find a qualified examiner,
could be a real educator
if not
then try to become one
Friday, October 4, 13
30. Spec First ↝ BDD + DDD
Feature: student can take an exam
Scenario: student takes an exam
Given student starts an exam
And student is presented with a question
When student answers to question
...
Then student ends exam and gets graded
Friday, October 4, 13
37. Folder Structure
To convey:
- inversion of dependencies
- make dependencies explicit
- domain and infrastructure separation
- bounded context separation
Friday, October 4, 13
38. ~
!""
#
#
!""
#
#
#
#
#
#
#
#
#
#
#
tree -L 6
features
!"" student_takes_exam.feature
$"" teacher_builds_exam.feature
spec
$"" Simulator
!"" Domain
# !"" Model
# # $"" Exam
# #
!"" AttemptSpec.php
# #
!"" ExamSpec.php
# #
!"" OptionSpec.php
# #
$"" QuestionSpec.php
# !"" Port
# # !"" AnswerSpec.php
# # !"" ExamSpec.php
Friday, October 4, 13
Notice these are specs!
39. ~
!""
#
#
!""
#
#
#
#
#
#
#
#
#
#
#
tree -L 6
features
!"" student_takes_exam.feature
$"" teacher_builds_exam.feature
spec
$"" Simulator
!"" Domain
# !"" Model
# # $"" Exam
# #
!"" AttemptSpec.php
# #
!"" ExamSpec.php
# #
!"" OptionSpec.php
# #
$"" QuestionSpec.php
# !"" Port
# # !"" AnswerSpec.php
# # !"" ExamSpec.php
Friday, October 4, 13
40. ~
!""
#
#
!""
#
#
#
#
#
#
#
#
#
#
#
tree -L 6
features
!"" student_takes_exam.feature
$"" teacher_builds_exam.feature
spec
$"" Simulator
!"" Domain
# !"" Model
# # $"" Exam
# #
!"" AttemptSpec.php
# #
!"" ExamSpec.php
# #
!"" OptionSpec.php
# #
$"" QuestionSpec.php
# !"" Port
# # !"" AnswerSpec.php
# # !"" ExamSpec.php
Friday, October 4, 13
44. ~ tree -L 6
...
#
#
#
#
#
#
#
#
#
Friday, October 4, 13
$"" Infrastructure
!"" Cilex
# !"" Command
# # $"" ShowAllExamsCommand.php
# !"" Console
# # $"" Runner.php
# !"" Provider
# # $"" SimulatorServiceProvider.php
# $"" config.yml
45. ~ tree -L 6
...
#
|
#
#
#
#
#
#
#
#
#
#
#
#
#
Friday, October 4, 13
$"" Infrastructure
...
!"" Persistence
# !"" Doctrine
# # $"" OrmExamRepository.php
# !"" InMemoryAttemptRepository.php
# !"" InMemoryExamRepository.php
# $"" PDO
#
$"" PdoExamRepository.php
!"" Symfony
# $"" Bundle
#
$"" SimulatorBundle
$"" Yolo
$"" Controller
$"" ExamController.php
46. ~ tree -L 6
...
#
|
#
#
#
#
#
#
#
#
#
#
#
#
#
Friday, October 4, 13
$"" Infrastructure
...
!"" Persistence
# !"" Doctrine
# # $"" OrmExamRepository.php
# !"" InMemoryAttemptRepository.php
# !"" InMemoryExamRepository.php
# $"" PDO
#
$"" PdoExamRepository.php
!"" Symfony
# $"" Bundle
#
$"" SimulatorBundle
$"" Yolo
$"" Controller
$"" ExamController.php
47. ~ tree -L 6
...
#
|
#
#
#
#
#
#
#
#
#
#
#
#
#
Friday, October 4, 13
$"" Infrastructure
...
!"" Persistence
# !"" Doctrine
# # $"" OrmExamRepository.php
# !"" InMemoryAttemptRepository.php
# !"" InMemoryExamRepository.php
# $"" PDO
#
$"" PdoExamRepository.php
!"" Symfony
# $"" Bundle
#
$"" SimulatorBundle
$"" Yolo
$"" Controller
$"" ExamController.php
48. What if I ask
you which
classes
implement the
features?
Friday, October 4, 13
49. Folder Structure
~ tree -L
...
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
6
!""
#
#
#
!""
#
#
#
!""
#
$""
Port
!"" AnswerSpec.php
!"" ExamSpec.php
$"" ExamsSpec.php
Services
!"" ExamsConverterSpec.php
!"" GraderSpec.php
$"" PrototypeManagerSpec.php
Support
$"" StudentHelperSpec.php
UseCase
!"" GradesAttemptSpec.php
This bring us back to interactors/use cases
Friday, October 4, 13
57. ~ php bin/console exams:show
- yolo - part I
- yolo - part II
All exams displayed
Friday, October 4, 13