Hands on PHPSpec

Miro Svrtan

@msvrtan

Software design/architecture

  • simple design
  • inspire confidence

Test First Development

Test Driven Development

Test Driven Development

Source: https://github.com/dwyl/learn-tdd

Check out 'Uncle Bob' doing TDD

  Robert Martin: The Transformation Priority Premise
   https://www.youtube.com/watch?v=B93QezwTQpI

Behavior Driven Development

  • specBDD vs storyBDD

PHPSpec

  • specBDD
  • generates files/code
  • highly opinionated

Dependency injection

Value object

SOLID

  • S - Single responsibility principle
  • O - Open/closed principle
  • L - Liskov substitution principle
  • I - Interface segregation principle
  • D - Dependency inversion principle

Test doubles

  • dummy
  • stub
  • spy
  • mock
  • fake

More about ...

Konstantin Kudryashov (everzet)

Design How Your Objects Talk Through Mocking at Laracon EU 2014
https://www.youtube.com/watch?v=X6y-OyMPqfw

Lets code

Get composer

https://getcomposer.org/download/

Create composer.json

{
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "require-dev": {
        "phpspec/phpspec": "~2.0"
    },
    "config": {
        "bin-dir": "bin"
    }
}

Create composer.json

php composer.phar install

Thank you all

  • feedback pleaseeeeeeee
  • https://legacy.joind.in/18946