Problem/Motivation
Since the introduction of Simpletest, we've been plagued with issues around keeping the parent (testing) process in sync with changes in the child (tested) processes.
Even now $this->container \Drupal::container() and the container in the child processes aren't necessarily the same thing.
Proposed resolution
Refactor tests to be either pure integration tests with no browser requests, or pure browser requests with no API access. You'd be fine to use the API during setup since that all happens before the child site is requested, but once you start making browser requests, should stick to that (which means losing some shortcuts for assertions generally).
Remaining tasks
Decide if this is the course of action we want to take, then start identifying and re-factoring problematic tests.
Comments
Comment #2
alexpottI think this would be great for sanity - it's going to be hard to implement because this is not simply about the container it is about the test runner not have any access to any drupal methods.
Comment #3
neclimdulMan oh man yes. Separation of the testing environment from the site being tested has always been a dream.
However... "only" implies we can't check the database to confirm values are stored correctly. It would require quite a bit of effort to see that a hidden field the logged in user doesn't have access to is stored correctly. Or that some computed internal value is correctly triggered off a form submit. Probably other cases but those comes to mind as things we might want to consider.
Comment #9
geek-merlinWe might want to use json:api and other rpc methods to replace the api calls.
Comment #10
mile23Comment #11
mile23Comment #12
mile23Comment #13
mile23We're working on a more formal black-box testing type here #3031379: Add a new test type to do real update testing
It will be easier to make that work than to try to add the formality to the existing BTB type.
Also: No idea why I just made three comments by loading this page.
Comment #20
joachim commented> Since the introduction of Simpletest
Is this issue still relevant now we're using PHPUnit?
Comment #21
catchIt's still relevant, we have exactly the same issues between the parent child and the child site with functional tests. However, this is now a duplicate of #2066993: Use magic methods to sync container property to \Drupal::getContainer in functional tests.