File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
src/Bex/Behat/Magento2Extension/HelperContainer Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public function __construct(array $symfonyServiceContainers)
2121
2222 public function has ($ id )
2323 {
24- if (is_null ($ id )) {
24+ if (! $ this -> isSupportedServiceId ($ id )) {
2525 return false ;
2626 }
2727
@@ -40,6 +40,10 @@ public function has($id)
4040
4141 public function get ($ id , $ invalidBehavior = self ::EXCEPTION_ON_INVALID_REFERENCE )
4242 {
43+ if (!$ this ->isSupportedServiceId ($ id )) {
44+ return null ;
45+ }
46+
4347 try {
4448 return parent ::get ($ id );
4549 } catch (ServiceNotFoundException $ e ) {
@@ -84,4 +88,27 @@ public function compile(bool $resolveEnvPlaceholders = false)
8488
8589 parent ::compile ($ resolveEnvPlaceholders );
8690 }
91+
92+ private function isSupportedServiceId ($ id )
93+ {
94+ if (is_null ($ id )) {
95+ return false ;
96+ }
97+
98+ // If the Page Object Extension is used then let it handle the autowiring
99+ // @see \SensioLabs\Behat\PageObjectExtension\Context\Argument\PageObjectArgumentResolver::resolveArguments
100+ if ($ this ->isPageObject ($ id )) {
101+ return false ;
102+ }
103+
104+ return true ;
105+ }
106+
107+ private function isPageObject ($ id )
108+ {
109+ return (
110+ is_subclass_of ($ id , '\SensioLabs\Behat\PageObjectExtension\PageObject\Page ' ) ||
111+ is_subclass_of ($ id , '\SensioLabs\Behat\PageObjectExtension\PageObject\Element ' )
112+ );
113+ }
87114}
You can’t perform that action at this time.
0 commit comments