Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
</code>Not sure my conclusion is correct, but running the test suite against Core's Beta 10 release (for which I want to release a compatible Alpha 4 version of this module) gives the following error in the PHPUnit tests (all Drupal tests run correctly):
<code>
Fatal error: Call to undefined function Drupal\search_api\drupal_static() in /var/www/drupal/drupal8/modules/search_api/src/Utility.php on line 130
The function is still there, though, so it seems we need to manually include bootstrap.inc
in the tests?
Waiting for confirmation that this is indeed the cause, then I can of course provide a patch.
Also, and unrelatedly, there are again some schema fails. Seems like we need to manually cast the status
properties to boolean when saving a server/index?
Comment | File | Size | Author |
---|---|---|---|
#33 | 2482655-33--fix_tests.patch | 34.77 KB | drunken monkey |
#27 | 2482655-27--fix_test--interdiff.txt | 17.34 KB | drunken monkey |
#27 | 2482655-27--fix_test.patch | 258.92 KB | drunken monkey |
#21 | unitTestFix_2482655_7.patch | 28.65 KB | LKS90 |
#19 | unitTestFix_2482655_6-interdiff.txt | 602 bytes | LKS90 |
Comments
Comment #1
drunken monkeyUploading dummy patch to see if the fail also occurs for the test bot or it's just my setup …
Comment #3
drunken monkeyHuh. Different fails, interesting. Should fix those, too, of course.
But doesn't/shouldn't the test bot test PHPUnit tests, too? I thought it did …
Could someone please test if the Search API PHPUnit tests pass for them locally? (And verify that the normal tests pass with Drupal 8.0.0 Beta 10.)
Comment #4
drunken monkeyThe config fails were fixed by Andrei in #2483179: Fix some config properties for our test servers and indexes, so changing the title again.
Also, I had a short IRC chat with Sascha who helped me a lot. According to him,
bootstrap.inc
was never included, so probably the need for it is just new (i.e., thedrupal_static()
calls were newly added). But since the test bot doesn't run our PHPUnit tests, we didn't notice that.So, the primary goal of this issue is now to get the d.o test bot to run our PHPUnit tests, and (of course) to also get them passing.
The test bot seems to use
run-tests.sh --files
internally, maybe the problem lies there? Sascha says its similiar to his code for D8 Module Status.Comment #5
amateescu CreditAttribution: amateescu for Drupal Association commentedI could swear that we already had an issue with a similar title somewhere on drupal.org. Can't seem to find it on google though :(
Comment #6
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedAlright, a patch that fixes all the test fails and moves the unit tests to the correct location.
In case you would like me to split the commits into separate issues, just tell me. Moving the unit tests to the correct location is a separate commit from the test fixes.
Comment #8
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedAnother try, this time it should pass.
Removed another 'menu_link' dependency (which causes the getPath() on non-object error) which I forgot.
Moved 2 unit tests out of the testing folder. Testbot doesn't like them, locally (with the run-tests script) it at least runs but testbot doesn't even do that. Excluding these two tests (from the menu subfolder) should make the testbot run.
Comment #9
BerdirThe unit tests are executed now and everything is green, nice. However, we're not quite done yet ;)
We should have an interface for that service and move the documentation to it, would also make unit testing a bit easer. but that can be done in a separate issue I think.
Do we actually need *Custom* in the method names?
$data_type_plugin_manager is now $this, you don't need to call the service anymore.
you need to define this as a property ($this->customDataTypes) otherwise the caching isn't doing anything.
Don't return it, assign it to $this->dataTypePlugin. Same for results static cache.
And then rename the method to setUpDataTypePlugin().
Maybe we will need to extend this at some point and make it more flexible, but it looks like none of the unit tests need anything to be returned right now, they just happen to call it.
This method should then move as well.
In the long term, I think this class should not have any method that call out to Drupal::service(), but I think we don't need to move everything here, the patch is big enough.
This isn't a static method, call it with $this->, same for all other calls.
Also don't forget to remove the assignment when you don't return it anymore.
Comment #10
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedNew patch, points 2, 3, 4, 6 and 8 should be improved.
Thing still open:
1. Interface for DatatypePlugin
2. Extend mock methods where needed
3. Remove Drupal::serivce() calls from Utility class
4. Move ResultsCache Mock into a separate set up function. (currently in setUpDataTypePlugin())
Comment #12
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedAnd an interdiff file which shows the last changes.
Comment #13
Berdirshould have an empty line between the two and only one between class and the first docblock.
Not quite ;)
Just remove $types, use $this->customDataTypes directly.
The function can be protected.
No need for temporary local variables, just assign to $this->.. directly.
Comment #14
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedNew version, this one seems to take some time while testing, so probably some more issues after this test run.
Test summary
------------
Test run duration: 46 min 18 sec
wow... :D
--
Edit:
IntegrationTest: mostly fields that can't be set, tedious but easy fix.
CustomDataTypesUnitTest: FAILED: The processed value matches the altered original value
Comment #16
BerdirThis change is not correct, you still need to call the method.
Comment #17
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedModified one method to call getCustomDataTypes().
Comment #19
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedAfter moving the getDataTypeOptions method, I forgot to update the usage. That caused the test fails for IntegrationTest. New patch, I hope it also fixes the other test :D.
Comment #21
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedFixed the last test fail.
Comment #22
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedSome more improvements. Tests should still pass.
getCustomDataType() has been removed, getDataTypeInfo() has been fixed and extractField() has been changed to accommodate the usage of createInstance instead of getCustomDataType(). The tests should pass (I only ran IntegrationTest, the pickiest one :D)
Comment #24
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commented#21 wasn't really fixing anything, it just made the tests pass. I still don't get what that tests are doing, apparently. Here is the latest patch. with #21 reverted. All tests should pass now.
Comment #25
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedComment #26
BerdirLeft-over debug. Can be fixed on commit as well.
The data type API needs more work, but I think this is a step in the right direction. I'm not sure why there are hardcoded data types and custom plugin data types, I think those should be converted to plugins too, would allow to simplify the API a lot.
Comment #27
drunken monkeyThis is done because those types are special, because they are the types which backends have to support. Thus, they need to be hard-coded, retrievable separately and, e.g., also don't need a fallback type.
Therefore, they are really quite different from the data type plugins, which are really just the "custom" ones.
Of course, it would still be possible to define them as plugins and use other means to mark them as the "default" types, but I think this way is working quite well, and I don't think changing it would really simplify things.
In any case, I now looked over the patch, and it looks quite good, great job!
As is my custom, I'm rather nit-picky and therefore of course had some corrections, mostly about proper dependency injection and – as always – documentation (though you did really well in that last part!).
The updated patch is attached, along with an interdiff. If it passes for the test bot, I'll just commit it and create a new release. If it still needs polish or you have other objections, we can still change it after that. But getting the tests to pass first always seems like a good idea.
Comment #28
drunken monkeyIn classes which can use dependency injection, you should never use
\Drupal
. I changed this to proper DI.(Same in the
IndexFieldsForm
class.)As explained above, this has its reason. At the very least it should have its own issue with a discussion, it's not just a
@todo
.These don't seem to be used anywhere, currently, so I don't see a reason to keep those references.
Moreover, if someone needs them, they can just obtain them from
\Drupal
– that's the whole point, after all.Also, I moved the two
Menu
unit tests, too. Or is there a reason this wasn't done?Anyways, thanks again for all your work on this, Sascha and especially Lukas!
(Now crossing my fingers this still passes …)
Comment #29
drunken monkey(Don't know why it switched status, I specifically checked that it's still on "RTBC" before …)
Comment #30
BerdirOn custom vs. default data types: Ok, but the weird thing is that a number of those methods on the data type plugin manager are now overlapping with the getDefinition()/getDefinitions() methods but by going through multiple nested calls.. getDataTypeDefinitions() calls getCustomDataTypes(), which instantiates all the plugin objects only to get the definitions from them again.
And the naming is quite strange, it's a DataTypePluginManager, but actually defines custom data types only, so getCustomTypes() returns it's own stuff and getDataType* returns more..
We tried to limit how many changes we make here so we stopped making more changes there, that's also why we didn't inject stuff nicely.. it already called static methods that then again called into services before, it was just better hidden :)
Maybe open an issue to discuss the naming of those methods?
We didn't move the Menu unit test because they are broken :) One is completely empty and doesn't do anything, the other fails and is kind of disabled with @requires extension disabled, but that doesn't actually work.
Also, looks like your git isn't configured for renames, so the unit test move makes the patch huge :)
Comment #31
drunken monkeyThat's why we had the code in
Utility
, not in the plugin manager.But I guess bundling that code there still makes sense. We should just make it clearer to people looking at the code to see what's going on. So, according to your suggestion, I created a new issue for that: #2493599: Make our data type system more easily understandable.
Oh, so my patch will fail? It worked for me fine locally …
In any case, I don't think leaving them there, without comment, in a kind-of-unsupported location isn't a solution. We should either fix the test cases, or remove them (or fix one and remove the other). Or is the non-empty one just so conceptually broken?
(In any case, whatever we do, we can do that in a new issue. I want to get this committed and don't plan to hold it up any further.)
Ah, thanks a lot for pointing that out, I didn't even know there was a setting for that!
And if d.o understands that format – perfect!
Comment #33
drunken monkeyAh, OK, then here's the patch with the
Menu
tests removed, and here is the follow-up issue: #2493863: Re-add tests for the menus.Comment #34
drunken monkeyAh, excellent!
So, finally committed!
Thanks a lot again, Lukas and Sascha!