-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to configure script path for fake url
[Fixes #67]
- Loading branch information
1 parent
91748f0
commit b22980d
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Kdyby\Console\HttpRequestFactory. | ||
* | ||
* @testCase Kdyby\Console\HttpRequestFactoryTest | ||
* @author Filip Procházka <filip@prochazka.su> | ||
* @package Kdyby\Console | ||
*/ | ||
|
||
namespace KdybyTests\Console; | ||
|
||
use Kdyby; | ||
use Nette\Application\LinkGenerator; | ||
use Nette\Application\PresenterFactory; | ||
use Nette\Application\Routers\Route; | ||
use Tester; | ||
use Tester\Assert; | ||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
|
||
/** | ||
* @author Filip Procházka <filip@prochazka.su> | ||
*/ | ||
class HttpRequestFactoryTest extends Tester\TestCase | ||
{ | ||
|
||
public function testScriptPath() | ||
{ | ||
$requestFactory = new Kdyby\Console\HttpRequestFactory(); | ||
$requestFactory->setFakeRequestUrl( | ||
'http://domain.tld/path/', | ||
'/path/' | ||
); | ||
|
||
$httpRequest = $requestFactory->createHttpRequest(); | ||
Assert::same('cli', $httpRequest->getMethod()); | ||
|
||
$presenterFactory = new PresenterFactory(); | ||
$presenterFactory->setMapping(['Kdyby' => 'KdybyModule\*\*Presenter']); | ||
$linkGenerator = new LinkGenerator( | ||
new Route('ABCDEF', ['presenter' => 'Kdyby:Cli', 'action' => 'default']), | ||
$httpRequest->getUrl(), | ||
$presenterFactory | ||
); | ||
|
||
$url = $linkGenerator->link('Kdyby:Cli:default', ['code' => 'brown-alert']); | ||
Assert::same('http://domain.tld/path/ABCDEF?code=brown-alert', $url); | ||
} | ||
|
||
} | ||
|
||
\run(new HttpRequestFactoryTest()); |