I understand that this isn't really needed, but it does allow us to ensure that all static caches are clear during testing and when the caches are cleared.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Status: Needs review » Needs work

Hmm... I'm fine with clearing the 'libraries_get_path' and 'libraries_info' in libraries_flush_caches, I think that's a good idea. I don't think we should be clearing 'libraries_load', though. That would mean that any library, that has been loaded prior to that call of libraries_flush_caches() could be loaded again afterwards, which would wreak terrible havoc. In that specific test, we are just interested in the contents of the $library array, we don't care about the actual files being loaded (twice), so we do that there.

sun’s picture

hook_flush_caches() is not limited to testing, but invoked whenever drupal_flush_all_caches() is. If we want a helper for testing, then we should add that to a generic base testing class; i.e., LibrariesTestCase.

That said, we should split our tests into multiple test case classes (extending the base LibrariesTestCase) at some point.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
581 bytes

Something like this?

sun’s picture

What I meant was: If this is for testing, then it should be available for testing only.

Overall, the discussion here is a bit hard though, as I don't see an actual use-case currently, so we're kinda designing into the blue.

tstoeckler’s picture

Overall, the discussion here is a bit hard though, as I don't see an actual use-case currently, so we're kinda designing into the blue.

If this is seen as related to testing, then I think you're right.

I think flushing static caches in hook_flush_caches() is a good idea and something I would consider best practice, regardless of what we do in the test. I don't think I can come up with an actual use-case where you would want the statics to be reset, but if only for debugging purposes I would like that.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
581 bytes

Still can't find anything wrong with #3. Re-uploading to see if it's still green. If so, I will commit this now.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, libraries.flush-statics.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
706 bytes

Here we go.

tstoeckler’s picture

Status: Fixed » Closed (fixed)

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