O'Reilly logo

Learning Yii Testing by Matteo Pescarin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Isolating components with stubs

The problem we are facing right now is that we don't really want to use the actual security component, as it's not part of the test itself. Keep in mind that we're working in a black box environment, and we don't know what other dependencies the security component might have in the future. We just need to ensure that our implemented method will behave correctly, given the interface of the (fake) object works as expected. We can later add an integration method to ensure that the security component actually works, but that's a completely different matter.

In order to do that, PHPUnit provides an interesting system for stubbing and mocking classes and injecting them into your application to provide a more controlled ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required