Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelWei committed Aug 31, 2023
1 parent cfd0d03 commit 3def639
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,10 @@ public function getHTTPQuery(): string
{
$queries = $this->getHTTPQueryArray();

if (\count($this->getDisabledFeatures()) != 0) {
$queries['disabledFeatures'] = implode(',', $this->getDisabledFeatures());
if (!empty($this->disabledFeatures)) {
$queries = array_merge($queries, [
'disabledFeatures' => implode(',', $this->disabledFeatures),
]);
}

if ($this->isBreakout()) {
Expand Down
46 changes: 46 additions & 0 deletions src/Util/ParamsIterator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
*
* Copyright (c) 2016-2023 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/

namespace BigBlueButton\Util;

use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @coversNothing
*/
class ParamsIterator extends TestCase
{
public function iterate($params, $url)
{
foreach ($params as $key => $value) {
if (\is_bool($value)) {
$value = $value ? 'true' : 'false';
}

if (!\is_array($value)) {
$this->assertStringContainsString($value, urldecode($url));
} else {
$this->iterate($value, $url);
}
}
}
}
13 changes: 3 additions & 10 deletions tests/unit/BigBlueButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use BigBlueButton\Parameters\GetRecordingsParameters;
use BigBlueButton\Parameters\InsertDocumentParameters;
use BigBlueButton\Parameters\PublishRecordingsParameters;
use BigBlueButton\Util\ParamsIterator;
use PHPUnit\Framework\MockObject\MockObject;

/**
Expand Down Expand Up @@ -161,17 +162,9 @@ public function testCreateMeetingUrl()
{
$params = $this->generateCreateParams();
$url = $this->bbb->getCreateMeetingUrl($this->getCreateMock($params));
foreach ($params as $key => $value) {
if (\is_bool($value)) {
$value = $value ? 'true' : 'false';
}

if ($key == 'disabledFeatures') {
$value = implode(',', $value);
}

$this->assertStringContainsString(rawurlencode($key).'='.rawurlencode($value), $url);
}
$paramsIterator = new ParamsIterator();
$paramsIterator->iterate($params, $url);
}

/* Join Meeting */
Expand Down

0 comments on commit 3def639

Please sign in to comment.