/** * @param \PHPUnit_Framework_MockObject_Matcher_Invocation|null $matcher * * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getComposer(\PHPUnit_Framework_MockObject_Matcher_Invocation $matcher = null) { $mock = $this->getMock('\\Composer\\Composer'); $that = $this; $composer = $this->composer; $this->factory->expects($matcher ?: $this->once())->method('createComposer')->will($this->returnCallback(function ($io) use($that, $mock, $composer) { // check IO from origin composer $that->assertEquals($composer->getIO(), $io); return $mock; })); return $mock; }