Creating Nette presenters for testing purposes has never been easier.
This will run Homepage presenter with default action.
$tester = new PresenterTester($container->getByType('\Nette\Application\IPresenterFactory'));
$tester->setPresenter('Homepage');
$response = $tester->run();
$tester = new PresenterTester($container->getByType('\Nette\Application\IPresenterFactory'));
$tester->setPresenter('Article');
$tester->setAction('edit');
$tester->setHandle('form-save')
$tester->setParams(array('id' => 1));
$article = array(
'content' => 'Lorem ipsum',
'save' => 'save',
);
$tester->setPost($article);
$response = $tester->run();
This can edit and save the article with id 1.
- You can not runs twice the presenter. You must clear internal cache with clean().
- Ajax support
- Native support for formular sending