Updated: Comment #0
Problem/Motivation
drupal_get_profile() returns 'standard' in DrupalUnitTestBase tests. This can lead to the Standard profile config being installed by DrupalUnitTestBase::installConfig(). As an example, $this->installConfig(array('filter'));
will install the 'Full HTML' format from Standard profile. This breaks encapsulation of tests.
The reason for this is that drupal_get_profile() falls back to 'standard' if Settings::get('install_profile')
is empty. Inside a DrupalUnitTestBase (almost) no settings are set at all, and 'install_profile' is not either.
Proposed resolution
Remove the fallback to 'standard' in drupal_get_profile().
Remaining tasks
User interface changes
None.
API changes
drupal_get_profile() no longer performs a (non-sensical) fallback to 'standard'.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2234771-4-drupal-get-profile-no-fallback.patch | 1.91 KB | tstoeckler |
Comments
Comment #1
tstoecklerHere's a patch for either of the two approaches.
I personally think B makes a lot of sense, but I'm not sure how badly it will break stuff.
Comment #2
tstoecklerAll right, let's do B, then.
Comment #3
sunYup, the fix for
drupal_get_profile()
makes more sense to me.All other code throughout core was recently adjusted to no longer assume that there is always an installation profile, because the early installer screens do not have one (until a profile is selected).
I think this is RTBC, but can we quickly add a test method to the
DrupalUnitTestBaseTest
(of Simpletest) with basically just one assertion thatdrupal_get_profile()
returns no installation profile?Comment #4
sunLooks like the phpDoc of drupal_get_profile() needs an adjustment, too.
Comment #5
tstoecklerThanks for the review. Makes a lot of sense, here we go.
Comment #6
sunThanks!
Comment #7
webchickLooks good, but needs a change notice. According to http://drupalcontrib.org/api/drupal/drupal!includes!common.inc/function/... this is actually called from places outside of core.
Comment #8
tstoecklerAdded a draft change record: https://drupal.org/node/2235431
There's no example code as there really is no use-case of contrib code that will have to change for this. At least I couldn't think of one.
Comment #9
tstoecklerJust added some example code with the help of @tim.plunkett in IRC.
Comment #10
sunComment #11
webchickAwesome, thanks.
Committed and pushed to 8.x.