Problem/Motivation

Currently the protected method FeaturesManager::getConfigDependency() tests for InstallStorage::CONFIG_INSTALL_DIRECTORY, but not when adding a dependency on the module providing a config type. The test should be applied in either case, since no dependencies should be added for optional config.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nedjo created an issue. See original summary.

nedjo’s picture

Status: Active » Needs review
FileSize
2.39 KB

Status: Needs review » Needs work

The last submitted patch, 2: features-dependencies-2845779-2.patch, failed testing.

JeffM2001’s picture

Status: Needs work » Needs review
FileSize
3.33 KB

Updated the patch so that it also skips inter-package dependencies for optional config.

JeffM2001’s picture

Sorry, missed a line in that last patch.

JeffM2001’s picture

Ugh. I tested it and it was working, but then I did some formatting to make the code more readable and messed things up. Sorry about that. This time, I retested before uploading the patch.

The last submitted patch, 4: features-dependencies-2845779-4.patch, failed testing.

The last submitted patch, 5: features-dependencies-2845779-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 6: features-dependencies-2845779-6.patch, failed testing.

mpotter’s picture

Status: Needs work » Needs review

Triggered a new test now that the Features branch is working again.

Status: Needs review » Needs work

The last submitted patch, 6: features-dependencies-2845779-6.patch, failed testing.

mpotter’s picture

Not sure why the testbot doesn't give useful results, but here is the test result when I run it locally:

% ../vendor/bin/phpunit ../modules/features/tests/src/Unit/FeaturesManagerTest.php --verbose
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

Runtime: PHP 7.0.15
Configuration: /Users/mpotter/Projects/d8/docroot/core/phpunit.xml.dist

........FF....E...............

Time: 857 ms, Memory: 10.00Mb

There was 1 error:

1) Drupal\Tests\features\Unit\FeaturesManagerTest::testAssignConfigPackageWithNonProviderExcludedConfig
Error: Call to a member function getType() on boolean

/Users/mpotter/Projects/d8/docroot/modules/features/src/FeaturesManager.php:570
/Users/mpotter/Projects/d8/docroot/modules/features/src/FeaturesManager.php:620
/Users/mpotter/Projects/d8/docroot/modules/features/tests/src/Unit/FeaturesManagerTest.php:438

--

There were 2 failures:

1) Drupal\Tests\features\Unit\FeaturesManagerTest::testAssignInterPackageDependenciesWithoutBundle
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 0 => 'my_other_feature'
- 1 => 'package2'
)

/Users/mpotter/Projects/d8/docroot/modules/features/tests/src/Unit/FeaturesManagerTest.php:260

2) Drupal\Tests\features\Unit\FeaturesManagerTest::testAssignInterPackageDependenciesWithBundle
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 0 => 'giraffe_package2'
- 1 => 'my_other_feature'
)

/Users/mpotter/Projects/d8/docroot/modules/features/tests/src/Unit/FeaturesManagerTest.php:308

FAILURES!
Tests: 30, Assertions: 63, Errors: 1, Failures: 2.

So some work on this is still needed.

smustgrave’s picture

Rerolled this against the latest version of dev.

Removed the last part because it was already added it appears.

-        if (!empty($config_collection[$item_name]->getData()['dependencies']['config'])) {
+        $subdirectory = $config_collection[$item_name]->getSubdirectory();
+        if (!empty($config_collection[$item_name]->getData()['dependencies']['config']) && $subdirectory === InstallStorage::CONFIG_INSTALL_DIRECTORY) {

Also had to change
$provider = $this->entityManager->getDefinition($type)->getProvider();

To

$provider = $this->entityTypeManager->getDefinition($type)->getProvider();

Very small tweak but appears to be working after initial testing.

smustgrave’s picture

I don't understand Drupal 8 unit testing well enough to know why it's failing.

Status: Needs review » Needs work

The last submitted patch, 15: features-optional-dependency-2845779-15-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nedjo’s picture

Status: Needs work » Needs review
FileSize
3.73 KB

And with the fix.

nedjo’s picture

Status: Needs review » Needs work

The last submitted patch, 18: features-optional-dependency-2845779-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nedjo’s picture

Status: Needs work » Needs review
FileSize
4.1 KB

Fixing up test.

  • nedjo committed b5c5f3c on 8.x-3.x
    Issue #2845779 by nedjo, JeffM2001, smustgrave, mpotter: Config...
nedjo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.