besanek/presenter-tester

Simple helper for testing Nette presenters.

Installs: 65

Dependents: 2

Stars: 5

Watchers: 2

Forks: 2

Language: PHP

v0.1.0-rc 2014-05-14 16:48 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

Build Status