lucatume / wp-browser

The easy and reliable way to test WordPress with Codeception. 10 years of proven success.
https://wpbrowser.wptestkit.dev/
MIT License
603 stars 86 forks source link

[SETUP ISSUE] Notices thrown by plugin activation cause CI to fail. #614

Closed justlevine closed 1 year ago

justlevine commented 1 year ago

Environment OS: Ubuntu 22.04.2 (GitHub runner) PHP version: 8.1 Installed Codeception version: 4.2.2 Installed wp-browser version: 3.1.9 WordPress version: 5.9-6.1 Local development environment: WSL2 + devilbox (ubuntu 20.0.4 php 8.1.13) WordPress structure and management: default

Did you use the codecept init wpbrowser command? yes

Did you take a look at Codeception and wp-browser documentation? yes

Codeception configuration file

paths:
    tests: '%TESTS_DIR%'
    output: '%TESTS_OUTPUT%'
    data: '%TESTS_DATA%'
    support: '%TESTS_SUPPORT%'
    envs: '%TESTS_ENVS%'
params:
    - env
    - .env
actor_suffix: Tester
bootstrap: bootstrap.php
settings:
    colors: true
    memory_limit: 1024M
coverage:
    enabled: true
    remote: false
    c3_url: '%WP_URL%/wp-content/plugins/wp-graphql-gravity-forms/wp-graphql-gravity-forms.php'
    include:
        - src/*
    exclude:
        - wp-graphql-gravity-forms.php
        - vendor/*
    show_only_summary: false
extensions:
    enabled:
        - Codeception\Extension\RunFailed
    commands:
        - Codeception\Command\GenerateWPUnit
        - Codeception\Command\GenerateWPRestApi
        - Codeception\Command\GenerateWPRestController
        - Codeception\Command\GenerateWPRestPostTypeController
        - Codeception\Command\GenerateWPAjax
        - Codeception\Command\GenerateWPCanonical
        - Codeception\Command\GenerateWPXMLRPC
modules:
    config:
        WPDb:
            dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'
            user: '%DB_USER%'
            password: '%DB_PASSWORD%'
            populator: 'mysql -u $user -p$password -h $host $dbname < $dump'
            dump: 'tests/_data/dump.sql'
            populate: true
            cleanup: true
            waitlock: 0
            url: '%WP_URL%'
            urlReplacement: true
            tablePrefix: '%WP_TABLE_PREFIX%'
        WPBrowser:
            url: '%WP_URL%'
            wpRootFolder: '%WP_ROOT_FOLDER%'
            adminUsername: '%ADMIN_USERNAME%'
            adminPassword: '%ADMIN_PASSWORD%'
            adminPath: '/wp-admin'
            cookies: false
        REST:
            depends: WPBrowser
            url: '%WP_URL%'
        WPFilesystem:
            wpRootFolder: '%WP_ROOT_FOLDER%'
            plugins: '/wp-content/plugins'
            mu-plugins: '/wp-content/mu-plugins'
            themes: '/wp-content/themes'
            uploads: '/wp-content/uploads'
        WPLoader:
            wpRootFolder: '%WP_ROOT_FOLDER%'
            dbName: '%DB_NAME%'
            dbHost: '%DB_HOST%'
            dbUser: '%DB_USER%'
            dbPassword: '%DB_PASSWORD%'
            tablePrefix: '%WP_TABLE_PREFIX%'
            domain: '%WP_DOMAIN%'
            adminEmail: '%ADMIN_EMAIL%'
            title: 'Test'
            plugins:
                - gravityforms/gravityforms.php
                - gravityformschainedselects/chainedselects.php
                - gravityformsquiz/quiz.php
                - gravityformssignature/signature.php
                - wp-graphql/wp-graphql.php
                - wp-graphql-gravity-forms/wp-graphql-gravity-forms.php
                - wp-graphql-upload/wp-graphql-upload.php
            activatePlugins:
                - gravityforms/gravityforms.php
                - gravityformschainedselects/chainedselects.php
                - gravityformsquiz/quiz.php
                - gravityformssignature/signature.php
                - wp-graphql/wp-graphql.php
                - wp-graphql-upload/wp-graphql-upload.php
            configFile: 'tests/_data/config.php'

Suite configuration file If you're encountering an issue with a specific suite, please provide its configuration file.

# suite for acceptance tests.
actor: AcceptanceTester
modules:
    enabled:
        - Asserts
        - REST
        - WPBrowser
        - WPDb
        - WPLoader
    config:
        WPDb:
            cleanup: false

Describe the issue you're encountering When running Codeception + WPBrowser as part of my ci, Codeception fails initialization due to PHP deprecation notices caused by the plugins I'm testing against.

When I run the failing acceptance test locally, the deprecation notices get printed to the console, but the tests complete as expected.

Output GH Action report

Running Test Suite acceptance
Codeception PHP Testing Framework v4.2.2 https://helpukrainewin.org/
Powered by PHPUnit 9.6.8 by Sebastian Bergmann and contributors.
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Cookie/Jar.php on line 63
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Cookie/Jar.php on line 73
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Cookie/Jar.php on line 89
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Cookie/Jar.php on line 102
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Cookie/Jar.php on line 111
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php on line 40
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php on line 51
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php on line 68
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php on line 82
[15-May-2023 09:51:06 UTC] PHP Deprecated:  Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/wp-content/plugins/wp-graphql-gravity-forms/vendor/rmccue/requests/library/Requests/Utility/CaseInsensitiveDictionary.php on line 91

In bootstrap.php line 150:

  Activating plugin [gravityforms/gravityforms.php]...The plugin generated un  
  expected output.

To Reproduce As noted, the issue the issue is happening in harness-software/wp-graphql-gravity-forms repo and not locally. I am happy to share the GH tokens necessary for the CI to work on a fork.

Screenshots This is the output when running locally. Note it passes successfully. image

Additional context The source of the error seems to be from #556

lucatume commented 1 year ago

Hi @justlevine,

thanks for reporting an issue and providing debug information. I'm currently away from office and will come back in a couple weeks to lo into this and fix it.

lucatume commented 1 year ago

@justlevine looking at the suite configuration file, you're using the WPDb module together with the WPLoader module. The WPLoader module is not in loadOnly: true mode, though, see the documentation. This means both the WPDb module and the WPLoader module will try to manage the database initial state. If your purpose is to have WordPress and plugins functions available in the context of end-to-end tests, then:

Documentation link.