Skip to content

Commit

Permalink
Move userdata property to JoinMeetingParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
GhaziTriki committed Nov 12, 2018
1 parent f461e1a commit 6710d96
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 35 deletions.
31 changes: 31 additions & 0 deletions src/Core/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ class Attendee
*/
private $hasVideo;

/**
* @var array
*/
private $customData;

/**
* @var string
*/
private $clientType;

/**
* Attendee constructor.
* @param $xml \SimpleXMLElement
Expand All @@ -68,6 +78,11 @@ public function __construct($xml)
$this->isListeningOnly = $xml->isListeningOnly->__toString() === 'true';
$this->hasJoinedVoice = $xml->hasJoinedVoice->__toString() === 'true';
$this->hasVideo = $xml->hasVideo->__toString() === 'true';
$this->clientType = $xml->clientType->__toString();

foreach ($xml->customdata->children() as $data) {
$this->customData[$data->getName()] = $data->__toString();
}
}

/**
Expand Down Expand Up @@ -125,4 +140,20 @@ public function hasVideo()
{
return $this->hasVideo;
}

/**
* @return string
*/
public function getClientType()
{
return $this->clientType;
}

/**
* @return array
*/
public function getCustomData()
{
return $this->customData;
}
}
3 changes: 1 addition & 2 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Class CreateMeetingParameters.
*/
class CreateMeetingParameters extends UserDataParameters
class CreateMeetingParameters extends MetaParameters
{
/**
* @var string
Expand Down Expand Up @@ -713,7 +713,6 @@ public function getHTTPQuery()
}

$this->buildMeta($queries);
$this->buildUserData($queries);

return $this->buildHTTPQuery($queries);
}
Expand Down
33 changes: 17 additions & 16 deletions src/Parameters/JoinMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Class JoinMeetingParametersTest.
*/
class JoinMeetingParameters extends BaseParameters
class JoinMeetingParameters extends UserDataParameters
{
/**
* @var string
Expand Down Expand Up @@ -312,20 +312,21 @@ public function setJoinViaHtml5($joinViaHtml5)
*/
public function getHTTPQuery()
{
return $this->buildHTTPQuery(
[
'meetingID' => $this->meetingId,
'fullName' => $this->username,
'password' => $this->password,
'userID' => $this->userId,
'webVoiceConf' => $this->webVoiceConf,
'createTime' => $this->creationTime,
'configToken' => $this->configToken,
'avatarURL' => $this->avatarURL,
'redirect' => $this->redirect ? 'true' : 'false',
'joinViaHtml5' => $this->joinViaHtml5 ? 'true' : 'false',
'clientURL' => $this->clientURL
]
);
$queries = [
'meetingID' => $this->meetingId,
'fullName' => $this->username,
'password' => $this->password,
'userID' => $this->userId,
'webVoiceConf' => $this->webVoiceConf,
'createTime' => $this->creationTime,
'configToken' => $this->configToken,
'avatarURL' => $this->avatarURL,
'redirect' => $this->redirect ? 'true' : 'false',
'joinViaHtml5' => $this->joinViaHtml5 ? 'true' : 'false',
'clientURL' => $this->clientURL
];
$this->buildUserData($queries);

return $this->buildHTTPQuery($queries);
}
}
4 changes: 2 additions & 2 deletions src/Parameters/UserDataParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*
* 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\Parameters;

/**
* Class UserDataParameters
* @package BigBlueButton\Parameters
*/
abstract class UserDataParameters extends MetaParameters
abstract class UserDataParameters extends BaseParameters
{
/**
* @var array
Expand Down
1 change: 0 additions & 1 deletion tests/Parameters/CreateMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testCreateMeetingParameters()
$this->assertEquals($params['muteOnStart'], $createMeetingParams->isMuteOnStart());
$this->assertEquals($params['meta_presenter'], $createMeetingParams->getMeta('presenter'));
$this->assertEquals($params['meta_endCallbackUrl'], $createMeetingParams->getMeta('endCallbackUrl'));
$this->assertEquals($params['userdata_countrycode'], $createMeetingParams->getUserData('countrycode'));

// Check values are empty of this is not a breakout room
$this->assertNull($createMeetingParams->isBreakout());
Expand Down
1 change: 1 addition & 0 deletions tests/Parameters/JoinMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function testJoinMeetingParameters()
$this->assertEquals($params['userId'], $joinMeetingParams->getUserId());
$this->assertEquals($params['webVoiceConf'], $joinMeetingParams->getWebVoiceConf());
$this->assertEquals($params['creationTime'], $joinMeetingParams->getCreationTime());
$this->assertEquals($params['userdata_countrycode'], $joinMeetingParams->getUserData('countrycode'));

// Test setters that are ignored by the constructor
$joinMeetingParams->setMeetingId($newId = $this->faker->uuid);
Expand Down
9 changes: 8 additions & 1 deletion tests/Responses/GetMeetingInfoResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ public function testMeetingAttendeeContent()
$this->assertEquals(false, $anAttendee->isListeningOnly());
$this->assertEquals(true, $anAttendee->hasJoinedVoice());
$this->assertEquals(false, $anAttendee->hasVideo());
$this->assertEquals('FLASH', $anAttendee->getClientType());
$this->assertCount(2, $this->meetingInfo->getAttendees());

$customData = $anAttendee->getCustomData();
$this->assertEquals(3, sizeof($customData));
$this->assertEquals('true', $customData['skipCheck']);
$this->assertEquals('#FF0033', $customData['backgroundColor']);
$this->assertEquals('a:focus{color:#0181eb}', $customData['customStyle']);
}

public function testGetMeetingInfoResponseTypes()
Expand All @@ -95,7 +102,7 @@ public function testGetMeetingInfoResponseTypes()

$anAttendee = $this->meetingInfo->getAttendees()[1];

$this->assertEachGetterValueIsString($anAttendee, ['getUserId', 'getFullName', 'getRole']);
$this->assertEachGetterValueIsString($anAttendee, ['getUserId', 'getFullName', 'getRole', 'getClientType']);
$this->assertEachGetterValueIsBoolean($anAttendee, ['isPresenter', 'isListeningOnly', 'hasJoinedVoice', 'hasVideo']);
}

Expand Down
23 changes: 12 additions & 11 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ protected function generateCreateParams()
'copyright' => $this->faker->text,
'muteOnStart' => $this->faker->boolean(50),
'meta_presenter' => $this->faker->name,
'meta_endCallbackUrl' => $this->faker->url,
'userdata_countrycode' => $this->faker->countryCode
'meta_endCallbackUrl' => $this->faker->url
];
}

Expand Down Expand Up @@ -121,8 +120,7 @@ protected function getCreateMock($params)
->setDuration($params['duration'])->setWelcomeMessage($params['welcomeMessage'])->setAutoStartRecording($params['autoStartRecording'])
->setAllowStartStopRecording($params['allowStartStopRecording'])->setModeratorOnlyMessage($params['moderatorOnlyMessage'])
->setWebcamsOnlyForModerator($params['webcamsOnlyForModerator'])->setLogo($params['logo'])->setCopyright($params['copyright'])
->setEndCallbackUrl($params['meta_endCallbackUrl'])->setMuteOnStart($params['muteOnStart'])->addMeta('presenter', $params['meta_presenter'])
->addUserData('countrycode', $params['userdata_countrycode']);
->setEndCallbackUrl($params['meta_endCallbackUrl'])->setMuteOnStart($params['muteOnStart'])->addMeta('presenter', $params['meta_presenter']);
}

/**
Expand All @@ -143,12 +141,14 @@ protected function getBreakoutCreateMock($params)
*/
protected function generateJoinMeetingParams()
{
return ['meetingId' => $this->faker->uuid,
'userName' => $this->faker->name,
'password' => $this->faker->password,
'userId' => $this->faker->numberBetween(1, 1000),
'webVoiceConf' => $this->faker->word,
'creationTime' => $this->faker->unixTime];
return ['meetingId' => $this->faker->uuid,
'userName' => $this->faker->name,
'password' => $this->faker->password,
'userId' => $this->faker->numberBetween(1, 1000),
'webVoiceConf' => $this->faker->word,
'creationTime' => $this->faker->unixTime,
'userdata_countrycode' => $this->faker->countryCode
];
}

/**
Expand All @@ -160,7 +160,8 @@ protected function getJoinMeetingMock($params)
{
$joinMeetingParams = new JoinMeetingParameters($params['meetingId'], $params['userName'], $params['password']);

return $joinMeetingParams->setUserId($params['userId'])->setWebVoiceConf($params['webVoiceConf'])->setCreationTime($params['creationTime']);
return $joinMeetingParams->setUserId($params['userId'])->setWebVoiceConf($params['webVoiceConf'])
->setCreationTime($params['creationTime'])->addUserData('countrycode', $params['userdata_countrycode']);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions tests/fixtures/get_meeting_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<isListeningOnly>false</isListeningOnly>
<hasJoinedVoice>true</hasJoinedVoice>
<hasVideo>true</hasVideo>
<clientType>HTML5</clientType>
<customdata></customdata>
</attendee>
<attendee>
Expand All @@ -42,7 +43,12 @@
<isListeningOnly>false</isListeningOnly>
<hasJoinedVoice>true</hasJoinedVoice>
<hasVideo>false</hasVideo>
<customdata></customdata>
<clientType>FLASH</clientType>
<customdata>
<skipCheck>true</skipCheck>
<backgroundColor>#FF0033</backgroundColor>
<customStyle>a:focus{color:#0181eb}</customStyle>
</customdata>
</attendee>
</attendees>
<isBreakout>true</isBreakout>
Expand All @@ -52,7 +58,7 @@
<bbb-context>Best BBB Developers Club</bbb-context>
<bn-origin>Moodle</bn-origin>
<bn-recording-ready-url>
http://bigbluebutton.org/moodle/mod/bigbluebuttonbn/bbb_broker.php?action=recording_ready
http://bigbluebutton.org/moodle/mod/bigbluebuttonbn/bbb_broker.php?action=recording_ready
</bn-recording-ready-url>
<bbb-origin-tag>moodle-mod_bigbluebuttonbn (2015080609)</bbb-origin-tag>
<bbb-origin-version>3.0.2 (Build: 20160111)</bbb-origin-version>
Expand Down

0 comments on commit 6710d96

Please sign in to comment.