Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75b3531

Browse files
committedSep 29, 2024·
Symfony assertion refinement
1 parent 72cf4d1 commit 75b3531

File tree

5 files changed

+89
-151
lines changed

5 files changed

+89
-151
lines changed
 

‎composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"symfony/http-kernel": "^5.4 | ^6.4 | ^7.0",
4444
"symfony/mailer": "^5.4 | ^6.4 | ^7.0",
4545
"symfony/mime": "^5.4 | ^6.4 | ^7.0",
46-
"symfony/notifier": "5.4 | ^6.4 | ^7.0",
46+
"symfony/notifier": "^5.4 | ^6.4 | ^7.0",
4747
"symfony/options-resolver": "^5.4 | ^6.4 | ^7.0",
4848
"symfony/property-access": "^5.4 | ^6.4 | ^7.0",
4949
"symfony/property-info": "^5.4 | ^6.4 | ^7.0",

‎readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Codeception module for Symfony framework.
99

1010
## Requirements
1111

12-
* `Symfony` `5.4.x`, `6.4.x`, `7.0.x` or higher, as per the [Symfony supported versions](https://symfony.com/releases).
12+
* `Symfony` `5.4.x`, `6.4.x`, `7.1.x` or higher, as per the [Symfony supported versions](https://symfony.com/releases).
1313
* `PHP 8.1` or higher.
1414

1515
## Installation

‎src/Codeception/Module/Symfony/BrowserAssertionsTrait.php

+56-62
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Codeception\Module\Symfony;
66

77
use PHPUnit\Framework\Constraint\Constraint;
8-
use PHPUnit\Framework\Constraint\LogicalAnd;
98
use PHPUnit\Framework\Constraint\LogicalNot;
109
use Symfony\Component\BrowserKit\Test\Constraint\BrowserCookieValueSame;
1110
use Symfony\Component\BrowserKit\Test\Constraint\BrowserHasCookie;
@@ -25,150 +24,147 @@
2524
trait BrowserAssertionsTrait
2625
{
2726
/**
28-
* Asserts the given cookie in the test Client is set to the expected value.
27+
* Asserts that the given cookie in the test client is set to the expected value.
2928
*/
3029
public function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', ?string $domain = null, string $message = ''): void
3130
{
32-
$this->assertThatForClient(LogicalAnd::fromConstraints(
33-
new BrowserHasCookie($name, $path, $domain),
34-
new BrowserCookieValueSame($name, $expectedValue, $raw, $path, $domain)
35-
), $message);
31+
$this->assertThatForClient(new BrowserHasCookie($name, $path, $domain), $message);
32+
$this->assertThatForClient(new BrowserCookieValueSame($name, $expectedValue, $raw, $path, $domain), $message);
3633
}
3734

3835
/**
39-
* Asserts that the test Client does have the given cookie set (meaning, the cookie was set by any response in the test).
36+
* Asserts that the test client has the specified cookie set.
37+
* This indicates that the cookie was set by any response during the test.
4038
*/
4139
public function assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
4240
{
4341
$this->assertThatForClient(new BrowserHasCookie($name, $path, $domain), $message);
4442
}
4543

4644
/**
47-
* Asserts that the test Client does not have the given cookie set (meaning, the cookie was set by any response in the test).
45+
* Asserts that the test client does not have the specified cookie set.
46+
* This indicates that the cookie was not set by any response during the test.
4847
*/
4948
public function assertBrowserNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
5049
{
5150
$this->assertThatForClient(new LogicalNot(new BrowserHasCookie($name, $path, $domain)), $message);
5251
}
5352

5453
/**
55-
* Asserts the given request attribute is set to the expected value.
54+
* Asserts that the specified request attribute matches the expected value.
5655
*/
5756
public function assertRequestAttributeValueSame(string $name, string $expectedValue, string $message = ''): void
5857
{
5958
$this->assertThat($this->getClient()->getRequest(), new RequestAttributeValueSame($name, $expectedValue), $message);
6059
}
6160

6261
/**
63-
* Asserts the given cookie is present and set to the expected value.
62+
* Asserts that the specified response cookie is present and matches the expected value.
6463
*/
6564
public function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = ''): void
6665
{
67-
$this->assertThatForResponse(LogicalAnd::fromConstraints(
68-
new ResponseHasCookie($name, $path, $domain),
69-
new ResponseCookieValueSame($name, $expectedValue, $path, $domain)
70-
), $message);
66+
$this->assertThatForResponse(new ResponseHasCookie($name, $path, $domain), $message);
67+
$this->assertThatForResponse(new ResponseCookieValueSame($name, $expectedValue, $path, $domain), $message);
7168
}
7269

7370
/**
74-
* Asserts the response format returned by the `Response::getFormat()` method is the same as the expected value.
71+
* Asserts that the response format matches the expected format. This checks the format returned by the `Response::getFormat()` method.
7572
*/
7673
public function assertResponseFormatSame(?string $expectedFormat, string $message = ''): void
7774
{
7875
$this->assertThatForResponse(new ResponseFormatSame($this->getClient()->getRequest(), $expectedFormat), $message);
7976
}
8077

8178
/**
82-
* Asserts the given cookie is present in the response (optionally checking for a specific cookie path or domain).
79+
* Asserts that the specified cookie is present in the response. Optionally, it can check for a specific cookie path or domain.
8380
*/
8481
public function assertResponseHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
8582
{
8683
$this->assertThatForResponse(new ResponseHasCookie($name, $path, $domain), $message);
8784
}
8885

8986
/**
90-
* Asserts the given header is available on the response, e.g. assertResponseHasHeader('content-type');.
87+
* Asserts that the specified header is available in the response.
88+
* For example, use `assertResponseHasHeader('content-type');`.
9189
*/
9290
public function assertResponseHasHeader(string $headerName, string $message = ''): void
9391
{
9492
$this->assertThatForResponse(new ResponseHasHeader($headerName), $message);
9593
}
9694

9795
/**
98-
* Asserts the given header does not contain the expected value on the response,
99-
* e.g. assertResponseHeaderNotSame('content-type', 'application/octet-stream');.
96+
* Asserts that the specified header does not contain the expected value in the response.
97+
* For example, use `assertResponseHeaderNotSame('content-type', 'application/octet-stream');`.
10098
*/
10199
public function assertResponseHeaderNotSame(string $headerName, string $expectedValue, string $message = ''): void
102100
{
103101
$this->assertThatForResponse(new LogicalNot(new ResponseHeaderSame($headerName, $expectedValue)), $message);
104102
}
105103

106104
/**
107-
* Asserts the given header does contain the expected value on the response,
108-
* e.g. assertResponseHeaderSame('content-type', 'application/octet-stream');.
105+
* Asserts that the specified header contains the expected value in the response.
106+
* For example, use `assertResponseHeaderSame('content-type', 'application/octet-stream');`.
109107
*/
110108
public function assertResponseHeaderSame(string $headerName, string $expectedValue, string $message = ''): void
111109
{
112110
$this->assertThatForResponse(new ResponseHeaderSame($headerName, $expectedValue), $message);
113111
}
114112

115113
/**
116-
* Asserts that the response was successful (HTTP status is 2xx).
114+
* Asserts that the response was successful (HTTP status code is in the 2xx range).
117115
*/
118116
public function assertResponseIsSuccessful(string $message = '', bool $verbose = true): void
119117
{
120118
$this->assertThatForResponse(new ResponseIsSuccessful($verbose), $message);
121119
}
122120

123121
/**
124-
* Asserts the response is unprocessable (HTTP status is 422)
122+
* Asserts that the response is unprocessable (HTTP status code is 422).
125123
*/
126124
public function assertResponseIsUnprocessable(string $message = '', bool $verbose = true): void
127125
{
128126
$this->assertThatForResponse(new ResponseIsUnprocessable($verbose), $message);
129127
}
130128

131129
/**
132-
* Asserts the given cookie is not present in the response (optionally checking for a specific cookie path or domain).
130+
* Asserts that the specified cookie is not present in the response. Optionally, it can check for a specific cookie path or domain.
133131
*/
134132
public function assertResponseNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
135133
{
136134
$this->assertThatForResponse(new LogicalNot(new ResponseHasCookie($name, $path, $domain)), $message);
137135
}
138136

139137
/**
140-
* Asserts the given header is not available on the response, e.g. assertResponseNotHasHeader('content-type');.
138+
* Asserts that the specified header is not available in the response.
139+
* For example, use `assertResponseNotHasHeader('content-type');`.
141140
*/
142141
public function assertResponseNotHasHeader(string $headerName, string $message = ''): void
143142
{
144143
$this->assertThatForResponse(new LogicalNot(new ResponseHasHeader($headerName)), $message);
145144
}
146145

147146
/**
148-
* Asserts the response is a redirect response (optionally, you can check the target location and status code).
149-
* The excepted location can be either an absolute or a relative path.
147+
* Asserts that the response is a redirect. Optionally, you can check the target location and status code.
148+
* The expected location can be either an absolute or a relative path.
150149
*/
151150
public function assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = '', bool $verbose = true): void
152151
{
153-
$constraint = new ResponseIsRedirected($verbose);
154-
if ($expectedLocation) {
155-
if (class_exists(ResponseHeaderLocationSame::class)) {
156-
$locationConstraint = new ResponseHeaderLocationSame($this->getClient()->getRequest(), $expectedLocation);
157-
} else {
158-
$locationConstraint = new ResponseHeaderSame('Location', $expectedLocation);
159-
}
152+
$this->assertThatForResponse(new ResponseIsRedirected($verbose), $message);
160153

161-
$constraint = LogicalAnd::fromConstraints($constraint, $locationConstraint);
154+
if ($expectedLocation) {
155+
$constraint = class_exists(ResponseHeaderLocationSame::class)
156+
? new ResponseHeaderLocationSame($this->getClient()->getRequest(), $expectedLocation)
157+
: new ResponseHeaderSame('Location', $expectedLocation);
158+
$this->assertThatForResponse($constraint, $message);
162159
}
160+
163161
if ($expectedCode) {
164-
$constraint = LogicalAnd::fromConstraints($constraint, new ResponseStatusCodeSame($expectedCode));
162+
$this->assertThatForResponse(new ResponseStatusCodeSame($expectedCode), $message);
165163
}
166-
167-
$this->assertThatForResponse($constraint, $message);
168164
}
169165

170166
/**
171-
* Asserts a specific HTTP status code.
167+
* Asserts that the response status code matches the expected code.
172168
*/
173169
public function assertResponseStatusCodeSame(int $expectedCode, string $message = '', bool $verbose = true): void
174170
{
@@ -178,23 +174,18 @@ public function assertResponseStatusCodeSame(int $expectedCode, string $message
178174
/**
179175
* Asserts the request matches the given route and optionally route parameters.
180176
*/
181-
public function assertRouteSame(string $expectedRoute, array $parameters = [], string $message = ''): void
182-
{
183-
$constraint = new RequestAttributeValueSame('_route', $expectedRoute);
184-
$constraints = [];
177+
public function assertRouteSame(string $expectedRoute, array $parameters = [], string $message = ''): void {
178+
$request = $this->getClient()->getRequest();
179+
$this->assertThat($request, new RequestAttributeValueSame('_route', $expectedRoute));
180+
185181
foreach ($parameters as $key => $value) {
186-
$constraints[] = new RequestAttributeValueSame($key, $value);
187-
}
188-
if ($constraints) {
189-
$constraint = LogicalAnd::fromConstraints($constraint, ...$constraints);
182+
$this->assertThat($request, new RequestAttributeValueSame($key, $value), $message);
190183
}
191-
192-
$this->assertThat($this->getClient()->getRequest(), $constraint, $message);
193184
}
194185

195186
/**
196-
* Reboot client's kernel.
197-
* Can be used to manually reboot kernel when 'rebootable_client' => false
187+
* Reboots the client's kernel.
188+
* Can be used to manually reboot the kernel when 'rebootable_client' is set to false.
198189
*
199190
* ```php
200191
* <?php
@@ -214,7 +205,7 @@ public function rebootClientKernel(): void
214205

215206
/**
216207
* Verifies that a page is available.
217-
* By default, it checks the current page, specify the `$url` parameter to change it.
208+
* By default, it checks the current page. Specify the `$url` parameter to change the page being checked.
218209
*
219210
* ```php
220211
* <?php
@@ -224,7 +215,7 @@ public function rebootClientKernel(): void
224215
* $I->seePageIsAvailable('/dashboard'); // Same as above
225216
* ```
226217
*
227-
* @param string|null $url
218+
* @param string|null $url The URL of the page to check. If null, the current page is checked.
228219
*/
229220
public function seePageIsAvailable(?string $url = null): void
230221
{
@@ -237,7 +228,7 @@ public function seePageIsAvailable(?string $url = null): void
237228
}
238229

239230
/**
240-
* Goes to a page and check that it redirects to another.
231+
* Navigates to a page and verifies that it redirects to another page.
241232
*
242233
* ```php
243234
* <?php
@@ -246,21 +237,24 @@ public function seePageIsAvailable(?string $url = null): void
246237
*/
247238
public function seePageRedirectsTo(string $page, string $redirectsTo): void
248239
{
249-
$this->getClient()->followRedirects(false);
240+
$client = $this->getClient();
241+
$client->followRedirects(false);
250242
$this->amOnPage($page);
251-
$response = $this->getClient()->getResponse();
243+
252244
$this->assertTrue(
253-
$response->isRedirection()
245+
$client->getResponse()->isRedirection(),
246+
'The response is not a redirection.'
254247
);
255-
$this->getClient()->followRedirect();
248+
249+
$client->followRedirect();
256250
$this->seeInCurrentUrl($redirectsTo);
257251
}
258252

259253
/**
260-
* Submit a form specifying the form name only once.
254+
* Submits a form by specifying the form name only once.
261255
*
262256
* Use this function instead of [`$I->submitForm()`](#submitForm) to avoid repeating the form name in the field selectors.
263-
* If you customized the names of the field selectors use `$I->submitForm()` for full control.
257+
* If you have customized the names of the field selectors, use `$I->submitForm()` for full control.
264258
*
265259
* ```php
266260
* <?php
@@ -270,8 +264,8 @@ public function seePageRedirectsTo(string $page, string $redirectsTo): void
270264
* ]);
271265
* ```
272266
*
273-
* @param string $name The `name` attribute of the `<form>` (you cannot use an array as selector here)
274-
* @param string[] $fields
267+
* @param string $name The `name` attribute of the `<form>`. You cannot use an array as a selector here.
268+
* @param array<string, mixed> $fields The form fields to submit.
275269
*/
276270
public function submitSymfonyForm(string $name, array $fields): void
277271
{

‎src/Codeception/Module/Symfony/DomCrawlerAssertionsTrait.php

+29-85
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,54 @@
44

55
namespace Codeception\Module\Symfony;
66

7-
use PHPUnit\Framework\Constraint\LogicalAnd;
7+
use PHPUnit\Framework\Constraint\Constraint;
88
use PHPUnit\Framework\Constraint\LogicalNot;
9-
use Symfony\Component\DomCrawler\Crawler;
10-
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerAnySelectorTextContains;
11-
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerAnySelectorTextSame;
129
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorAttributeValueSame;
13-
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorCount;
1410
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorExists;
1511
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorTextContains;
1612
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerSelectorTextSame;
1713

1814
trait DomCrawlerAssertionsTrait
1915
{
20-
/**
21-
* Asserts that any element matching the given selector does contain the expected text.
22-
*/
23-
public function assertAnySelectorTextContains(string $selector, string $text, string $message = ''): void
24-
{
25-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
26-
new CrawlerSelectorExists($selector),
27-
new CrawlerAnySelectorTextContains($selector, $text)
28-
), $message);
29-
}
30-
31-
/**
32-
* Asserts that any element matching the given selector does not contain the expected text.
33-
*/
34-
public function assertAnySelectorTextNotContains(string $selector, string $text, string $message = ''): void
35-
{
36-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
37-
new CrawlerSelectorExists($selector),
38-
new LogicalNot(new CrawlerAnySelectorTextContains($selector, $text))
39-
), $message);
40-
}
41-
42-
/**
43-
* Asserts that any element matching the given selector does equal the expected text.
44-
*/
45-
public function assertAnySelectorTextSame(string $selector, string $text, string $message = ''): void
46-
{
47-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
48-
new CrawlerSelectorExists($selector),
49-
new CrawlerAnySelectorTextSame($selector, $text)
50-
), $message);
51-
}
52-
5316
/**
5417
* Asserts that the checkbox with the given name is checked.
5518
*/
5619
public function assertCheckboxChecked(string $fieldName, string $message = ''): void
5720
{
58-
$this->assertThat(
59-
$this->getCrawler(),
60-
new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"),
61-
$message
62-
);
21+
$this->assertThatCrawler(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked"), $message);
6322
}
6423

6524
/**
6625
* Asserts that the checkbox with the given name is not checked.
6726
*/
6827
public function assertCheckboxNotChecked(string $fieldName, string $message = ''): void
6928
{
70-
$this->assertThat(
71-
$this->getCrawler(),
72-
new LogicalNot(new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")),
73-
$message
74-
);
29+
$this->assertThatCrawler(new LogicalNot(
30+
new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")
31+
), $message);
7532
}
7633

7734
/**
78-
* Asserts that value of the form input with the given name does not equal the expected value.
35+
* Asserts that the value of the form input with the given name does not equal the expected value.
7936
*/
8037
public function assertInputValueNotSame(string $fieldName, string $expectedValue, string $message = ''): void
8138
{
82-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
83-
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
84-
new LogicalNot(new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue))
39+
$this->assertThatCrawler(new CrawlerSelectorExists("input[name=\"$fieldName\"]"), $message);
40+
$this->assertThatCrawler(new LogicalNot(
41+
new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue)
8542
), $message);
8643
}
8744

8845
/**
89-
* Asserts that value of the form input with the given name does equal the expected value.
46+
* Asserts that the value of the form input with the given name equals the expected value.
9047
*/
9148
public function assertInputValueSame(string $fieldName, string $expectedValue, string $message = ''): void
9249
{
93-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
94-
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
95-
new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue)
96-
), $message);
50+
$this->assertThatCrawler(new CrawlerSelectorExists("input[name=\"$fieldName\"]"), $message);
51+
$this->assertThatCrawler(
52+
new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue),
53+
$message
54+
);
9755
}
9856

