backdrop-contrib / entity_plus

This module wraps in a variety of additional entity-related functionality from various sources. Partial port of D7 Entity API.
https://backdropcms.org/project/entity_plus
GNU General Public License v2.0
3 stars 11 forks source link

entity_plus_get_property_info('node') is incomplete during Simpletest tests #101

Closed bugfolder closed 2 years ago

bugfolder commented 2 years ago

This arose when I was investigating why many of the ported tests in Rules module were failing. Eventually, I narrowed the issue down to this peculiar behavior.

In a standard Backdrop installation, which creates the page and post types, the function entity_plus_get_property_info('node') will return an array with two keys, array( 'bundles' => ..., 'properties' => ...).

In a Simpletest test run, the same two node types are created (along with the usual node 1). However, any call to entity_plus_get_property_info('node') returns an array missing the bundles key. This causes lots of problems downstream in the Rules tests, so that Rules things that fail in the tests work perfectly well in the UI.

To verify this, turn on Devel, go to admin/devel/php, and enter this code:

dpm(entity_plus_get_property_info('node'));

You'll see the resulting array with two keys.

Now go into any test that uses the "standard" profile and add this line (which just prints the keys, for brevity):

debug(print_r(array_keys(entity_plus_get_property_info('node')), TRUE));

Run the test. You will see in the output:

'Array
(
    [0] => properties
)
'

So no 'bundles' key.

Any ideas on why the discrepancy is there, and how to fix it?

argiepiano commented 2 years ago

@bugfolder I'm unable to replicate this issue. See attached image. I followed your directions and added your debug line within entity_plus.test , inside testEntityQuery.

Are you working with the latest dev version of Entity Plus? We have been making several changes that have not been released yet.

Screen Shot 2021-12-25 at 2 55 32 PM
argiepiano commented 2 years ago

Can you tell me to which specific test function you added your line?

bugfolder commented 2 years ago

Thanks for the quick response! Hmm, I just downloaded the latest dev release, trying it, and am still seeing it.

So maybe it's something peculiar to Rules's testing setup (I've only been trying it in various Rules tests).

argiepiano commented 2 years ago

I can probably take a closer look in a couple of hours. Can you give me more details as to which test method and from which module? (Rules I assume)

bugfolder commented 2 years ago

So I just tried what you described doing, and it behaved (with both 1.0.13 and the dev version of Entity Plus). So, yeah, sorry, it must be some interaction with what Rules is doing to set up for testing.

I found that if I put that debug() call even in the setUp method of any of several different Rules tests (but after calling the parent::setUp()) it lost the bundles tag.

With that added information, I"ll investigate further. Thank you for offering, but I don't want to make unnecessary work for you. If/when I figure out what's going on, I'll post here as a resolution.

bugfolder commented 2 years ago

Well, that was (is) weird. It appears that I need to explicitly include entity_plus and locale in the setup call (like this):

    parent::setUp('entity_plus', 'locale', 'rules', 'rules_test', 'path');

and then that not only addresses the issue with entity_plus_get_property_info(), it fixes the particular tests that were failing due to the discrepancy. So, progress!

I'll close this issue, since it seems like the problem was a Rules thing, not an Entity Plus thing. Thanks for quick jump-in!