Codeception WebDriver url remove trailing slash - webdriver

I'm trying to test Laravel 5.3 application. To bootstrap an application with testing config I have added index-testing.php entry point.
I have my codeception acceptance test config like this:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://nginx/index-testing.php'
host: 'selenium'
browser: 'chrome'
- \Helper\Acceptance_selenium
And here is a piece of output of the test scenario:
Scenario --
I am on page "/"
[GET] http://nginx/index-testing.php/
I click ".apply-button"
So instead of http://nginx/index-testing.php it actually goes to http://nginx/index-testing.php/ which of course results in 404
How to I remove this trailing slash?

I found the answer!
In a test I was getting home page like this:
$I->amOnPage('/');
When I changed to this:
$I->amOnPage('');
No more trailing slash present.

Related

legacy redirection with symfony routing bug?

I would like to redirect (301) all the requests like "/cgi/.*" to a "parking" page of my symfony (3.4) application "/park".
I've created a route like this :
old_legacy:
path: /cgi/{catchall}
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /park
permanets: true
requirements:
catchall: ".*"
Everything is ok when urls are "/cgi/foo/bar", "cgi/bar.php?x=2", etc., but it doesn't work when the URL end with "index.php" : "/cgi/index.php", "cgi/foo/index.php?x=2".
I goes in symfony code (same for SF master) and I found something wrong for my case:
To get baseUrl, the HttpFoundation/Request object try to get the php script filename "SCRIPT_FILENAME", but if the basename is the same as SCRIPT_NAME, it get this one !
Ok, but SCRIPT_FILENAME is "/var/www/public/index.php" and SCRIPT_NAME is "/cgi/index.php", and both basename are "index.php", thus, base URL is calculated with "/cgi/index.php" which is wrong, and the base URL become "null".
At the end of the story, the router look for the path "/" and not "/cgi/index.php".
Do other people have this issue ?

Symfony 3.4. Not any route is working - No route found for "GET /

My Symfony 3.4 project does not recognize any route anymore. Debugging routes in terminal (php bin/console debug:router) does show all the routes but app_dev.php keeps giving error messages. Routing is enabled and set correct in routing.yml file.
Clearing cache also did not work.
mail_chimp:
resource: "#MailChimpBundle/Controller/"
type: annotation
prefix: /
/**
* #Route("/klanten/lijst")
*/
public function klantenLijstAction() {
return;
}
screenshot
Thanks.
> the routing tries to match routes one by one in the order of their definitions; whenever one matches, work is done.
In the routes-list image, you look to have three (maybe more) routes to answer the URL '/'. Which single one should run a controller action?
You should probably set prefixes for the URLs that aren't the index route.

Google App Engine modules: routing second module to subdirectory

Has anyone run two different WordPress installations as separate modules inside Google App Engine?
I have the following:
/app/
- wordpress1
- wordpress2
- app.yaml
- second.yaml
- dispatch.yaml
- php.ini
Inside wordpress1 and wordpress2 are somewhat clean installations of WordPress, with some GAE helper plugins.
app.yaml contains the default module config, which redirects traffic to wordpress1 using URL handlers.
second.yaml contains the second module config (module: second) and redirects traffic to wordpress2.
In dispatch.yaml I only check for a subdir second to load the second.yaml config:
dispatch:
- url: "*/second*"
module: second
Everything is fine and dandy:
http://localhost.dev:8080 -> wordpress1/index.php
http://localhost.dev:8080/second/ -> wordpress2/index.php
But I can't seem to work out how to set the edge cases:
http://localhost.dev:8080/secondwithextra -> dispatcher error (no URL set)
http://localhost.dev:8080/second (missing trailing slash) -> same as above
I tried to add the following to second.yaml handlers:
- url: /second[^/].+/?
script: wordpress1/index.php # Reroute to `wordpress1` because not a directory match.
But that didn't really work out.
How can I make the second module accept request URI /second, /second/, /second/abc but not /secondxyz?
Having the dispatch.yaml URL glob set to */second/* breaks the slashless /second.
I think you could try to add both */second/* and /second in dispatch.yaml.

How to display the 404 error page in Symfony2 dev environment

I want to work on the 404 page from the dev environment. I customize 404 using this file : app/Resources/TwigBundle/views/Exception/error.html.twig
This prod url work correctly : mysite.com/404
But this one mysite.com/app_dev.php/404 throw a NotFoundHttpException and give me the dev debug page.
Is it possible to display the error page instead of debug page ?
UPDATE:
The official documentation has now a chapter about that : Testing Error Pages during Development
To display error pages, in web/app_dev.php change second parameter to false
$kernel = new AppKernel('dev', false);
After testing what you need, change it back.
UPDATE
Thanks #user2019515 for pointing that out - now (2.3 and up) there's a link to WebfactoryExeptionsBundle in Symfony docs and the method I wrote above should not be used.
As of Symfony2.6 in dev environment, you can use the following route:
/_error/404.html
Where 404 is the error code to test and html the format of the request.
To be able to use this features, make sure you have the following entry in your routing_dev.yml file:
# app/config/routing_dev.yml
_errors:
resource: "#TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
You need to override the exception_full.html.twig template on development.
app/Resources/TwigBundle/views/Exception/exception_full.html.twig
Symfony2 uses this template to provide you with as much debugging information as possible during development.
When the kernel is in debug mode, Symfony2 will use exception_full.html.twig, otherwise it will use the specific templates you override.
See vendor/symfony/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php, specifically the showAction() and findTemplate() functions for more details.
Also you can add routes to your routing_dev.yml file
error404:
path: /404
defaults:
_controller: FrameworkBundle:Template:template
template: TwigBundle:Exception:error404.html.twig
error500:
path: /500
defaults:
_controller: FrameworkBundle:Template:template
template: TwigBundle:Exception:error500.html.twig

Google App Engine CSS Problem

I have a strange problem with css file in google app engine.
If i use
handlers:
- url: /cms/.* script: cms.py
- url: /
script: main.py
- url: /stylesheets
static_dir: stylesheets
in my app.yaml file for http://localhost:8080/ it works fine.
But when i redirect it to another handler in main.py It gives such an error
Not found error: /login did not match any patterns in application configuration.
When I use this
handlers:
- url: /cms/.* script: cms.py
- url: .*
script: main.py
- url: /stylesheets
static_dir: stylesheets
whole logic works just fine ( no error occurs wherever I roam in the application) but no sign of css this time.
I hope you can help me.
Thanks in advance..
Try with this:
- url: /stylesheets
static_dir: stylesheets
- url: /cms/.*
script: cms.py
- url: /.*
script: main.py
Your first solution does not work with /login because using / you are getting just the root
Your second solution does not work because stylesheets cames after the catch all pattern .*

Resources