9957
/**
@@ -105,72 +63,58 @@ public function assertPageTitleContains(string $expectedTitle, string $message =
10563
}
10664

10765
/**
108-
* Asserts that the `<title>` element is equal to the given title.
66+
* Asserts that the `<title>` element equals the given title.
10967
*/
11068
public function assertPageTitleSame(string $expectedTitle, string $message = ''): void
11169
{
11270
$this->assertSelectorTextSame('title', $expectedTitle, $message);
11371
}
11472

11573
/**
116-
* Asserts that the expected number of selector elements are in the response.
117-
*/
118-
public function assertSelectorCount(int $expectedCount, string $selector, string $message = ''): void
119-
{
120-
$this->assertThat($this->getCrawler(), new CrawlerSelectorCount($expectedCount, $selector), $message);
121-
}
122-
123-
/**
124-
* Asserts that the given selector does match at least one element in the response.
74+
* Asserts that the given selector matches at least one element in the response.
12575
*/
12676
public function assertSelectorExists(string $selector, string $message = ''): void
12777
{
128-
$this->assertThat($this->getCrawler(), new CrawlerSelectorExists($selector), $message);
78+
$this->assertThatCrawler(new CrawlerSelectorExists($selector), $message);
12979
}
13080

13181
/**
13282
* Asserts that the given selector does not match at least one element in the response.
13383
*/
13484
public function assertSelectorNotExists(string $selector, string $message = ''): void
13585
{
136-
$this->assertThat($this->getCrawler(), new LogicalNot(new CrawlerSelectorExists($selector)), $message);
86+
$this->assertThatCrawler(new LogicalNot(new CrawlerSelectorExists($selector)), $message);
13787
}
13888

