I'm doing a very simple controller test using Ecomdev_PHPUnit:

class Foo_BarWishlist_Test_Controller_IndexController 
    extends EcomDev_PHPUnit_Test_Case_Controller

     * @test
     * @loadFixture ~Foo_BarWishlist/default
    public function fromcartAction()
        $this->dispatch('checkout/cart/add', array('product' => 10));
        $body = self::getResponse()->getOutputBody();


This test fails because $body is empty. When checking self::getResponse() more closely, I see that a redirect to the enable-cookies CMS page was sent.

How can I take care of this? Do I have to set the check-cookie manually? Do I have to open another page before (I tried already a $this->dispatch('/') before the actual dispatch)? Or is there a general cookie issue during the controller tests?

2 Answers 2


There's a setting for it in the admin panel:

Web > (Browser Capabilities Detection) Redirect to CMS-page if Cookies are Disabled

This setting can also be set during the tests using a config fixture.

  • I am just afraid, that the session is not properly initiated, so even if I disable this setting, something else might not work?
    – Alex
    Feb 12, 2013 at 10:25
  • You can add the session id in the URL trough Web > Session Validation > Use SID on Frontend Mar 14, 2013 at 11:03
  • @Alex did you find that there were any issues with disabling the Redirect? Did you need to add the SID to the URL like sander suggested? Jul 17, 2013 at 5:39

I believe this stack overflow answer will help:

The basic idea is to mock the session so then your "add to cart" action is successful instead of redirecting to the "cookies disabled" page.

$sessionMock = $this->getModelMockBuilder('admin/session')

    // This one removes `session_start` and other methods

    // Enables original methods usage, because by default it overrides all methods


$this->replaceByMock('singleton', 'admin/session', $sessionMock);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.