0

When I change the application model in my acceptance test, the test acutally uses that model, when I do the same in functional test... the test still uses yii/web/application I need it to use my common/compontents/application model. How can I change that ?

The functional _bootstrap contains my custom model... (common/compontents/application) I am totally baffled....

When I run my testing code:

use tests\codeception\frontend\FunctionalTester;
$I = new FunctionalTester($scenario);
$I->amOnPage('/');

Then I get the error:

[yii\base\UnknownPropertyException] Getting unknown property: yii\web\Application::nowSQL

This nowSQL is defined in common\components\application, but somehow this functional test uses the default

Acceptance yml

    # Codeception Test Suite Configuration

    # suite for acceptance tests.
    # perform tests in browser using the Selenium-like tools.
    # powered by Mink (http://mink.behat.org).
    # (tip: that's what your customer will see).
    # (tip: test your ajax and javascript by one of Mink drivers).

    # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.

    class_name: AcceptanceTester
    modules:
        enabled:
            - PhpBrowser
            - tests\codeception\common\_support\FixtureHelper
    # you can use WebDriver instead of PhpBrowser to test javascript and ajax.
    # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
    # "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
    # it is useful if you want to login in your app in each test.
    #        - WebDriver
        config:
            PhpBrowser:
    # PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
                url: http://example.com
    #        WebDriver:
    #            url: http://localhost:8080
    #            browser: firefox
    #            restart: true

Functional .YML

    # Codeception Test Suite Configuration

    # suite for functional (integration) tests.
    # emulate web requests and make application process them.
    # (tip: better to use with frameworks).

    # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
    #basic/web/index.php
    class_name: FunctionalTester
    modules:
        enabled:
          - Filesystem
          - Yii2
          - tests\codeception\common\_support\FixtureHelper
        config:
            Yii2:
                configFile: '../config/frontend/functional.php'

8
  • Could you show content of acceptance.suite.yml and functional.suite.yml files? Commented Aug 30, 2016 at 9:44
  • Added the acceptance and functional.yml... really appreciating your help... pulling my hair out... Commented Aug 30, 2016 at 11:34
  • How do you change the application model in acceptance tests? Commented Aug 30, 2016 at 11:41
  • In the acceptance/_bootstrap I do :new common\components\Application(require(dirname(dirname(DIR)) . '/config/frontend/acceptance.php')); Commented Aug 30, 2016 at 12:37
  • in the functional/_bootstrap is do: new common\components\Application(require(dirname(dirname(DIR)) . '/config/frontend/functional.php')); Commented Aug 30, 2016 at 12:38

1 Answer 1

0

In order to use your custom application class for functional tests, set the 'class' configuration in your 'functional.php' config.

functional.suite.yml:

class_name: FunctionalTester
modules:
    enabled:
      - Yii2
    config:
        Yii2:
            configFile: 'codeception/config/functional.php'

functional.php:

return [
    'class' => 'my\custom\Application',
    ...
];

Regarding acceptance testing you have to change the Application implementation used in your index-text.php:

[...]
(new my\custom\Application($config))->run();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.