Skip to content

Commit 9d522a7

Browse files
committed
SonarCube Code Reduction: 3
1 parent 1c22318 commit 9d522a7

10 files changed

Lines changed: 183 additions & 185 deletions

Tests/Functional/ContactControllerCest.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,92 @@ class ContactControllerCest
1212

1313
public string $testUser = 'Test User';
1414

15-
public function testInterestPageLoads(FunctionalTester $functionalTester): void
15+
public function testInterestPageLoads(FunctionalTester $tester): void
1616
{
17-
$functionalTester->wantTo('see the contact interest page loads');
18-
$functionalTester->amOnPage($this->interest);
19-
$functionalTester->seeResponseCodeIs(200);
20-
$functionalTester->seeInSource('name');
21-
$functionalTester->seeInSource('email');
22-
$functionalTester->seeInSource('subject');
23-
$functionalTester->seeInSource('body');
17+
$tester->wantTo('see the contact interest page loads');
18+
$tester->amOnPage($this->interest);
19+
$tester->seeResponseCodeIs(200);
20+
$tester->seeInSource('name');
21+
$tester->seeInSource('email');
22+
$tester->seeInSource('subject');
23+
$tester->seeInSource('body');
2424
}
2525

26-
public function testInterestFormValidation(FunctionalTester $functionalTester): void
26+
public function testInterestFormValidation(FunctionalTester $tester): void
2727
{
28-
$functionalTester->wantTo('test contact form validation');
29-
$functionalTester->amOnPage($this->interest);
30-
$functionalTester->seeResponseCodeIs(200);
28+
$tester->wantTo('test contact form validation');
29+
$tester->amOnPage($this->interest);
30+
$tester->seeResponseCodeIs(200);
3131

3232
// Submit empty form to test validation
33-
if ($functionalTester->seeElement('form')) {
34-
$functionalTester->submitForm('form', []);
35-
$functionalTester->seeResponseCodeIs(200);
33+
if ($tester->seeElement('form')) {
34+
$tester->submitForm('form', []);
35+
$tester->seeResponseCodeIs(200);
3636
// Should stay on the same page with validation errors
3737
}
3838
}
3939

40-
public function testInterestFormWithValidData(FunctionalTester $functionalTester): void
40+
public function testInterestFormWithValidData(FunctionalTester $tester): void
4141
{
42-
$functionalTester->wantTo('test contact form with valid data');
43-
$functionalTester->amOnPage($this->interest);
44-
$functionalTester->seeResponseCodeIs(200);
42+
$tester->wantTo('test contact form with valid data');
43+
$tester->amOnPage($this->interest);
44+
$tester->seeResponseCodeIs(200);
4545

4646
// Try to submit form with valid data
47-
if ($functionalTester->seeElement('form')) {
48-
$functionalTester->submitForm('form', [
47+
if ($tester->seeElement('form')) {
48+
$tester->submitForm('form', [
4949
'ContactForm[name]' => $this->testUser,
5050
'ContactForm[email]' => 'test@example.com',
5151
'ContactForm[subject]' => 'Test Subject',
5252
'ContactForm[body]' => 'This is a test message'
5353
]);
5454
// Should redirect or show success - either way not an error
55-
$functionalTester->dontSeeResponseCodeIs(500);
55+
$tester->dontSeeResponseCodeIs(500);
5656
}
5757
}
5858

59-
public function testInterestFormWithInvalidEmail(FunctionalTester $functionalTester): void
59+
public function testInterestFormWithInvalidEmail(FunctionalTester $tester): void
6060
{
61-
$functionalTester->wantTo('test contact form with invalid email');
62-
$functionalTester->amOnPage($this->interest);
63-
$functionalTester->seeResponseCodeIs(200);
61+
$tester->wantTo('test contact form with invalid email');
62+
$tester->amOnPage($this->interest);
63+
$tester->seeResponseCodeIs(200);
6464

6565
// Submit form with invalid email
66-
if ($functionalTester->seeElement('form')) {
67-
$functionalTester->submitForm('form', [
66+
if ($tester->seeElement('form')) {
67+
$tester->submitForm('form', [
6868
'ContactForm[name]' => $this->testUser,
6969
'ContactForm[email]' => 'invalid-email',
7070
'ContactForm[subject]' => 'Test Subject',
7171
'ContactForm[body]' => 'This is a test message'
7272
]);
73-
$functionalTester->seeResponseCodeIs(200);
73+
$tester->seeResponseCodeIs(200);
7474
// Should stay on page with validation error
7575
}
7676
}
7777

78-
public function testInterestFormMissingRequiredFields(FunctionalTester $functionalTester): void
78+
public function testInterestFormMissingRequiredFields(FunctionalTester $tester): void
7979
{
80-
$functionalTester->wantTo('test contact form with missing required fields');
81-
$functionalTester->amOnPage($this->interest);
82-
$functionalTester->seeResponseCodeIs(200);
80+
$tester->wantTo('test contact form with missing required fields');
81+
$tester->amOnPage($this->interest);
82+
$tester->seeResponseCodeIs(200);
8383

8484
// Submit form with only partial data
85-
if ($functionalTester->seeElement('form')) {
86-
$functionalTester->submitForm('form', [
85+
if ($tester->seeElement('form')) {
86+
$tester->submitForm('form', [
8787
'ContactForm[name]' => 'Test User',
8888
'ContactForm[email]' => 'test@example.com'
8989
// Missing subject and body
9090
]);
91-
$functionalTester->seeResponseCodeIs(200);
91+
$tester->seeResponseCodeIs(200);
9292
// Should stay on page with validation errors
9393
}
9494
}
9595

96-
public function testInterestGetRequest(FunctionalTester $functionalTester): void
96+
public function testInterestGetRequest(FunctionalTester $tester): void
9797
{
98-
$functionalTester->wantTo('test GET request to interest page');
99-
$functionalTester->amOnPage($this->interest);
100-
$functionalTester->seeResponseCodeIs(200);
101-
$functionalTester->seeInSource('contact');
98+
$tester->wantTo('test GET request to interest page');
99+
$tester->amOnPage($this->interest);
100+
$tester->seeResponseCodeIs(200);
101+
$tester->seeInSource('contact');
102102
}
103103
}

0 commit comments

Comments
 (0)