Search code examples
phptestingyii2codeception

Yii2 build-in server starts from index.php


I'm trying to execute codeception acceptance test according to https://github.com/yiisoft/yii2-app-basic/blob/master/README.md#testing

I cannot figure out why yii serve starts with entryScript index.php while I expect index-test.php. That leads to YII_DEBUG = false and, as a consequence, unable to save e-mail to a file.

Here is my codeception.yml

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    helpers: tests/_support
coverage:
    enabled: true
    remote: false
    c3_url: 'http://localhost:8080/index-test.php'
    include:
      - commands/*
      - components/*
      - controllers/*
      - models/*
      - modules/*
settings:
    bootstrap: _bootstrap.php
    memory_limit: 1024M
    colors: true
modules:
    config:
        Yii2:
            configFile: 'config/test.php'
            entryScript: index-test.php
            cleanup: false

Here is my acceptance.yml:

actor: AcceptanceTester
extensions:
    enabled:
        - Codeception\Extension\RunProcess:
            - ./tests/bin/yii serve
            - wait 2
modules:
    enabled:
    - WebDriver:
        url: 'http://localhost:8080/'
        window_size: 1920x1080
        browser: chrome
        capabilities:
            chromeOptions:
                args: ["--no-sandbox", "--headless", "--disable-gpu"]
                binary: "/usr/bin/google-chrome-stable"
            unexpectedAlertBehaviour: 'accept'

    - Yii2:
        part: [orm, email]
        entryScript: index-test.php

I've added c3.php to my index-test.php. It' the only contrast from original file.


Solution

  • You did not specify index-test.php for the Webdriver module. Try this:

     - WebDriver:
         url: 'http://localhost:8080/index-test.php'
         window_size: 1920x1080