Codeception / Codeception

Full-stack testing PHP framework
http://codeception.com
MIT License
4.75k stars 1.3k forks source link

Override function does not override as expected #3740

Closed InputOutput closed 7 years ago

InputOutput commented 7 years ago

What are you trying to achieve?

I'm trying to set the url config value for AngularJS from commandline using the --override option

What do you get instead?

The default url from acceptance.suite.yml

Provide console output if related. Use -vvv mode for more details. I've added a dump on the AcceptanceTester object to discover where the override actually ends.

./codecept run -vvv acceptance Cms/CmsWidgetsACept -o "modules: enabled: AngularJS: url: localhost.net"

Provide test source code if related

(
    [class_name] => AcceptanceTester
    [modules] => Array
        (
            [enabled] => Array
                (
                    [0] => Array
                        (
                            [Db] => Array
                                (
                                    [dsn] => ****
                                    [user] => ****
                                    [password] => ****
                                    [populate] => 
                                    [cleanup] => 
                                    [reconnect] => 1
                                )

                        )

                    [1] => Array
                        (
                            [AngularJS] => Array
                                (
                                    [el] => html
                                    [browser] => chrome
                                    [restart] => 1
                                    [wait] => 1
                                    [url] => https://k2gocake.dev
                                    [script_timeout] => 20
                                    [window_size] => 1920x1080
                                    [capabilities] => Array
                                        (
                                            [chromeOptions] => Array
                                                (
                                                    [mobileEmulation] => Array
                                                        (
                                                            [deviceMetrics] => Array
                                                                (
                                                                    [width] => 1920
                                                                    [height] => 1080
                                                                    [pixelRatio] => 3
                                                                )

                                                            [userAgent] => Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 AcceptTest
                                                        )

                                                )

                                        )

                                )

                        )

                    [2] => Array
                        (
                            [Asserts] => 
                        )

                    [3] => Array
                        (
                            [REST] => Array
                                (
                                    [depends] => PhpBrowser
                                    [url] => https://k2gocake.dev
                                )

                        )

                )

            [AngularJS] => 
            [url] => localhost.net
            [config] => Array
                (
                )

            [depends] => Array
                (
                )

        )

    [env] => Array
        (
            [firefox] => Array
                (
                    [modules] => Array
                        (
                            [config] => Array
                                (
                                    [AngularJS] => Array
                                        (
                                            [browser] => firefox
                                            [capabilities] => Array
                                                (
                                                    [unexpectedAlertBehaviour] => accept
                                                    [chromeOptions] => 
                                                )

                                        )

                                )

                        )

                )

            [browserstack] => Array
                (
                    [modules] => Array
                        (
                            [config] => Array
                                (
                                    [AngularJS] => Array
                                        (
                                            [browser] => edge
                                            [url] => https://testing.kaartje2go.nl
                                            [host] => ****
                                            [capabilities] => Array
                                                (
                                                    [os] => Windows
                                                    [os_version] => 10
                                                    [chromeoptions] => 
                                                )

                                        )

                                )

                        )

                )

            [testrunner] => Array
                (
                    [modules] => Array
                        (
                            [config] => Array
                                (
                                    [Db] => Array
                                        (
                                            [dsn] => ****
                                            [user] => ****
                                            [password] => ****
                                        )

                                    [AngularJS] => Array
                                        (
                                            [url] => https://testing.kaartje2go.nl
                                        )

                                    [REST] => Array
                                        (
                                            [url] => https://testing.kaartje2go.nl
                                        )

                                )

                        )

                )

        )

    [bootstrap] => _bootstrap.php
    [colors] => 1
    [memory_limit] => 1024M
    [strict_xml] => 
    [lint] => 1
    [backup_globals] => 1
    [coverage] => Array
        (
        )

    [namespace] => 
    [groups] => Array
        (
            [failed] => tests/_output/failed
        )

    [gherkin] => Array
        (
        )

    [path] => /home/vagrant/kaartje2go.nl/app/Test/Codeception/tests/acceptance/
    [shuffle] => 
    [error_level] => E_ALL & ~E_STRICT & ~E_DEPRECATED
)

Details

class_name: AcceptanceTester
modules:
    enabled:
        - Db:
             dsn: '****'
             user: '****'
             password: '****'
             populate: false
             cleanup: false
             reconnect: true
        - AngularJS:
             el: html
             browser: chrome
             restart: true
             wait: 1
             url: 'https://k2gocake.dev'
             script_timeout: 20
             window_size: 1920x1080
             capabilities:
                 chromeOptions:
                     mobileEmulation:
                        deviceMetrics:
                            width: 1920
                            height: 1080
                            pixelRatio: 3,
                        userAgent: 'Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 AcceptTest'
        - Asserts:
        - REST:
            depends: PhpBrowser
            url: 'https://k2gocake.dev'
env:
    firefox:
        modules:
            config:
                AngularJS:
                    browser: firefox
                    capabilities:
                        unexpectedAlertBehaviour: 'accept'
                        chromeOptions:

    browserstack:
        modules:
            config:
                AngularJS:
                    browser: edge
                    url: 'https://testing.kaartje2go.nl'
                    host: '****'
                    capabilities:
                        os: Windows
                        os_version: 10
                        chromeoptions:

    testrunner:
        modules:
            config:
                Db:
                    dsn: '****'
                    user: '****'
                    password: '****'
                AngularJS:
                    url: 'https://testing.kaartje2go.nl'
                REST:
                    url: 'https://testing.kaartje2go.nl'
Naktibalda commented 7 years ago

@DavertMik it is your feature, please respond.

DavertMik commented 7 years ago

Unfortunately it works for global config only. Suite configs are overriding global configs.

However you can try to update it like:

./codecept run -o "modules: config: AngularJS: url: localhost.net"
InputOutput commented 7 years ago

Ok thanks for the explanation, unfortunately I don't see how this will work in our setup.