Skip to content

Randomly failing BigBlueButtonTest::testInsertDocumentFile() #279

Description

@donquixote

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions