Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPUnit testing

Shaun Hare
February 07, 2012

PHPUnit testing

ilinkoln demo

Shaun Hare

February 07, 2012
Tweet

More Decks by Shaun Hare

Other Decks in Programming

Transcript

  1. Some things are difficult Copyright:  Sheldon  Cooper:    The  Friendship

     Algorithm      :  Series  2.13  Bing  Bang  Theory  
  2. PHP Testing Phpunit.de  (xunit)   Simpletest.org   Behat.org    (BDD

     port  of  cucumber)     hEps://github.com/mageekguy/Atoum    
  3. PHUNIT Version  :  3.6       Open  Sourced  :

     github.com/sebasKanbergmann/phpunit     Widely  used  by  community    
  4. PHPUNIT     •  AsserKons   – Lots    main  ones

        •  $this-­‐>assertTrue();  /$this-­‐>assertFalse();     •  $this-­‐>assertEquals();   •  $this-­‐>assertContains();     •  $this-­‐>assertEmpty();     •  $this-­‐>assertSame();     •  $this-­‐>assertNull();     •  See  phpunit.de/manual/3.6/en  
  5. PHPUnit     •  AnnotaKons   •  DataProviders    

    •  ExcepKons   •  ExpectedOutput   •  PHPErrors      
  6. Demo •  I  wrote  some  tests  for  a  game  

      •  Paper-­‐  Scissors  –Rock  –  Lizard  –Spock    
  7. The  rules   •  Scissors  cut  paper   •  Paper

     covers  rock   •  Lizard  poisons  spock   •  Spock  smashes  scissors   •  Scissors  decapitate  lizard   •  Lizard  eats  paper   •  Paper  disproves  spock   •  Spock  vaporises  rock   •  And  as  it  always  has  rock  crushes  scissors  
  8. THANKS •  @sdh100shaun   •  Github.com/sdh100shaun/uniEestExample   •  Cartoon  slide

     taken  from  hEp://redesignland.blogspot.com/  Hope  they  don’t   mind     •  PHP  community  photos  from  Derick  Rethans  and  Just  Search  (Flickr)   •  All  other  images  mashed  up  from  @codepo8  slides  and  he  would  never  steal   kiEens  –  and  aEribute  so  because  I  didn’t  find  a  aEribuKon  I  am  placing  this   statement  here