php - PHPUnit : mock an Interface and super class at the same time -
i have interface :
interface myinterface { const some_constant='hi'; function method(): void; }
and super class :
class myclass { private $id; function method1(){ //do } }
i need mock implements interface , extends super class,i.e mock needs of type myinterface , myclass @ same time.
the testcase::createmock
method can take 1 class mock hoping see if it's possible mock need using phpunit 6.
you use prophecy here.
class classandinterfacetest extends phpunit_framework_testcase { /** * @test */ function classandiface () { $myclass_instance = $this->prophesize (myclass::class) ->willimplement (myinterface::class)->reveal (); $this->a ($myclass_instance); $this->b ($myclass_instance); } function (myinterface $i) { } function b (myclass $i) { } }
Comments
Post a Comment