Problem/Motivation

Would be useful to have test coverage for rewrite functionality.

Proposed resolution

  • Add test modules, one providing config via config/install and one providing config/rewrite overrides.
  • Write tests of the rewrites. Should cover rewrites with and without the config_rewrite key set.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

nedjo created an issue. See original summary.

nedjo’s picture

StatusFileSize
new610 bytes

As a starter, here are two modules I'm using locally for manual testing.

saltednut’s picture

I think we should focus on getting this in for 8.x-1.x and stable before moving on to 8.x-2.x given the core patch #2350111: Introduce an event to decouple the module installer from the entity manager is currently stalled.

saltednut’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev
nedjo’s picture

Status: Active » Needs review
StatusFileSize
new7.85 KB
saltednut’s picture

Status: Needs review » Needs work

Had issues running this via core/scripts/run-tests.sh and via UI

The errors are different. Perhaps you can recreate? I also need to test this with core by itself.

Output from command line:

05:01:04 PM 8.x-2.x ~/Sites/df.local/docroot $ php core/scripts/run-tests.sh --module config_rewrite

Drupal test run
---------------

Tests to be run:
  - Drupal\Tests\config_rewrite\Kernel\ConfigRewriteTest

Test run started:
  Tuesday, January 17, 2017 - 22:01

Test summary
------------

PHP Warning:  array_map(): An error occurred while invoking the map callback in /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php on line 125
PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/Users/brant.wynn/Sites/df.local/docroot/modules): failed to open dir: No such file or directory' in /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php:23
Stack trace:
#0 /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php(23): RecursiveDirectoryIterator->__construct('/Users/brant.wy...', 512)
#1 [internal function]: drupal_phpunit_find_extension_directories('/Users/brant.wy...')
#2 /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php(125): array_map('drupal_phpunit_...', Array)
#3 /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php(137): drupal_phpunit_populate_class_loader()
#4 /Users/brant.wynn/Sites/df.local/vendor/phpunit/phpunit/src/Util/Fileloader.php(56): include_once('/Users/brant.wy...')
#5 /Users/brant.wynn/Sites/df.local/vendor/phpunit/phpunit/src/Util/Fileloader.php(38): PHPUnit_Util_Fileloader::load('/Users/brant.wy...')
#6 /Users/brant.wynn/ in /Users/brant.wynn/Sites/df.local/docroot/core/tests/bootstrap.php on line 23
Drupal\Tests\config_rewrite\Kernel\ConfigRewriteTest           0 passes
FATAL Drupal\Tests\config_rewrite\Kernel\ConfigRewriteTest: test runner returned a non-zero error code (255).
Drupal\Tests\config_rewrite\Kernel\ConfigRewriteTest           0 passes   1 fails

Test run duration: 2 sec

Output from UI admin/config/development/testing/results/%:

Notice: Undefined index: error in Drupal\simpletest\Form\SimpletestResultsForm::addResultForm() (line 315 of core/modules/simpletest/src/Form/SimpletestResultsForm.php).
Drupal\simpletest\Form\SimpletestResultsForm::addResultForm(Array, Array, Object) (Line: 120)
Drupal\simpletest\Form\SimpletestResultsForm->buildForm(Array, Object, '3')
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('simpletest_results_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Notice: Undefined index: #error in Drupal\simpletest\Form\SimpletestResultsForm::addResultForm() (line 323 of core/modules/simpletest/src/Form/SimpletestResultsForm.php).
Drupal\simpletest\Form\SimpletestResultsForm::addResultForm(Array, Array, Object) (Line: 120)
Drupal\simpletest\Form\SimpletestResultsForm->buildForm(Array, Object, '3')
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('simpletest_results_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Notice: Undefined index: #error in Drupal\simpletest\Form\SimpletestResultsForm::addResultForm() (line 324 of core/modules/simpletest/src/Form/SimpletestResultsForm.php).
Drupal\simpletest\Form\SimpletestResultsForm::addResultForm(Array, Array, Object) (Line: 120)
Drupal\simpletest\Form\SimpletestResultsForm->buildForm(Array, Object, '3')
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('simpletest_results_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
saltednut’s picture

Status: Needs work » Needs review

Let's try re-queue'ing it now that the service is in place from #2841961: Pull rewrite code into a service

  • brantwynn committed 4555479 on 8.x-1.x authored by nedjo
    Issue #2829511 by nedjo: Write tests for rewrites
    
saltednut’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Needs review » Patch (to be ported)

NM, the errors must have been a product of my distro or install environment.

Tested again with stock Drupal 8.2.5 and the test passes. I think we can move forward now and port the tests to 8.x-2.x

  • brantwynn committed cc0ed2d on 8.x-2.x
    Issue #2829511 by nedjo, brantwynn: Write tests for rewrites
    
saltednut’s picture

Status: Patch (to be ported) » Fixed

Now realizing tests will fail on the bot until our core patch is in for 8.4.x that adds the ModuleEvents stuff...

Status: Fixed » Closed (fixed)

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