Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to force usage of router file #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ extensions:
startDelay: 1
phpIni: /etc/php5/apache2/php.ini
```
### additional configuration options:
Option Name | Value | Description
--- | --- | ---
alwaysUseRouter | boolean (default: false) | If enabled, all requests will use the specified router file regardless of if the file requested exists in the documentRoot
3 changes: 3 additions & 0 deletions src/Codeception/Extension/PhpBuiltinServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ private function getCommand()
if (isset($this->config['router'])) {
$parameters .= ' -dcodecept.user_router="' . $this->config['router'] . '"';
}
if (isset($this->config['alwaysUseRouter'])) {
$parameters .= ' -dcodecept.always_use_router="' . $this->config['alwaysUseRouter'] . '"';
}
if (isset($this->config['directoryIndex'])) {
$parameters .= ' -dcodecept.directory_index="' . $this->config['directoryIndex'] . '"';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Extension/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static public function main()
file_put_contents($accessLog, $logEntry, FILE_APPEND);
}

if (file_exists($filePath) && is_file($filePath)) {
if (file_exists($filePath) && is_file($filePath) && !get_cfg_var('codecept.always_use_router')) {
return false; // serve the requested resource as-is.
} elseif ($userRouter) {
return include $userRouter;
Expand Down