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

Phakeで簡単 モックオブジェクト作成

Phakeで簡単 モックオブジェクト作成

2012.03.27 PHP勉強会@東京 #58

Katsuhiro Ogawa

July 02, 2012
Tweet

More Decks by Katsuhiro Ogawa

Other Decks in Programming

Transcript

  1. About Me খ઒ ༤େ - OGAWA Katsuhiro @fivestr גࣜձࣾΫϩίε ձࣾͰ͸ߴڮͬͯݺ͹Εͯ·͢

    ύʔϑΣΫτPHPॻ͖·ͨ͠ 5݄ʹ΋PHPͷຊग़͢Έ͍ͨͰ͢ (৭ʑະఆ) OOPɺMVCɺDDD 2
  2. Phake::when - Answers thenReturn( $value ) $value Λฦ͢ thenThrow( $exception

    ) $exception Λεϩʔ thenCallParent() parentݺͼग़͠ 18
  3. Phake::verify Phake::verify( $mock [, $mode ] ) ->ݕূ͢Δϝιου(ظ଴͢ΔҾ਺) Phake::verify($mock, Phake::times($n))->foo()

    foo()ϝιου͕$nճݺͼग़͞Εͨ͜ͱΛݕূ Phake::verifyNoIntaraction($mock) $mockΦϒδΣΫτͷελϒϝιου͕Կ΋ݺͼग़͞ Εͳ͔ͬͨ͜ͱΛݕূ 19
  4. 21

  5. 22