phpunit 4.0で追加されたwillreturn*()の紹介
TRANSCRIPT
- 1. PHPUnit 4.0 willReturn*()
- 2. PHPUnitwill()
- 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.
- 5. willReturn*()
- 6. $stub = $this->getMockBuilder('FooClass') ->getMock(); $stub->method('barMethod') ->willReturn('BAR'); $stub->method('bazMethod') ->willReturnArgument(0)); $stub->method('quxMethod') ->willThrowException(new Exception);
- 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. ?