Created
May 18, 2017 11:04
-
-
Save pikl-cz/7e3b1493aaa0e81bf4b7deeca64ce2f0 to your computer and use it in GitHub Desktop.
Testování presenteru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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