Join GitHub today
Add missing PHPUnit tests to Travis CI #1540
Travis CI builds are not executing all of the defined PHPUnit test suites : IssueHistoryTest and REST tests are not executed.
This PR makes changes to both the PHPUnit scripts and the Travis configuration, to ensure all tests are run and we don't have skipped tests either.
@vboctor I need some help with this one.
One of the REST tests is still failing (RestIssueAddTest::testCreateIssueWithTags) and I do not know how to fix that. I do not understand why the issue body is returned as NULL, when as far as I can tell we're executing the same command as in other test cases (e.g. testCreateIssueWithVersionObjectId), and the body is set correctly in that case.
Also, I had to comment out some of the assertions in testCreateIssueWithTagIdNotFound and testCreateIssueNoSummary, because the REST API returns a 404 as expected, but I have no way of retrieving the created issue so I have nothing to compare against.
@dregad This is probably caused by a bug in the
@vboctor that was it indeed ! Thanks for pointing me in the right direction.
The code in IssueAddCommand is accessing $t_tag['id'] without first checking that the key exists, so when a tag is provided only by name, PHP throws a NOTICE causing the API to return an invalid JSON response (there is an HTML error message appended to it).
I logged https://mantisbt.org/bugs/view.php?id=25997 to track the bug.
You have not responded to the other issue I am facing
IMO, this is a design flaw of the API's current implementation, which first creates the issue, then creates/attaches tags to it as a separate, second step.
Would it be the correct approach, to execute in IssueAddCommand::validate(), the same checks on tags to attach, as in mci_tag_set_for_issue() ?
If yes, in the interest of avoiding duplication, this code should be moved to a function; any advice on where to put it ?
When creating an issue with non-default status/resolution, check that a single entry is created. Fixes #25962
Dynamically generate an API token for the administrator user to execute the REST API test suite.
Prior to this, the tests were written to use harcoded version numbers and ids taken from mantisbt.org database. Now we retrieve versions from the database; there must be at least 3 defined versions for the test project.
The assertion is now conditional, based on how $g_allow_no_category is set. This option defaults to OFF, but Travis builds set it to ON to avoid skipping tests in SOAP suite.
Prior to this, date order was set to a hardcoded timestamp. This caused testAddVersion to fail if there were any existing Version records in the database having a more recent date order more recent. To fix the problem, the DATE_ORDER constant has been replaced by a $date_order class property, set to current date/time when the test suite starts.