In order to write my own step definitions that uses regions
As a developer
I need to have a getDrupalRegion method

CommentFileSizeAuthor
#1 get_drupal_region-2093737-1.patch918 bytesVanille

Comments

Vanille’s picture

Status: Active » Needs review
StatusFileSize
new918 bytes

Have attached a patch that adds a function to get the css selector for a region defined in the region_map.

Useful when you write your own step definitions that uses regions.

jhedstrom’s picture

There's a method called getRegion() that returns a region object. That method is currently marked private--would that be sufficient, or is there a use case for getting the name/css selector independently?

skruf’s picture

Would be good if this method was defined as protected so we can use it in extending FeatureContext class.

jhedstrom’s picture

Status: Needs review » Fixed

I made the method protected instead of private. Please re-open if an additional method is still needed. Thanks!

Vanille’s picture

The use case I had can be solved with the change. Thanks.

Wanted a step definition to just test for the existence of a region without having to use the css selector in the step, ex: "Then I should see the region"

Would be nice to be able to define css selectors for elements also. Like in the "Business Selectors extension". Will create another issue on that.

Status: Fixed » Closed (fixed)

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

  • Commit 0ba2104 on master, 1.0 by jhedstrom:
    Issue #2093737 by Vanille: Added Function to get region from region_map...

  • Commit 0ba2104 on master, 1.0, test-symfony by jhedstrom:
    Issue #2093737 by Vanille: Added Function to get region from region_map...
justintilson’s picture

Issue summary: View changes

Would someone be willing to make the getRegion() method pubic? It fails to work when calling it from a SubContext (explained here - http://dspeak.com/drupalextension/subcontexts.html & http://docs.behat.org/guides/4.context.html#using-subcontexts):

return $this->getMainContext()->getRegion($region);

Fatal error: Call to protected method Drupal\DrupalExtension\Context\DrupalContext::getRegion() from context 'DesktopSubContext' in /Users/justin.tilson/Sites/wfmcom/tests-behat/context/DesktopSubContext.php on line 22

My SubContext based tests run fine when I change 'protected' to 'public'

jhedstrom’s picture

@justintilson I just made this method public in the 1.0 branch and in master.