Skip to content

Instantly share code, notes, and snippets.

@pikl-cz
Created May 18, 2017 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pikl-cz/7e3b1493aaa0e81bf4b7deeca64ce2f0 to your computer and use it in GitHub Desktop.
Save pikl-cz/7e3b1493aaa0e81bf4b7deeca64ce2f0 to your computer and use it in GitHub Desktop.
Testování presenteru
<?php
require __DIR__ . '/../../vendor/autoload.php';
Tester\Environment::setup();
$configurator = new Nette\Configurator;
$configurator->addParameters([
'appDir' => __DIR__ . '/../../app',
]);
$configurator->setDebugMode(FALSE);
$configurator->setTempDirectory(__DIR__ . '/../../temp');
$configurator->createRobotLoader()
->addDirectory(__DIR__ . '/../../app')
->addDirectory(__DIR__ . '/../../libs')
->register();
$configurator->addConfig(__DIR__ . '/../../app/config/config.neon');
$configurator->addConfig(__DIR__ . '/../../app/config/config.local.neon');
return $configurator->createContainer();
date_default_timezone_set('Europe/Prague');
define('TMP_DIR', '/tmp/app-tests');
use \Tester\Assert;
# autoloader testovanych trid
//require __DIR__ . '/../src/Greeting.php';
\Tester\Environment::setup();
<?php
namespace Test;
require __DIR__ . '/../../bootstrap.php';
$presenterFactory = $container->getByType('Nette\Application\IPresenterFactory');
$presenter = $presenterFactory->createPresenter('Shop:Sign');
$presenter->autoCanonicalize = FALSE;
// zobrazení stránky Sign:in metodou GET
$request = new Nette\Application\Request('Sign', 'GET', array('action' => 'in'));
$response = $presenter->run($request);
Assert::type('Nette\Application\Responses\TextResponse', $response);
Assert::type('Nette\Bridges\ApplicationLatte\Template', $response->getSource());
$html = (string) $response->getSource();
$dom = Tester\DomQuery::fromHtml($html);
Assert::true( $dom->has('input[name="username"]') );
Assert::true( $dom->has('input[name="password"]') );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment