View Issue Details

IDProjectCategoryView StatusLast Update
0033374mantisbtotherpublic2024-02-20 16:58
Reporterdregad Assigned Todregad  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version2.26.0 
Target Version2.26.1Fixed in Version2.26.1 
Summary0033374: Erratic behavior of RestProjectVersionTest::testProjectUpdateVersion PHPUnit test case
Description

This test case occasionally fails, without any significant change in the code:

For example, compare this recent build of master branch which completed successfully:
https://app.travis-ci.com/github/mantisbt/mantisbt/jobs/613971950

OK (379 tests, 1619 assertions)

With the build for PR https://github.com/mantisbt/mantisbt/pull/1942 which just updates a library that is not used in any of the unit tests:
https://app.travis-ci.com/github/mantisbt/mantisbt/jobs/613535442

There was 1 failure:
1) RestProjectVersionTest::testProjectUpdateVersion
Failed asserting that false is true.
/home/travis/build/mantisbt/mantisbt/tests/rest/RestProjectVersionTest.php:298
TagsNo tags attached.

Relationships

related to 0030415 closedvboctor REST API: Add API to Get / Delete / Update versions 

Activities

dregad

dregad

2023-12-01 17:46

developer   ~0068367

The assertion to test the version update (PATCH request) is incorrectly setting the timestamp in the updated version data as a Unix timestamp instead of a date string that can be parsed by strtotime().

Depending on the current time, the timestamp is sometimes converted by the strtotime() call in VersionUpdateCommand to a date that is not supported by the database, which causes the SQL UPDATE statement in version_update() to fail.

For example:

$t = 1701451181;
echo strtotime(); // -24869487495
print_r(date_parse($t));

Array
(
    [year] => 1181
    [month] => 
    [day] => 
    [hour] => 17
    [minute] => 1
    [second] => 45
    [fraction] => 0
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)
dregad

dregad

2023-12-01 17:50

developer   ~0068368

Incorrect logic in test case was introduced by commit MantisBT master 5caafd27 (see 0030415).

Related Changesets

MantisBT: master 5caafd27

2023-04-22 19:35

vboctor


Details Diff
Add test cases for project version APIs + fixes

Fixes 0030415
Affected Issues
0030415, 0033374
mod - api/rest/restcore/projects_rest.php Diff File
mod - core/commands/VersionAddCommand.php Diff File
mod - core/commands/VersionGetCommand.php Diff File
mod - core/commands/VersionUpdateCommand.php Diff File
mod - core/version_api.php Diff File
mod - manage_proj_ver_add.php Diff File
mod - manage_proj_ver_delete.php Diff File
mod - tests/core/RequestBuilder.php Diff File
mod - tests/rest/RestBase.php Diff File
add - tests/rest/RestProjectVersionTests.php Diff File

MantisBT: master-2.26 37930c92

2023-12-01 17:51

dregad


Details Diff
Fix testProjectUpdateVersion()

The assertion to test the version update (PATCH request) was incorrectly
setting the timestamp in the updated version data as a Unix timestamp
instead of a date string to be parsed by strtotime().

Depending on the current time, the timestamp is sometimes converted by
the strtotime() call in VersionUpdateCommand to a date that is not
supported by the database which causes the SQL UPDATE statement in
version_update() to fail.

Fixes 0033374
Affected Issues
0033374
mod - tests/rest/RestProjectVersionTest.php Diff File