13989
/**
140-
* Asserts that the first element matching the given selector does contain the expected text.
90+
* Asserts that the first element matching the given selector contains the expected text.
14191
*/
14292
public function assertSelectorTextContains(string $selector, string $text, string $message = ''): void
14393
{
144-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
145-
new CrawlerSelectorExists($selector),
146-
new CrawlerSelectorTextContains($selector, $text)
147-
), $message);
94+
$this->assertThatCrawler(new CrawlerSelectorExists($selector), $message);
95+
$this->assertThatCrawler(new CrawlerSelectorTextContains($selector, $text), $message);
14896
}
14997

15098
/**
15199
* Asserts that the first element matching the given selector does not contain the expected text.
152100
*/
153101
public function assertSelectorTextNotContains(string $selector, string $text, string $message = ''): void
154102
{
155-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
156-
new CrawlerSelectorExists($selector),
157-
new LogicalNot(new CrawlerSelectorTextContains($selector, $text))
158-
), $message);
103+
$this->assertThatCrawler(new CrawlerSelectorExists($selector), $message);
104+
$this->assertThatCrawler(new LogicalNot(new CrawlerSelectorTextContains($selector, $text)), $message);
159105
}
160106

161107
/**
162-
* Asserts that the contents of the first element matching the given selector does equal the expected text.
108+
* Asserts that the text of the first element matching the given selector equals the expected text.
163109
*/
164110
public function assertSelectorTextSame(string $selector, string $text, string $message = ''): void
165111
{
166-
$this->assertThat($this->getCrawler(), LogicalAnd::fromConstraints(
167-
new CrawlerSelectorExists($selector),
168-
new CrawlerSelectorTextSame($selector, $text)
169-
), $message);
112+
$this->assertThatCrawler(new CrawlerSelectorExists($selector), $message);
113+
$this->assertThatCrawler(new CrawlerSelectorTextSame($selector, $text), $message);
170114
}
171115

