-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update presence & request guild members
- Loading branch information
Showing
7 changed files
with
236 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Exan\Dhp\Enums\Gateway; | ||
|
||
enum StatusType: string | ||
{ | ||
case ONLINE = 'online'; | ||
case DO_NOT_DISTURB = 'dnd'; | ||
case AFK = 'idle'; | ||
case INVISIBLE = 'invisible'; | ||
case OFFLINE = 'offline'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Exan\Dhp\Websocket\Helpers; | ||
|
||
class ActivityBuilder | ||
{ | ||
public function get(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace Tests\Exan\Dhp\Discord; | ||
|
||
/** | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
*/ | ||
class RequestGuildMembersTest extends DiscordTestCase | ||
{ | ||
public function testRequestGuildMembersByQuery() | ||
{ | ||
$this->discord->requestGuildMembersByQuery( | ||
'::guild id::', | ||
'', | ||
123, | ||
true | ||
); | ||
|
||
$this->assertMessageSent( | ||
[ | ||
'guild_id' => '::guild id::', | ||
'query' => '', | ||
'limit' => 123, | ||
'presences' => true | ||
] | ||
); | ||
} | ||
|
||
public function testRequestGuildMembersByQueryWithNonce() | ||
{ | ||
$this->discord->requestGuildMembersByQuery( | ||
'::guild id::', | ||
'', | ||
123, | ||
true, | ||
'::nonce::' | ||
); | ||
|
||
$this->assertMessageSent( | ||
[ | ||
'guild_id' => '::guild id::', | ||
'query' => '', | ||
'limit' => 123, | ||
'presences' => true, | ||
'nonce' => '::nonce::' | ||
] | ||
); | ||
} | ||
|
||
public function testRequestGuildMembersByUserIds() | ||
{ | ||
$this->discord->requestGuildMembersByUserIds( | ||
'::guild id::', | ||
['::user id::'], | ||
123, | ||
true | ||
); | ||
|
||
$this->assertMessageSent( | ||
[ | ||
'guild_id' => '::guild id::', | ||
'user_ids' => ['::user id::'], | ||
'limit' => 123, | ||
'presences' => true | ||
] | ||
); | ||
} | ||
|
||
public function testRequestGuildMembersByUserIdsWithNonce() | ||
{ | ||
$this->discord->requestGuildMembersByUserIds( | ||
'::guild id::', | ||
['::user id::'], | ||
123, | ||
true, | ||
'::testRequestGuildMembersByUserIdsWithNonce::' | ||
); | ||
|
||
$this->assertMessageSent( | ||
[ | ||
'guild_id' => '::guild id::', | ||
'user_ids' => ['::user id::'], | ||
'limit' => 123, | ||
'presences' => true, | ||
'nonce' => '::testRequestGuildMembersByUserIdsWithNonce::' | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Tests\Exan\Dhp\Discord; | ||
|
||
use Exan\Dhp\Enums\Gateway\StatusType; | ||
use Exan\Dhp\Websocket\Helpers\ActivityBuilder; | ||
use Tests\Exan\Dhp\Discord\DiscordTestCase; | ||
|
||
/** | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
*/ | ||
class UpdatePresenceTest extends DiscordTestCase | ||
{ | ||
public function testUpdatePresence() | ||
{ | ||
$this->discord->updatePresence( | ||
StatusType::ONLINE, | ||
[new ActivityBuilder()], | ||
); | ||
|
||
$this->assertMessageSent([ | ||
'status' => StatusType::ONLINE->value, | ||
'activities' => [[]], | ||
'afk' => false, | ||
]); | ||
} | ||
|
||
public function testUpdatePresenceWithSince() | ||
{ | ||
$this->discord->updatePresence( | ||
StatusType::ONLINE, | ||
[new ActivityBuilder()], | ||
since: 12345 | ||
); | ||
|
||
$this->assertMessageSent([ | ||
'status' => StatusType::ONLINE->value, | ||
'activities' => [[]], | ||
'afk' => false, | ||
'since' => 12345 | ||
]); | ||
} | ||
} |