Problem/Motivation
In #3100386: Create contrib update module test cases that use semantic versioning @dww pointed out that in this snippet from testNormalUpdateAvailable
switch ($minor_version) {
case 0:
// Both stable and unstable releases are available.
// A stable release is the latest.
if ($extra_version == '') {
$this->assertUpdateTableTextNotContains('Up to date');
$this->assertUpdateTableTextContains('Update available');
$this->assertVersionUpdateLinks('Recommended version:', $full_version);
$this->assertUpdateTableTextNotContains('Latest version:');
$this->assertUpdateTableElementContains('warning.svg');
}
// Only unstable releases are available.
// An unstable release is the latest.
else {
$this->assertUpdateTableTextContains('Up to date');
$this->assertUpdateTableTextNotContains('Update available');
$this->assertUpdateTableTextNotContains('Recommended version:');
$this->assertVersionUpdateLinks('Latest version:', $full_version);
$this->assertUpdateTableElementContains('check.svg');
}
break;
case 1:
// Both stable and unstable releases are available.
// A stable release is the latest.
if ($extra_version == '') {
$this->assertUpdateTableTextNotContains('Up to date');
$this->assertUpdateTableTextContains('Update available');
$this->assertVersionUpdateLinks('Recommended version:', $full_version);
$this->assertUpdateTableTextNotContains('Latest version:');
$this->assertUpdateTableElementContains('warning.svg');
}
// Both stable and unstable releases are available.
// An unstable release is the latest.
else {
$this->assertUpdateTableTextNotContains('Up to date');
$this->assertUpdateTableTextContains('Update available');
$this->assertVersionUpdateLinks('Recommended version:', '8.1.0');
$this->assertVersionUpdateLinks('Latest version:', $full_version);
$this->assertUpdateTableElementContains('warning.svg');
}
break;
}
The portion
if ($extra_version == '') {
$this->assertUpdateTableTextNotContains('Up to date');
$this->assertUpdateTableTextContains('Update available');
$this->assertVersionUpdateLinks('Recommended version:', $full_version);
$this->assertUpdateTableTextNotContains('Latest version:');
$this->assertUpdateTableElementContains('warning.svg');
}
Is a duplicates and could be moved out of the switch.
Since code was just being copied in that issue it was out of scope.
Proposed resolution
Move duplicate to a method
Remaining tasks
User interface changes
None
API changes
none
Data model changes
none
Release notes snippet
none
Issue fork drupal-3205912
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3205912-remove-11.x
changes, plain diff MR !7566
- 3205912-remove-duplication-section
changes, plain diff MR !1357
Comments
Comment #2
tedbowJust regular postponed
Comment #10
quietone commentedComment #13
quietone commentedI closed the empty MR 1357.
Oops, this was novice and I didn't notice. Sorry!
Comment #14
smustgrave commentedMoving seems fine.
Comment #15
alexpottCommitted 8a67d67 and pushed to 11.x. Thanks!
Committed 0ec61e3 and pushed to 10.3.x. Thanks!