phpunit 4.0で追加されたwillreturn*()の紹介

Download PHPUnit 4.0で追加されたwillReturn*()の紹介

If you can't read please download the document

Upload: takaaki-hirano

Post on 16-Aug-2015

13 views

Category:

Technology


2 download

TRANSCRIPT

  1. 1. PHPUnit 4.0 willReturn*()
  2. 2. PHPUnitwill()
  3. 3. $stub = $this->getMockBuilder('FooClass') ->getMock(); $stub->method('barMethod') ->will($this->returnValue('BAR')); $stub->method('bazMethod') ->will($this->returnArgument(0)); $stub->method('quxMethod') ->will( $this->throwException(new Exception) );
  4. 4.
  5. 5. willReturn*()
  6. 6. $stub = $this->getMockBuilder('FooClass') ->getMock(); $stub->method('barMethod') ->willReturn('BAR'); $stub->method('bazMethod') ->willReturnArgument(0)); $stub->method('quxMethod') ->willThrowException(new Exception);
  7. 7. $stub = $this->getMockBuilder('FooClass') ->getMock(); $stub->method('barMethod') ->will($this->returnValue('BAR')); $stub->method('bazMethod') ->will($this->returnArgument(0)); $stub->method('quxMethod') ->will( $this->throwException(new Exception) );
  8. 8. ?