Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand you correctly, you're writing a test for this action. In that case it's impossible to mock $member since the new instance is created inside the method. That's why we're all striving to float as many of our <code>new</code> statements as far up in the object graph as possible (DI).</p> <p>Generally there is the special PHPunit testcase <a href="http://Zend_http://framework.zend.com/manual/en/zend.test.phpunit.html" rel="nofollow">Zend_Test_PHPUnit</a> to test your controllers. </p> <p>But it is, as a matter of fact, very hard or even impossible to test ZF controllers correctly (meaning with full isolation). You'd be better of to test the rest of your app, your general library, etc.</p> <p>In other words, in the ZF1 logic, the controller is the central wiring place (after the bootstrap), where a lot of <code>new</code> statements are traditionally used. Obviously that leads to non-testability because every instance which is created instead of injected, is unmockable.</p> <p>As @vascowhite pointed out, it is also generally good to strive for lean controllers. This means, move as much logic as possible to your model layer. This will lead to less redundance (DRY) and better testability at the same time.</p> <p>But pay attention not to bloat your models either. At one point you will probably want to factor some code out into additional components.</p> <p>An additional problem is that you can't mock the Front Controller either since it's a singleton. So you really don't have many options to test such an action. The only option would be to inject the member instance or get it from the registry (not a good idea either).</p> <p>So, given all that it is clear that you can't reach full isolation for your action tests. But </p> <p>ZF2 will be much easier to test, though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload