Search code examples
yii2codeception

Yii2 url generation issue


In Yii2 Codeception acceptance test I am using PhantomJs as a browser.

Started server successfully

 phantomjs --webdriver=4444

When running test with

codecept run

It isn't working as expected.
My code is:

class LoginCest
{
    public function ensureThatLoginWorks(AcceptanceTester $I)
    {
        $I->amOnPage(Url::toRoute('/site/login'));
        $I->see('Enq','b');

    }
}

When changing it to

$I->amOnPage(Url::toRoute(['/../../../site/login']));

its works fine because it takes url as myApp/web/usr/local/bin/site/login

Its adding automatically usr/local/bin

is there any solution for this apart from this $I->amOnPage(Url::toRoute(['/../../../site/login']));


Solution

  • Worked fine whe replacing

     $I->amOnPage(Url::toRoute(['/../../../site/login']));
    

    with this

    $I->amOnPage('/site/login');