The BigBlueButtonTest::testInsertDocumentFile() fails randomly.
// ASSERT
if (!array_search(Feature::PRESENTATION, $createMeetingParameters->getDisabledFeatures()) > 0) {
[...]
} else {
$this->assertTrue($insertDocumentResponse->failed()); // Random fail here.
I see two flaws in this code:
- The condition with
!$expr > 0 has operator precedence problems, it evaluates to (!$expr) > 0 which is equivalent to just !$expr.
- If 'presentation' is at position 0, then
array_search($needle, $haystack) returns 0, and !0 is true.
- The condition does not account for
->getDisabledFeaturesExclude(), which overrides ->getDisabledFeatures().
Steps to reproduce
Repeat the following a bunch of times:
./vendor/bin/phpunit tests/BigBlueButtonTest.php --stop-on-failure --stop-on-error --filter=testInsertDocumentFile
Solution
Use in_array() instead of array_search().
Also check for ->getDisabledFeaturesExclude().
The
BigBlueButtonTest::testInsertDocumentFile()fails randomly.I see two flaws in this code:
!$expr > 0has operator precedence problems, it evaluates to(!$expr) > 0which is equivalent to just!$expr.array_search($needle, $haystack)returns 0, and!0is true.->getDisabledFeaturesExclude(), which overrides->getDisabledFeatures().Steps to reproduce
Repeat the following a bunch of times:
Solution
Use in_array() instead of array_search().
Also check for
->getDisabledFeaturesExclude().