Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge branch 'Valicek1-master' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnzlml committed Aug 5, 2016
2 parents 7c2624f + e2fd316 commit 414e09d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static function setup($tempDir, $callback = NULL)

$_SERVER['HTTP_USER_AGENT'] = 'Awesome Browser';
$_SERVER['REMOTE_ADDR'] = '11.22.33.44';
$_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = 'test.bench';
}

}
6 changes: 3 additions & 3 deletions src/Scaffold/TestsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function generateTests($outputFolder)
break;
case 'action':
if ($extra instanceof \Nette\Application\Responses\RedirectResponse) {
$path = preg_replace('~^https?://([/a-z0-9]+).*~i', '$1', $extra->getUrl());
$generatedMethod->addBody('$this->checkRedirect(?, ?);', [$destination, $path]);
$url = new \Nette\Http\Url($extra->getUrl());
$generatedMethod->addBody('$this->checkRedirect(?, ?);', [$destination, $url->getPath()]);
} elseif ($extra instanceof \Nette\Application\Responses\JsonResponse) {
$generatedMethod->addBody('$this->checkJson(?);', [$destination]);
} else {
Expand Down Expand Up @@ -144,7 +144,7 @@ public function generateTests($outputFolder)
);
} catch (\Nette\Application\AbortException $exc) {
$extra = $this->getResponse($service);
$path = $extra ? preg_replace('~^https?://([/a-z0-9]+).*~i', '$1', $extra->getUrl()) : '/';
$path = $extra ? (new \Nette\Http\Url($extra->getUrl()))->getPath() : '/';
$testClass->addMethod('test' . ucfirst($testMethod))->addBody(
"\$this->checkForm(?, ?, [\n" . $controls . '], ?);',
[$destination . ':', $action, $path]
Expand Down
2 changes: 2 additions & 0 deletions tests/Runner/Bootstrap.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Bootstrap extends \Tester\TestCase
{
Assert::same('Awesome Browser', $_SERVER['HTTP_USER_AGENT']);
Assert::same('11.22.33.44', $_SERVER['REMOTE_ADDR']);
Assert::same('test.bench', $_SERVER['HTTP_HOST']);
Assert::same('test.bench', $_SERVER['SERVER_NAME']);
}

}
Expand Down

0 comments on commit 414e09d

Please sign in to comment.