Repository navigation
Test Case Linking Fix
Fixed critical bug: Application crash when linking test cases to requirements with INACTIVE versions.
When attempting to link a test case to a requirement, the application would crash if the test case's latest version was marked as INACTIVE.
Fatal error: Call to a member function on null
In lib/functions/requirement_mgr.class.php, the assign_to_tcase() function did not validate whether the latest test case version was active before attempting to use it.
The code would:
- Call
get_last_active_version()to retrieve the latest active version - NOT check if the result was null
- Attempt to access properties on a null value → CRASH
Added early validation to check if the latest test case version is INACTIVE:
// Get Latest Active Test Case Version
$tcv = current($tcMgr->get_last_active_version($testcase_id));
if ($tcv == null) {
// Latest version is Inactive => operation not allowed
return $output;
}Behavior:
- If latest test case version is INACTIVE → return with no link created
- If latest test case version is ACTIVE → proceed with linking
- No error/exception thrown → graceful handling
lib/functions/requirement_mgr.class.php- Function:
assign_to_tcase()
function assign_to_tcase($req_id, $testcase_id, $author_id) {
$tcMgr = new testcase($this->db);
// Check if test case version is active FIRST
if ($testcase_id && $req_id) {
$tcv = current($tcMgr->get_last_active_version($testcase_id));
if ($tcv == null) {
// Latest version is Inactive => operation not allowed
return 0; // Return early, no link created
}
}
// Go ahead with requirement linking...
if ($testcase_id && $req_id) {
// ... rest of linking logic ...
}
}✅ WORKS: Test case latest version is ACTIVE
→ Requirement successfully linked
⚠️ BLOCKED: Test case latest version is INACTIVE
→ Operation returns silently (graceful failure)
→ No crash
→ No link created
- ❌ Application crashes
- ❌ Error page displayed
- ❌ Session may be interrupted
- ✅ Operation handled gracefully
- ✅ No error message (silent failure)
- ✅ User can continue working
- ℹ️ User should activate test case version first
-
Create Test Case
- New test cases are ACTIVE by default
-
Link to Requirement
- Click requirement → "Link to Test Case"
- Select test case
- Link created successfully ✅
-
Deactivate Test Case (if needed)
- Change test case status to INACTIVE
- Existing requirement links remain
- Cannot create NEW links until reactivated
-
Reactivate Test Case
- Change status back to ACTIVE
- Can link to new requirements again ✅
Preconditions:
- Test case exists with ACTIVE version
- Requirement exists
Steps:
1. Navigate to requirement
2. Click "Link Test Case"
3. Select active test case
4. Click "Link"
Expected Result:
✅ Link created successfully
✅ No errors
Preconditions:
- Test case exists with INACTIVE version
- Requirement exists
Steps:
1. Navigate to requirement
2. Click "Link Test Case"
3. Select inactive test case
4. Click "Link"
Expected Result:
✅ Operation completes
✅ No crash/error
✅ No link created
ℹ️ May show info message (optional enhancement)
Preconditions:
- Test case has multiple versions
- Latest version is INACTIVE
- Earlier versions are ACTIVE
Expected Result:
✅ Operation blocked (uses latest version check)
✅ User must activate latest version to link
-
User Feedback
if ($tcv == null) { // Add message return ['status' => 'error', 'message' => lang_get('test_case_inactive')]; }
-
Automatic Version Activation
- Option to auto-activate when linking
-
UI Indication
- Show INACTIVE status in test case selector
- Disable selection of inactive versions
-
Logging
- Log failed link attempts
- Track inactive test case linking attempts
- Test Case Versioning: Developer-Guide
- Requirement Management: File-Import-Export
- Status Management: Test case lifecycle
requirement_mgr::assign_to_tcase()requirement_mgr::create_tc_from_requirement()
-
testcase::get_last_active_version()- Gets latest ACTIVE version -
testcase::getActiveStatus()- Checks if version is active
- Commit ID: b0dd23a70
- Message: "fix: logic to avoid crash when trying to add req link to a test case that has latest version INACTIVE"
- Status: ✅ Already integrated in sebiboga branch
- GitHub Issue: #138
- Original commit (sebiboga_2.0): e57510a84
- Current branch: sebiboga (b0dd23a70)
Status: ✅ Fixed
Issue: #138
Type: Critical Bug Fix
Severity: High
Impact: Zero breaking changes