Does anybody know how to use PHPUnit's mocking functionality with Yii?

Hi,

I want to checkout the Mocking functionality from PHPUnit. I’ve heard that it should be very useful.

So I’ve played around a bit:


        public function testBlar(){


        $stub = $this->getMockBuilder('\app\controllers\NonStaticClass')

                        ->setMethods(array('foo'))

                        ->getMock();




        $debug = $stub->method('foo')

                        ->willReturn('foo');

        $debug = true;


    }

Like in the example at https://phpunit.de/manual/current/en/test-doubles.html

But I’m getting

Has anybody an idea what goes wrong here? My Controller can be definitely found.

Thanks