Acceptance test and ajax URL


(Alan) #1

First, thanks for a great framework. The amount of work that has gone into making Yii2 is amazing.

I am trying to run acceptance tests to using WebDriver. When I try clicking on a link call an ajax function the

URL in the test is being constructed correctly.

The baseUrl for the development site is localhost:8080/index.php. For the test site it is localhost:8080/index-test.php

PrettyPrint is enabled.

The URL in the ajax call is "/controller-name/action"

When codeception sees and clicks the link, the ajax is called, but is routed to the main site rather than the test site, and the test fails.

I’m pretty certain this is down to me not configuring my codeception/config/frontend/config.php properly.

return [

‘defaultRoute’=>‘site’,

‘components’=>[

'urlManager' => [


		'class' => 'yii\web\UrlManager',


		'enablePrettyUrl' => true,


		'showScriptName' => true,


		'baseUrl'=>'localhost:8080/index-test.php',


		'rules' => [


			'<alias:\w+>' => 'site/<alias>',


		],


		],


	]

];

The URL ajax call is always to localhost:8080/controller/action rather than localhost:8080/index-test.php/controller/action for the test site.

Any help would be appreciated