172-
protected function getCrawler(): Crawler
116+
protected function assertThatCrawler(Constraint $constraint, string $message): void
173117
{
174-
return $this->client->getCrawler();
118+
$this->assertThat($this->getClient()->getCrawler(), $constraint, $message);
175119
}
176120
}

‎src/Codeception/Module/Symfony/FormAssertionsTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait FormAssertionsTrait
1717
*/
1818
public function assertFormValue(string $formSelector, string $fieldName, string $value, string $message = ''): void
1919
{
20-
$node = $this->getCrawler()->filter($formSelector);
20+
$node = $this->getCLient()->getCrawler()->filter($formSelector);
2121
$this->assertNotEmpty($node, sprintf('Form "%s" not found.', $formSelector));
2222
$values = $node->form()->getValues();
2323
$this->assertArrayHasKey($fieldName, $values, $message ?: sprintf('Field "%s" not found in form "%s".', $fieldName, $formSelector));
@@ -29,7 +29,7 @@ public function assertFormValue(string $formSelector, string $fieldName, string
2929
*/
3030
public function assertNoFormValue(string $formSelector, string $fieldName, string $message = ''): void
3131
{
32-
$node = $this->getCrawler()->filter($formSelector);
32+
$node = $this->getCLient()->getCrawler()->filter($formSelector);
3333
$this->assertNotEmpty($node, sprintf('Form "%s" not found.', $formSelector));
3434
$values = $node->form()->getValues();
3535
$this->assertArrayNotHasKey($fieldName, $values, $message ?: sprintf('Field "%s" has a value in form "%s".', $fieldName, $formSelector));

0 commit comments

Comments
 (0)
Please sign in to comment.