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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -