craftcms / craftcms/cms

Project config not loading for unit tests

Open
#5,241 16 comments 3 reactions 1 assignee View on GitHub

@angrybrad is already working on this.

Since Nov 21, 2019.

testing ✅
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

I'm seeing a strange issue that I hope someone can help me out with.

I have a test suite that consists of some functional and unit tests. The functional tests reference some data loaded in from project.yaml and insert some records into the DB. The unit tests do not. This all works fine.

I've now added some new unit tests that reference a section and an entry type and create some entries. When I run the full suite, these tests error out, saying they can't find the section/entry type. (The functional tests continue to work properly.) When I run the unit tests only, it alternates between running properly and failing with the same error.

I've tried running with the -vvv option but it doesn't output any debugging info about how it's loading in the project configuration.

Steps to reproduce
  1. Create a unit test that references a section defined in project.yaml
  2. Run it

codeception.yml:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
bootstrap: _bootstrap.php
params:
    - tests/.env
modules:
    config:
        \craft\test\Craft:
            configFile: 'tests/_craft/config/test.php'
            entryUrl: 'http://clientname.test/index.php'
            entryScript: ''
            projectConfig: {file: 'config/project.yaml', reset: false}
            migrations: []
            plugins: []
            cleanup: true
            transaction: true
            dbSetup: {clean: true, setupCraft: true}
Additional info
  • Craft version: 3.3.15
  • PHP version: 7.1.31
  • Database driver & version: MariaDB 10.3.17
  • Plugins & versions: Codeception v3.1.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.