I have a simple class with a parser
class Parser
{
public function __construct(P1 $p1, P2 $p2)
{
$this->p1 = $p1;
// etc...
}
public function parse()
{
$this->doSomething1();
return $this->doSomething2(P3 $p3);
}
}
then I have my test class
class ParserTest
{
public function testParse()
{
$p1 = $this->getMockBuilder(P1::class)->disableOriginalConstructor()->getMock();
$p2 = $this->getMockBuilder(P2::class)->disableOriginalConstructor()->getMock();
$p3 = $this->getMockBuilder(P3::class)->disableOriginalConstructor()->getMock();
$parser = new Parser ($p1, $p2);
$result = $parser->parse($p3);
}
}
what I need to do is disable doSomething1 for the test because it is basically doing an API call, so I can test what is in result. How can I do that?