Skip to content

Commit f95f94b

Browse files
carusogabrielDavertMik
authored andcommitted
Use dedicated PHPUnit assertions (#4950)
1 parent c044b44 commit f95f94b

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

tests/unit/Codeception/Module/TestsForWeb.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,10 +1042,10 @@ public function testSubmitForm()
10421042
$form = data::get('form');
10431043
$this->assertEquals('Davert', $form['name']);
10441044
$this->assertEquals('Is Codeception maintainer', $form['description']);
1045-
$this->assertFalse(isset($form['disabled_fieldset']));
1046-
$this->assertFalse(isset($form['disabled_fieldset_textarea']));
1047-
$this->assertFalse(isset($form['disabled_fieldset_select']));
1048-
$this->assertFalse(isset($form['disabled_field']));
1045+
$this->assertArrayNotHasKey('disabled_fieldset', $form);
1046+
$this->assertArrayNotHasKey('disabled_fieldset_textarea', $form);
1047+
$this->assertArrayNotHasKey('disabled_fieldset_select', $form);
1048+
$this->assertArrayNotHasKey('disabled_field', $form);
10491049
$this->assertEquals('kill_all', $form['action']);
10501050
}
10511051

@@ -1209,8 +1209,8 @@ public function testSubmitFormWithTwoSubmitButtonsSubmitsCorrectValue()
12091209
$this->module->seeElement("#button2");
12101210
$this->module->click("#button2");
12111211
$form = data::get('form');
1212-
$this->assertTrue(isset($form['button2']));
1213-
$this->assertTrue(isset($form['username']));
1212+
$this->assertArrayHasKey('button2', $form);
1213+
$this->assertArrayHasKey('username', $form);
12141214
$this->assertEquals('value2', $form['button2']);
12151215
$this->assertEquals('fred', $form['username']);
12161216
}
@@ -1224,8 +1224,8 @@ public function testSubmitFormWithTwoSubmitButtonsSubmitsCorrectValueAfterFillFi
12241224
$this->module->fillField("username", "bob");
12251225
$this->module->click("#button2");
12261226
$form = data::get('form');
1227-
$this->assertTrue(isset($form['button2']));
1228-
$this->assertTrue(isset($form['username']));
1227+
$this->assertArrayHasKey('button2', $form);
1228+
$this->assertArrayHasKey('username', $form);
12291229
$this->assertEquals('value2', $form['button2']);
12301230
$this->assertEquals('bob', $form['username']);
12311231
}
@@ -1268,8 +1268,8 @@ public function testSubmitFormWithDefaultRadioAndCheckboxValues()
12681268
'test' => 'value'
12691269
));
12701270
$form = data::get('form');
1271-
$this->assertTrue(isset($form['checkbox1']), 'Checkbox value not sent');
1272-
$this->assertTrue(isset($form['radio1']), 'Radio button value not sent');
1271+
$this->assertArrayHasKey('checkbox1', $form, 'Checkbox value not sent');
1272+
$this->assertArrayHasKey('radio1', $form, 'Radio button value not sent');
12731273
$this->assertEquals('testing', $form['checkbox1']);
12741274
$this->assertEquals('to be sent', $form['radio1']);
12751275
}
@@ -1281,15 +1281,15 @@ public function testSubmitFormCheckboxWithBoolean()
12811281
'checkbox1' => true
12821282
));
12831283
$form = data::get('form');
1284-
$this->assertTrue(isset($form['checkbox1']), 'Checkbox value not sent');
1284+
$this->assertArrayHasKey('checkbox1', $form, 'Checkbox value not sent');
12851285
$this->assertEquals('testing', $form['checkbox1']);
12861286

12871287
$this->module->amOnPage('/form/example16');
12881288
$this->module->submitForm('form', array(
12891289
'checkbox1' => false
12901290
));
12911291
$form = data::get('form');
1292-
$this->assertFalse(isset($form['checkbox1']), 'Checkbox value sent');
1292+
$this->assertArrayNotHasKey('checkbox1', $form, 'Checkbox value sent');
12931293
}
12941294

12951295
public function testSubmitFormWithCheckboxesWithoutValue()
@@ -1320,7 +1320,7 @@ public function testSubmitFormWithButtons()
13201320
isset($form['button1']) || isset($form['button2']) || isset($form['button4']),
13211321
'Button values for buttons 1, 2 and 4 should not be set'
13221322
);
1323-
$this->assertTrue(isset($form['button3']), 'Button value for button3 should be set');
1323+
$this->assertArrayHasKey('button3', $form, 'Button value for button3 should be set');
13241324
$this->assertEquals($form['button3'], 'third', 'Button value for button3 should equal third');
13251325

13261326
$this->module->amOnPage('/form/form_with_buttons');
@@ -1332,7 +1332,7 @@ public function testSubmitFormWithButtons()
13321332
isset($form['button1']) || isset($form['button2']) || isset($form['button3']),
13331333
'Button values for buttons 1, 2 and 3 should not be set'
13341334
);
1335-
$this->assertTrue(isset($form['button4']), 'Button value for button4 should be set');
1335+
$this->assertArrayHasKey('button4', $form, 'Button value for button4 should be set');
13361336
$this->assertEquals($form['button4'], 'fourth', 'Button value for button4 should equal fourth');
13371337
}
13381338

@@ -1441,8 +1441,8 @@ public function testSubmitAdjacentForms()
14411441
$this->module->amOnPage('/form/submit_adjacentforms');
14421442
$this->module->submitForm('#form-2', []);
14431443
$data = data::get('form');
1444-
$this->assertTrue(isset($data['second-field']));
1445-
$this->assertFalse(isset($data['first-field']));
1444+
$this->assertArrayHasKey('second-field', $data);
1445+
$this->assertArrayNotHasKey('first-field', $data);
14461446
$this->assertEquals('Killgore Trout', $data['second-field']);
14471447
}
14481448

@@ -1453,17 +1453,17 @@ public function testSubmitAdjacentFormsByButton()
14531453
$this->module->fillField('second-field', 'Second');
14541454
$this->module->click('#submit1');
14551455
$data = data::get('form');
1456-
$this->assertTrue(isset($data['first-field']));
1457-
$this->assertFalse(isset($data['second-field']));
1456+
$this->assertArrayHasKey('first-field', $data);
1457+
$this->assertArrayNotHasKey('second-field', $data);
14581458
$this->assertEquals('First', $data['first-field']);
14591459

14601460
$this->module->amOnPage('/form/submit_adjacentforms');
14611461
$this->module->fillField('first-field', 'First');
14621462
$this->module->fillField('second-field', 'Second');
14631463
$this->module->click('#submit2');
14641464
$data = data::get('form');
1465-
$this->assertFalse(isset($data['first-field']));
1466-
$this->assertTrue(isset($data['second-field']));
1465+
$this->assertArrayNotHasKey('first-field', $data);
1466+
$this->assertArrayHasKey('second-field', $data);
14671467
$this->assertEquals('Second', $data['second-field']);
14681468
}
14691469

0 commit comments

Comments
 (0)