[Flow] Creating simple UnitTests (RestController)

Peter R peter at webschuppen.com
Wed Apr 2 10:04:07 CEST 2014


Hello,

is there any examples, how i can test methods in controller (indexAction, showAction, updateAction, deleteAction)?
I tried following in test controller:
public function setUp() {
            $this->subject = new StandardController();

            $this->view = $this->getMock('TYPO3\\Flow\\Mvc\\View\\ViewInterface');
            $this->inject($this->subject, 'view', $this->view);
        }
/**
         * @test
         * @return void
         */
        public function listActionCanBeCalled() {
            $this->subject->listAction();
        }

The result is this error:
Fatal error: Call to a member function reset() on a non-object in C:\flow-project\Packages\Framework\TYPO3.Flow\Classes\TYPO3\Flow\Mvc\Controller\AbstractController.php on line 262

At some point, i want to start a session in the StandardController but then i get an error after executing phpunit:
session_start(): Cannot send session cookie - headers already sent

I didn't found usefull examples for tasks like these. So maybe you have one.
This have to be tests on classes how extends RestController.

Thanks alot
Peter


More information about the Flow mailing list