When I have Cache Consistent in my codebase and I try to start SimpleTest for another module's tests the following error is displayed:
$ simpletest --verbose --class MetatagFaviconsTest
Fatal error: Class 'ConsistentCacheTestCaseBase' not found in sites/all/modules/contrib/cache_consistent/tests/cache_consistent.speed.test on line 12
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | cache_consistent-n2755163-3.patch | 1.76 KB | damienmckenna |
Comments
Comment #2
damienmckennaFixing the above error lead to this error:
Fatal error: Interface 'CacheVariableHandlerInterface' not found in sites/all/modules/contrib/cache_consistent/tests/cache_consistent.test.inc on line 430Comment #3
damienmckennaSo in order to fix the first error I loaded the cache_consistent.test.inc file at the top of each test file, and then to fix the second error I loaded cache_consistent.inc at the top of the cache_consistent.test.inc file.
Comment #4
damienmckennaFYI there was a similar problem with Redis: #2666866: Unable to run tests: Class 'Redis_Tests_Cache_FixesUnitTestCase' not found
Comment #5
gielfeldt commentedHmm. I thought the class was autoloaded due to its presence in the info-file?
Comment #6
damienmckennaIn theory. However, I suspect that Simpletest is sorting the list of files alphabetically and loading them in that order, rather than in the order they're listed in the info file. BICBW. The reason I wonder about the file ordering is that the cache_consistent.buffer.test file *does* have a require_once() line, apparently to fix the same problem.
So, in short, this is an existing problem with the buffer.test filethat was fixed by adding the require_once() line, so the others should be fixed this way too.
Comment #7
damienmckennaIt might be because the CacheConsistentTestHelper class is in a 'use' statement instead of being extended?
Also, the 'use' statements are inside the class definitions instead of outside. Moving them outside fixes the problem of CacheConsistentTestHelper not being loaded but still leaves ConsistentCacheTestCaseBase unavailable.
Comment #8
gielfeldt commentedAhh... But it has to be inside the class. It's a trait.
Are we sure this is not a php version issue?
Comment #9
damienmckennaOk, lets ignore #7 then.
I'm running 5.6.10 locally (from MAMP). Tests are disabled for this module, so it's hard to compare the tests across PHP versions.
Comment #10
damienmckennaBTW should ConsistentCacheTestCaseBase be an abstract class?
Comment #12
gielfeldt commentedComment #13
damienmckennaThanks!