Skip to content

Fixed broken testArraySearch() test#5

Merged
jayay merged 3 commits intoonOfficeGmbH:mainfrom
jdevinemt:patch-1
Feb 13, 2026
Merged

Fixed broken testArraySearch() test#5
jayay merged 3 commits intoonOfficeGmbH:mainfrom
jdevinemt:patch-1

Conversation

@jdevinemt
Copy link
Copy Markdown
Contributor

@jdevinemt jdevinemt commented Feb 11, 2026

testArraySearch() test in StringToNumberComparisonTest class did not assert correct behavior. It was asserting that the custom arraySearch() function would return a value "equal" to 0, which uses loose equality. Therefore, when running the test in PHP 8.0+ it falsely passes because arraySearch() returns false, which is "equal" to 0. The test was updated to assert that the return value was exactly 0.

@jayay
Copy link
Copy Markdown
Collaborator

jayay commented Feb 12, 2026

Good catch! This test was extracted from one of our internal tests, where $this->assertEquals() behaves like $this->assertSame() in PHPUnit. So that might have been forgotten.

Replacing every assertEquals() with assertSame() should still give us a working test. Would you consider trying that out?

…oNumberComparison unit tests. Some tests would return a false positive when using assertEquals() because it uses loose comparison. (eg. assertEquals(0, 'true') === true)
…ner unit tests to be consistent with usage of assertSame() in other unit test classes.
…\RecursionInnerValue with explicit definition.
@jdevinemt
Copy link
Copy Markdown
Contributor Author

Good catch! This test was extracted from one of our internal tests, where $this->assertEquals() behaves like $this->assertSame() in PHPUnit. So that might have been forgotten.

Replacing every assertEquals() with assertSame() should still give us a working test. Would you consider trying that out?

I replaced all usage of assertEquals() with assertSame() in test suite and verified tests still work as expected. There was one additional test class that was using assertEquals(), it was not affecting test behavior, but I updated it to be consistent with the usage of assertSame() throughout the rest of the test suite.

I also fixed a deprecation warning I was getting when running tests.

@jayay
Copy link
Copy Markdown
Collaborator

jayay commented Feb 13, 2026

I replaced all usage of assertEquals() with assertSame() in test suite and verified tests still work as expected. There was one additional test class that was using assertEquals(), it was not affecting test behavior, but I updated it to be consistent with the usage of assertSame() throughout the rest of the test suite.

I also fixed a deprecation warning I was getting when running tests.

Awesome, thank you! 😊

@jayay jayay merged commit 3275428 into onOfficeGmbH:main Feb 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants