View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035258 | mantisbt | other | public | 2025-01-25 12:23 | 2025-01-31 10:47 |
Reporter | dregad | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | sometimes |
Status | resolved | Resolution | fixed | ||
Product Version | 2.28.0 | ||||
Target Version | 2.28.0 | Fixed in Version | 2.28.0 | ||
Summary | 0035258: Use of PHPUnit::toString() sometimes causes errors in tests | ||||
Description | toString() uses a fully qualified class name, and also appends details about test data which can easily result in fairly long strings. When it is too big to store in the underlying column, the test errors out: Database query failed: Data too long for column 'name' at row 1 This happened to me with RestFiltersTest::testGetIssuesMatchingFilter(), while running the test suite after adding namespaces to the test scripts - mantis_filter_table.name is VARCHAR(64). | ||||
Tags | No tags attached. | ||||
@raspopov FYI - toString seemed to be a good idea at first, but considering this, and the fact that it is also a PHPUnit internal method just like getName() / name(), we might as well use our own function using the latter after all... |
|
That's the best I could come up with: |
|
Thanks for the feedback. I considered using debug_backtrace() as well, but the problem is that the first parent in the call stack is not necessarily the test case, there could be intermediate helper methods in between. I didn't try, but I guess we could walk the stack backwards until we get the first function called by PHPUnit's TestCase class... Anyway, considering that PHPUnit's getName()/name() have been pretty stable for many years, despite them being internal methods, I'd rather stick to using them and adapt our code if and when it changes again in the future. I have included a fix for this in PR https://github.com/mantisbt/mantisbt/pull/2082 |
|
MantisBT: master 616d9bd0 2025-01-25 12:33 Details Diff |
New MantisTestCase::getTestName() method Used instead of PHPUnit TestCase::toString(). Avoids error on RestFiltersTest::testGetIssuesMatchingFilter(): Database query failed: Data too long for column 'name' at row 1 Fixes 0035258 |
Affected Issues 0035258 |
|
mod - tests/core/MantisTestCase.php | Diff File | ||
mod - tests/rest/RestBase.php | Diff File | ||
mod - tests/rest/RestFiltersTest.php | Diff File | ||
mod - tests/soap/ProjectTest.php | Diff File | ||
mod - tests/soap/SoapBase.php | Diff File | ||
MantisBT: master 5b4f46b2 2025-01-31 10:47 Details Diff |
Add namespaces to PHPUnit test suite Fixes 0035259, 0035258 Merge PR https://github.com/mantisbt/mantisbt/pull/2082 |
Affected Issues 0035258, 0035259 |
|
mod - composer.json | Diff File | ||
mod - composer.lock | Diff File | ||
mod - tests/Mantis/ConfigParserTest.php | Diff File | ||
mod - tests/Mantis/Helper/ArrayTransposeTest.php | Diff File | ||
mod - tests/Mantis/Helper/GetLinkAttributesTest.php | Diff File | ||
mod - tests/Mantis/MantisCoreBase.php | Diff File | ||
mod - tests/Mantis/MantisEnumTest.php | Diff File | ||
mod - tests/Mantis/MentionParsingTest.php | Diff File | ||
mod - tests/Mantis/PluginTest.php | Diff File | ||
mod - tests/Mantis/PrepareTest.php | Diff File | ||
mod - tests/Mantis/StringTest.php | Diff File | ||
mod - tests/Mantis/UserApiTest.php | Diff File | ||
mod - tests/TestConfig.php | Diff File | ||
mod - tests/core/Faker.php | Diff File | ||
add - tests/core/MantisTestCase.php | Diff File | ||
mod - tests/core/RequestBuilder.php | Diff File | ||
mod - tests/rest/RestBase.php | Diff File | ||
mod - tests/rest/RestFiltersTest.php | Diff File | ||
mod - tests/rest/RestImpersonateUserTest.php | Diff File | ||
mod - tests/rest/RestIssueRelationshipsTest.php | Diff File | ||
mod - tests/rest/RestIssueTest.php | Diff File | ||
mod - tests/rest/RestIssueUpdateVersion.php | Diff File | ||
mod - tests/rest/RestProjectTest.php | Diff File | ||
mod - tests/rest/RestProjectVersionTest.php | Diff File | ||
mod - tests/rest/RestUserTest.php | Diff File | ||
mod - tests/soap/AttachmentTest.php | Diff File | ||
mod - tests/soap/CategoryTest.php | Diff File | ||
mod - tests/soap/CompressionTest.php | Diff File | ||
mod - tests/soap/EnumTest.php | Diff File | ||
mod - tests/soap/FilterTest.php | Diff File | ||
mod - tests/soap/IssueAddTest.php | Diff File | ||
mod - tests/soap/IssueHistoryTest.php | Diff File | ||
mod - tests/soap/IssueMonitorTest.php | Diff File | ||
mod - tests/soap/IssueNoteTest.php | Diff File | ||
mod - tests/soap/IssueUpdateTest.php | Diff File | ||
mod - tests/soap/LoginTest.php | Diff File | ||
mod - tests/soap/MentionTest.php | Diff File | ||
mod - tests/soap/ProjectTest.php | Diff File | ||
mod - tests/soap/RelationshipTest.php | Diff File | ||
mod - tests/soap/SoapBase.php | Diff File | ||
mod - tests/soap/TagTest.php | Diff File | ||
mod - tests/soap/UserTest.php | Diff File | ||
mod - tests/soap/VersionTest.php | Diff File |