craftcms / craftcms/cms

Running Codeception for all tests the Craft Edition defaults to Solo before overriding project configuration

Open
#7,724 1 comment 0 reactions 1 assignee View on GitHub

@angrybrad is already working on this.

Since Mar 25, 2021.

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

Description

Description

When running codeception run for my plugin I encounter an issue when running tests.

In ApplicationTrait.php line 490:                                  
Craft Pro is required for this  

I traced the stack back through to the following event and the issue during the saveUserGroup function. Which I would expect if the Edition of Craft is set to Solo.

In my project configuration I have set the version to Pro but these settings don't seem to persist at this point. The full event I am trying to run is attached below:

Event::on(
    Plugins::class,
    Plugins::EVENT_AFTER_INSTALL_PLUGIN,
    function (PluginEvent $event) {
        if ($event->plugin === $this) {
            // We were just installed
            $magicLoginUserGroup = new UserGroup();
            $magicLoginUserGroup->name = 'Magic Login';
            $magicLoginUserGroup->handle = 'magicLoginHandle';
            $magicLoginUserGroup->description = Craft::t('magic-login', 'Users within this group were registered with magic login capabilities.');

            $groupSaved = Craft::$app
                ->getUserGroups()
                ->saveGroup($magicLoginUserGroup);

            if (!$groupSaved) {
                Craft::error(Craft::t('magic-login', 'Could not create Magic Login User group.'), __METHOD__);
            }

            Craft::info(Craft::t('magic-login', 'Created Magic Login User Group.'), __METHOD__);
        }
    }
);
Steps to reproduce
  1. Pull the code from the plugin here: https://github.com/creode/magic-login/tree/feature/40-user_groups_broken
  2. Composer install to install dependencies.
  3. Run vendor/bin/codecept run to run the test suite. An error about the Craft Version should appear even though the project config sets the version to be Pro.
Additional info
  • Craft version: 3.6.11
  • PHP version: 7.3.27
  • Database driver & version: mysql (MariaDB 10.5.9)
  • Plugins & versions: Magic Login (attached above) - 1.0.0

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.