@@ -53,7 +53,8 @@ protected function getObjectManager(): ObjectManagerInterface
5353 return $ this ->objectManager ;
5454 }
5555
56- protected function getComponentByBlockName (string $ blockName
56+ protected function getComponentByBlockName (
57+ string $ blockName
5758 ): ComponentInterface {
5859 $ layout = $ this ->getObjectManager ()->get (LayoutInterface::class);
5960 $ block = $ layout ->getBlock ($ blockName );
@@ -65,73 +66,81 @@ protected function getComponentByBlockName(string $blockName
6566 return $ component ;
6667 }
6768
68- protected function assertComponentExistsOnPage (string $ componentName ,
69+ protected function assertComponentExistsOnPage (
70+ string $ componentName ,
6971 bool $ debug = false
7072 ) {
7173 $ component = $ this ->getComponent ($ componentName );
7274 $ found = $ this ->existsComponentOnPage ($ component );
73- $ msg = 'Component " ' . $ component ->getName () . '" not found ' ;
75+ $ msg = 'Component " ' . $ component ->getName (). '" not found ' ;
7476
7577 if ($ debug ) {
76- $ msg .= "\n" . $ this ->getResponseBody ();
78+ $ msg .= "\n" . $ this ->getResponseBody ();
7779 }
7880
7981 $ this ->assertTrue ($ found , $ msg );
8082 }
8183
82- protected function assertComponentNotExistsOnPage (string $ componentName ,
84+ protected function assertComponentNotExistsOnPage (
85+ string $ componentName ,
8386 bool $ debug = false
8487 ) {
8588 $ component = $ this ->getComponent ($ componentName );
8689 $ found = $ this ->existsComponentOnPage ($ component );
87- $ msg = 'Component " ' . $ component ->getName () . '" found anyway ' ;
90+ $ msg = 'Component " ' . $ component ->getName (). '" found anyway ' ;
8891 if ($ debug ) {
89- $ msg .= "\n" . $ this ->getResponseBody ();
92+ $ msg .= "\n" . $ this ->getResponseBody ();
9093 }
9194
9295 $ this ->assertFalse ($ found , $ msg );
9396 }
9497
95- protected function assertElementIdExistsOnPage (string $ elementId ,
98+ protected function assertElementIdExistsOnPage (
99+ string $ elementId ,
96100 bool $ debug = false
97101 ) {
98102 $ found = $ this ->existsElementIdOnPage ($ elementId );
99- $ msg = 'Element ID " ' . $ elementId . '" not found ' ;
103+ $ msg = 'Element ID " ' . $ elementId. '" not found ' ;
100104 if ($ debug ) {
101- $ msg .= "\n" . $ this ->getResponseBody ();
105+ $ msg .= "\n" . $ this ->getResponseBody ();
102106 }
103107
104108 $ this ->assertTrue ($ found , $ msg );
105109 }
106110
107- protected function assertElementIdNotExistsOnPage (string $ elementId ,
111+ protected function assertElementIdNotExistsOnPage (
112+ string $ elementId ,
108113 bool $ debug = false
109114 ) {
110115 $ found = $ this ->existsElementIdOnPage ($ elementId );
111- $ msg = 'Element ID " ' . $ elementId . '" found anyway ' ;
116+ $ msg = 'Element ID " ' . $ elementId. '" found anyway ' ;
112117 if ($ debug ) {
113- $ msg .= "\n" . $ this ->getResponseBody ();
118+ $ msg .= "\n" . $ this ->getResponseBody ();
114119 }
115120
116121 $ this ->assertFalse ($ found , $ msg );
117122 }
118123
119- protected function assertComponentValidators (array $ expectedValidators ,
124+ protected function assertComponentValidators (
125+ array $ expectedValidators ,
120126 ComponentInterface $ component
121127 ) {
122128 foreach ($ expectedValidators as $ expectedValidator ) {
123129 $ this ->assertContains (
124- $ expectedValidator , $ component ->getValidators ()
130+ $ expectedValidator ,
131+ $ component ->getValidators ()
125132 );
126133 }
127134 }
128135
129- protected function assertComponentNoValidators (array $ expectedValidators ,
136+ protected function assertComponentNoValidators (
137+ array $ expectedValidators ,
130138 ComponentInterface $ component
131139 ) {
132140 foreach ($ expectedValidators as $ expectedValidator ) {
133141 $ this ->assertNotContains (
134- $ expectedValidator , $ component ->getValidators ()
142+ $ expectedValidator ,
143+ $ component ->getValidators ()
135144 );
136145 }
137146 }
@@ -147,11 +156,13 @@ protected function assertComponentValidation(
147156
148157 if (true === $ expectedResult ) {
149158 $ this ->assertTrue (
150- $ result , 'Validation did not succeed for value: ' . $ value
159+ $ result ,
160+ 'Validation did not succeed for value: ' .$ value
151161 );
152162 } else {
153163 $ this ->assertFalse (
154- $ result , 'Validation did not fail for value: ' . $ value
164+ $ result ,
165+ 'Validation did not fail for value: ' .$ value
155166 );
156167 }
157168
@@ -167,11 +178,11 @@ protected function assertComponentValidation(
167178 protected function existsElementIdOnPage (string $ elementId ): bool
168179 {
169180 $ body = $ this ->getResponseBody ();
170- if (false === str_contains ($ body , ' id=" ' . $ elementId . '" ' )) {
181+ if (false === str_contains ($ body , ' id=" ' . $ elementId. '" ' )) {
171182 return false ;
172183 }
173184
174- if (str_contains ($ body , 'Not rendered: ' . $ elementId )) {
185+ if (str_contains ($ body , 'Not rendered: ' . $ elementId )) {
175186 return false ;
176187 }
177188
@@ -193,12 +204,13 @@ protected function existsComponentOnPage(ComponentInterface $component
193204 $ elementId = $ this ->getObjectManager ()->get (IdConvertor::class)
194205 ->toElementId ($ component ->getName ());
195206 $ body = $ this ->getResponseBody ();
196- if (false === str_contains ($ body , ' id=" ' . $ elementId . '" ' )) {
207+ if (false === str_contains ($ body , ' id=" ' . $ elementId. '" ' )) {
197208 return false ;
198209 }
199210
200211 if (str_contains (
201- $ body , 'Not rendered: ' . $ component ->getName () . ' '
212+ $ body ,
213+ 'Not rendered: ' .$ component ->getName ().' '
202214 )
203215 ) {
204216 return false ;
@@ -214,7 +226,6 @@ protected function setAsAjaxRequest(): void
214226 $ this ->getObjectManager ()->get (HttpRequest::class)->setHeaders (
215227 $ headers
216228 );
217-
218229 }
219230
220231 protected function getValidator (): Validator
@@ -231,6 +242,7 @@ protected function getResponseBody(): string
231242 {
232243 /** @var Http $response */
233244 $ response = $ this ->getResponse ();
245+
234246 return $ response ->getBody ();
235247 }
236248}
0 commit comments