besanek / presenter-tester
Simple helper for testing Nette presenters.
v0.1.0-rc
2014-05-14 16:48 UTC
Requires
- nette/nette: >=2.0.0
Requires (Dev)
- nette/tester: 1.0.*
This package is auto-updated.
Last update: 2024-11-10 21:16:55 UTC
README
Creating Nette presenters for testing purposes has never been easier.
Simplest example
This will run Homepage presenter with default action.
$tester = new PresenterTester($container->getByType('\Nette\Application\IPresenterFactory')); $tester->setPresenter('Homepage'); $response = $tester->run();
More complex example
$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.
Limitations
- You can not runs twice the presenter. You must clear internal cache with clean().
Future
- Ajax support
- Native support for formular sending