Fix composer file for Allowed Formats to work with Drupal 9 and Drupal CI
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3151386. -->
Reported by: [mohammed j. razem](https://www.drupal.org/user/255384)
>>>
<p>The project needs a composer.json for Drupal CI automated tests to work Drupal 9 tests.</p>
<hr>
<p>Having a new warning after Updating <a href="https://www.drupal.org/project/upgrade_status/releases/8.x-2.2">Upgrade Status 8.x-2.2</a> released 10 April 2020</p>
<p><span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/upgrade_status/issues/3123996" title="Status: Closed (fixed)">#3123996: Check if composer.json is not Drupal 9 compatible, if it exists</a></span></p>
<blockquote><p>The drupal/core requirement is not Drupal 9 compatible. Having a composer.json is not a requirement for Drupal 9 compatibility but if there is one, it should include a drupal/core requirement compatible with Drupal 9.</p></blockquote>
<h3>For example:</h3>
<pre>composer create-project drupal/recommended-project:~9 /var/www/html/test/drupal9test1allowed_formats -vvv<br>cd /var/www/html/test/drupal9test1allowed_formats</pre><p>
And then<br>
<code>composer require 'drupal/allowed_formats:^1.0'</code><br>
or the dev branch<br>
<code>composer require 'drupal/allowed_formats:1.x-dev'</code></p>
<p>Find out that in the .info.yml<br>
We do have <code>^8.7.7 || ^9</code><br>
It could be changed to <code>^8 || ^9</code> or <code>^8.8 || ^9</code> or <code>^8.7.7 || ^8 || ^9</code><br>
To have it work for both Drupal 8 and Drupal 9</p>
<p>When we test in Drupal 9 we can get the following issue</p>
<pre> - drupal/allowed_formats 1.x-dev requires drupal/core ^8.7.7 || ^9 -> satisfiable by drupal/core[8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.8, 8.8.x-dev, 8.9.0, 8.9.0-beta1, 8.9.0-beta2, 8.9.0-beta3, 8.9.0-rc1, 8.9.1, 8.9.x-dev, 9.0.0, 9.0.0-alpha1, 9.0.0-alpha2, 9.0.0-beta1, 9.0.0-beta2, 9.0.0-beta3, 9.0.0-rc1, 9.0.1, 9.0.x-dev, 9.1.x-dev].<br> - Can only install one of: drupal/core[9.0.0-alpha1, 8.7.1].<br> - Can only install one of: drupal/core[9.0.x-dev, 8.7.1].<br> - Can only install one of: drupal/core[9.1.x-dev, 8.7.1].<br> - Can only install one of: drupal/core[8.8.0-alpha1, 8.7.1].<br> - Can only install one of: drupal/core[8.8.x-dev, 8.7.1].<br> - Can only install one of: drupal/core[8.9.x-dev, 8.7.1].<br> - Can only install one of: drupal/core[8.7.x-dev, 8.7.1].<br> - Conclusion: install drupal/core 8.7.1</pre><hr>
It's important to update the composer with the full project set of config and have the following.
<pre>+ "require": {<br>+ "drupal/core": "^8 || ^9"<br>+ }</pre>
issue