Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
- tests
parallel:
maximumNumberOfProcesses: 4
level: 6
level: 7
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- tools/bootstrap.php
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

private string $source;

public function __construct(object $track)
public function __construct(\stdClass $track)
{
$this->href = $track->href;
$this->kind = $track->kind;
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Transport/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ private static function getHeadersAndContentFromCurlHandle(\CurlHandle $curlHand
$headers = [];

curl_setopt($curlHandle, \CURLOPT_HEADER, true);

/** @var string|false $responseContent */
$responseContent = curl_exec($curlHandle);

// @codeCoverageIgnoreStart
Expand Down
6 changes: 5 additions & 1 deletion src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ public function getModules(): string
// Get xml as string after modules have been added
$resultXML = $xml->asXML();

if (false === $resultXML) {
throw new \LogicException('Could not generate XML.');
}

// If xml was not modified (no modules added), return an empty string
if ($emptyXML === $resultXML) {
return '';
Expand Down Expand Up @@ -496,7 +500,7 @@ public function getHTTPQuery(): string
// Pre-defined groups to automatically assign the students to a given breakout room
if (!empty($this->breakoutRoomsGroups)) {
$queries = array_merge($queries, [
'groups' => json_encode($this->breakoutRoomsGroups),
'groups' => json_encode($this->breakoutRoomsGroups, \JSON_THROW_ON_ERROR),
]);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function removePresentation(string $url): self
return $this;
}

public function getPresentationsAsXML(): string|false
public function getPresentationsAsXML(): string
{
$result = '';

Expand All @@ -87,6 +87,10 @@ public function getPresentationsAsXML(): string|false
$result = $xml->asXML();
}

if (false === $result) {
throw new \LogicException('Could not generate XML.');
}

return $result;
}
}
2 changes: 1 addition & 1 deletion src/Responses/BaseResponseAsJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getRawJson(): string|false
*/
public function getRawArray(): array
{
return json_decode(json_encode($this->data), true);
return json_decode(json_encode($this->data, \JSON_THROW_ON_ERROR), true);
}

public function getMessage(): string
Expand Down
14 changes: 12 additions & 2 deletions tests/common/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,22 @@ protected function getUpdateRecordingsParamsMock(array $params): UpdateRecording

protected function loadXmlFile(string $path): \SimpleXMLElement
{
return simplexml_load_string(file_get_contents($path));
$content = file_get_contents($path);
$this->assertIsString($content);

$xml = simplexml_load_string($content);

$this->assertNotFalse($xml);

return $xml;
}

protected function loadJsonFile(string $path): string
{
return file_get_contents($path);
$content = file_get_contents($path);
$this->assertIsString($content);

return $content;
}

protected function minifyString(string $string): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/**
* Class BigBlueButtonIntegrationTest.
*/
abstract class AbstractBigBlueButtonFunctionalTest extends TestCase
abstract class BigBlueButtonFunctionalTestAbstract extends TestCase
{
private BigBlueButton $bbb;

Expand Down Expand Up @@ -153,7 +153,11 @@ public function testCreateMeetingWithDocumentUrlAndFileName(): void
public function testCreateMeetingWithDocumentEmbedded(): void
{
$params = $this->getCreateMock($this->generateCreateParams());
$params->addPresentation('bbb_logo.png', file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png'));

$content = file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png');
$this->assertIsString($content);

$params->addPresentation('bbb_logo.png', $content);

$result = $this->bbb->createMeeting($params);

Expand All @@ -172,7 +176,11 @@ public function testCreateMeetingWithMultiDocument(): void
{
$params = $this->getCreateMock($this->generateCreateParams());
$params->addPresentation('https://picsum.photos/3840/2160/?random', null, 'presentation.png');
$params->addPresentation('logo.png', file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png'));

$content = file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png');
$this->assertIsString($content);

$params->addPresentation('logo.png', $content);

$result = $this->bbb->createMeeting($params);

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/BigBlueButtonWithCurlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use BigBlueButton\Http\Transport\CurlTransport;
use BigBlueButton\Http\Transport\TransportInterface;

final class BigBlueButtonWithCurlTransportTest extends AbstractBigBlueButtonFunctionalTest
final class BigBlueButtonWithCurlTransportTest extends BigBlueButtonFunctionalTestAbstract
{
protected static function createTransport(): TransportInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Component\HttpClient\Psr18Client;

final class BigBlueButtonWithPsrHttpClientTransport extends AbstractBigBlueButtonFunctionalTest
final class BigBlueButtonWithPsrHttpClientTransport extends BigBlueButtonFunctionalTestAbstract
{
protected static function createTransport(): TransportInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use BigBlueButton\Http\Transport\Bridge\SymfonyHttpClient\SymfonyHttpClientTransport;
use BigBlueButton\Http\Transport\TransportInterface;

final class BigBlueButtonWithSymfonyHttpClientTransportTest extends AbstractBigBlueButtonFunctionalTest
final class BigBlueButtonWithSymfonyHttpClientTransportTest extends BigBlueButtonFunctionalTestAbstract
{
protected static function createTransport(): TransportInterface
{
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/BigBlueButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ public function testCreateWithPresentation(): void
$payload = $request->getPayload();
$xml = simplexml_load_string($payload);

self::assertNotFalse($xml);

$presentations = $xml->module[0];
$clientSettingsOverride = $xml->module[1];

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/Parameters/CreateMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ public function testGetPresentationsAsXMLWithFile(): void
{
$params = $this->generateCreateParams();
$createMeetingParams = $this->getCreateMock($params);
$createMeetingParams->addPresentation('bbb_logo.png', file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png'));

$content = file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png');
$this->assertIsString($content);

$createMeetingParams->addPresentation('bbb_logo.png', $content);
$this->assertXmlStringEqualsXmlFile(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'presentation_with_embedded_file.xml', $createMeetingParams->getModules());
}

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/Responses/GetMeetingsResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ public function testGetMeetingsNoMeetings(): void
{
// scalelite response no meetings
$xml = simplexml_load_string('<response><returncode>SUCCESS</returncode><messageKey>noMeetings</messageKey><message>No meetings were found on this server.</message></response>');
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);

$this->meetings = new GetMeetingsResponse($xml);
$this->assertEquals('SUCCESS', $this->meetings->getReturnCode());
$this->assertCount(0, $this->meetings->getMeetings());

// normal bbb response no meetings
$xml = simplexml_load_string('<response><returncode>SUCCESS</returncode><meetings/><messageKey>noMeetings</messageKey><message>No meetings were found on this server.</message></response>');
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);

$this->meetings = new GetMeetingsResponse($xml);
$this->assertEquals('SUCCESS', $this->meetings->getReturnCode());
$this->assertCount(0, $this->meetings->getMeetings());
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/Responses/GetRecordingsResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ public function testHasNoRecordings(): void
<message>There are no recordings for the meeting(s).</message>
</response>';

$response = new GetRecordingsResponse(simplexml_load_string($xml));
$xml = simplexml_load_string($xml);
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);

$response = new GetRecordingsResponse($xml);

$this->assertTrue($response->hasNoRecordings());
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Responses/HooksDestroyResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function testHooksDestroyResponseTypes(): void
public function testHookDestroyMissingHook(): void
{
$xml = simplexml_load_string('<response><returncode>FAILED</returncode><messageKey>destroyMissingHook</messageKey><message>The hook informed was not found.</message></response>');
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);

$destroyResponse = new HooksDestroyResponse($xml);
$this->assertTrue($destroyResponse->failed());
Expand All @@ -62,6 +63,7 @@ public function testHookDestroyMissingHook(): void
public function testHookDestroyHookError(): void
{
$xml = simplexml_load_string('<response><returncode>FAILED</returncode><messageKey>destroyHookError</messageKey><message>An error happened while removing your hook. Check the logs.</message></response>');
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);

$destroyResponse = new HooksDestroyResponse($xml);
$this->assertTrue($destroyResponse->failed());
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Responses/InsertDocumentResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public function testIsMeetingRunningResponseContent(): void
{
$this->assertEquals('SUCCESS', $this->running->getReturnCode());

$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode></response>', $this->minifyString($this->running->getRawXml()->asXML()));
$xml = $this->running->getRawXml()->asXML();
$this->assertIsString($xml);

$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode></response>', $this->minifyString(
$xml
));
}

public function testIsMeetingRunningResponseTypes(): void
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Responses/IsMeetingRunningResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public function testIsMeetingRunningResponseContent(): void
$this->assertEquals('SUCCESS', $this->running->getReturnCode());
$this->assertTrue($this->running->isRunning());

$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode><running>true</running></response>', $this->minifyString($this->running->getRawXml()->asXML()));
$xml = $this->running->getRawXml()->asXML();
$this->assertIsString($xml);

$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode><running>true</running></response>', $this->minifyString(
$xml
));
}

public function testIsMeetingRunningResponseTypes(): void
Expand Down
10 changes: 4 additions & 6 deletions tests/unit/Util/ArrayHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
*/
final class ArrayHelperTest extends TestCase
{
/**
* @return iterable<array{0: array<mixed>, 1: array<mixed>, 2: bool, 3: array<mixed>}>
*/
/** @return iterable<array<mixed>> */
public static function provideArrays(): iterable
{
yield 'simple flat arrays' => [
Expand Down Expand Up @@ -63,9 +61,9 @@ public static function provideArrays(): iterable
/**
* @dataProvider provideArrays
*
* @param array<mixed> $input1
* @param array<mixed> $input2
* @param array<mixed> $output
* @param array<string|array-key,string> $input1
* @param array<string|array-key,string> $input2
* @param array<string|array-key,string> $output
*/
public function testMergeRecursive(array $input1, array $input2, bool $reorderNested, array $output): void
{
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/Util/SimpleXMLElementExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ public function testAddChildWithCData(): void
$module = $xml->addChildWithCData('module', '{"foo": {"foo": "baa"}}');
$module->addAttribute('name', 'clientSettingsOverride');

$result = $xml->asXML();

$this->assertNotFalse($result);

$expected = '<?xml version="1.0" encoding="UTF-8"?>
<modules><module name="clientSettingsOverride"><![CDATA[{"foo": {"foo": "baa"}}]]></module></modules>';

$this->assertXmlStringEqualsXmlString($expected, $xml->asXML());
$this->assertXmlStringEqualsXmlString($expected, $result);
}
}
Loading