4

I'm running the static tests for one of my magento 2 modules php bin/magento dev:tests:run static and I get the following errors.

Data set: [ROOT]/app/code/Sample/News/Block/Adminhtml/Author/Edit/Buttons/Generic.php
Module Sample\News has undeclared dependencies: hard [Magento\Backend]
[ROOT]/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php:313
[ROOT]/lib/internal/Magento/Framework/App/Utility/AggregateInvoker.php:56
[ROOT]/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php:316

and others like that.
My module.xml file looks like this:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Sample_News" setup_version="2.0.0">
        <sequence>
            <module name="Magento_Backend"/>
            <module name="Magento_Ui" />
            <module name="Magento_Store" />
            <module name="Magento_Theme" />
            <module name="Magento_Cms" />
        </sequence>
    </module>
</config>

my composer.json file looks like this:

{
  "name": "tzyganu/magento2-sample-module",
  "description": "Magento 2 Sample crud module",
  "version": "2.0.0",
  "license": "MIT",
  "require": {
    "magento/module-backend": "~100.0.0",
    "magento/module-cms": "~100.0.0",
    "magento/module-ui": "~100.0.0",
    "magento/module-store": "100.0.*",
    "magento/framework": "100.0.*",
    "magento/module-media-storage": "100.0.*",
    "magento/module-directory": "100.0.*"
  },
  "type": "magento2-module",
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/tzyganu/Magento2SampleModule"
    }
  ],
  "autoload": {
    "files": [
      "registration.php"
    ],
    "psr-4": {
      "Sample\\News\\": ""
    }
  }
}

Is there an other place where I should declare these dependencies?

[EDIT] While debigging I found out that the module name that is used here to check for dependencies is Sample\News but in the dependency $_mapDependencies static var in the same class the module appears as sample/sample-news. This means that even if I add all the dependencies correctly it will still say that there is no declared dependency because of this.

  • If your code is in /app/code/Sample it's likely not installed via composer. Also where exactly is your composer.json for the module placed? – Kristof at Fooman May 31 '16 at 19:59
  • it is inside my module Sample/News/composer.json. And of course it's not installed via composer. I haven't finished it yet in order to publish it :) – Marius May 31 '16 at 20:46
1

The test verifies the declaration of dependencies in composer.json.

But looks like you copy/pasted the module name in composer file. You should name your module like "sample/module-news", and not "tzyganu/magento2-sample-module"

  • I did that, and I still get the same errors – Marius Jun 1 '16 at 9:15
  • Without debugging of test with your module I cannot guess what the problem do you have – KAndy Jun 1 '16 at 9:33
  • I know. I guess I have to dig in the dependency checker code. Thanks for trying. – Marius Jun 1 '16 at 9:56
1

As mentioned in the edit of the question, this happens because the module name listed in the composer.json file does not start with magento/module- or magento/magento.
The dependency tested converts the module name listed in the composer file but only takes into account the 2 prefixes I mentioned above.
The rest of the module names are not converted so they end up using the name declared in the composer file.
But when checking for dependencies, the dependency test class uses the real module name (Namespace_Module or Namespace\Module) and it does not find any declared dependencies for it. So it treats any dependency as a hard undeclared one.
I already reported the issue to the core team

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.