-
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.
Properly support activity updates, improve testing coverage
- promisev3-0.0.1
- 0.13.7
- 0.13.6
- 0.13.5
- 0.13.4
- 0.13.3
- 0.13.2
- 0.13.1
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.9.14
- 0.9.13
- 0.9.12
- 0.9.11
- 0.9.10
- 0.9.9
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.4.2
- 0.4.1
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
Showing
9 changed files
with
237 additions
and
23 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,13 @@ | ||
<?php | ||
|
||
namespace Exan\Dhp\Enums\Gateway; | ||
|
||
enum ActivityType: int | ||
{ | ||
case GAME = 0; | ||
case STREAMING = 1; | ||
case LISTENING = 2; | ||
case WATCHING = 3; | ||
case CUSTOM = 4; | ||
case COMPETING = 5; | ||
} |
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
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,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Exan\Dhp\Discord; | ||
|
||
use Exan\Dhp\Const\Events; | ||
use Mockery; | ||
use React\EventLoop\TimerInterface; | ||
use Tests\Exan\Dhp\Discord\DiscordTestCase; | ||
|
||
/** | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
*/ | ||
final class StopsHeartBeatsTest extends DiscordTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->mockIncomingMessage([ | ||
'op' => 0, | ||
't' => Events::READY, | ||
's' => 1, | ||
'd' => [ | ||
'session_id' => '::session id::', | ||
'resume_gateway_url' => '::resume gateway url::' | ||
] | ||
]); | ||
|
||
$this->loop->shouldReceive('addPeriodicTimer', 'addTimer') | ||
->andReturnUsing(function ($interval, callable $callback) { | ||
$callback(); | ||
|
||
return Mockery::mock(TimerInterface::class); | ||
}); | ||
|
||
$this->loop->shouldReceive('cancelTimer'); | ||
} | ||
|
||
public function testReconnectWhenHeartBeatNotAcknowledged() | ||
{ | ||
$this->mockIncomingMessage([ | ||
'op' => 10, | ||
'd' => [ | ||
'heartbeat_interval' => 20000 | ||
] | ||
]); | ||
|
||
$this->discord->websocket->shouldHaveReceived('close', [1001, 'reconnecting']); | ||
|
||
$this->mockIncomingMessage([ | ||
'op' => 10, | ||
'd' => [ | ||
'heartbeat_interval' => 20000, | ||
], | ||
]); | ||
|
||
$this->assertMessageSent([ | ||
'op' => 6, | ||
'd' => [ | ||
'token' => '::token::', | ||
'session_id' => '::session id::', | ||
'seq' => 1, | ||
] | ||
]); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Tests\Exan\Dhp\Websocket\Helpers; | ||
|
||
use Exan\Dhp\Enums\Gateway\ActivityType; | ||
use Exan\Dhp\Parts\Emoji; | ||
use Exan\Dhp\Websocket\Helpers\ActivityBuilder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ActivityBuilderTest extends TestCase | ||
{ | ||
public function testSetName(): void | ||
{ | ||
$activityBuilder = new ActivityBuilder(); | ||
$activityBuilder->setName('Test Activity'); | ||
$this->assertEquals(['name' => 'Test Activity'], $activityBuilder->get()); | ||
} | ||
|
||
public function testSetType(): void | ||
{ | ||
$activityBuilder = new ActivityBuilder(); | ||
$activityBuilder->setType(ActivityType::GAME); | ||
$this->assertEquals(['type' => ActivityType::GAME->value], $activityBuilder->get()); | ||
} | ||
|
||
public function testSetUrl(): void | ||
{ | ||
$activityBuilder = new ActivityBuilder(); | ||
$activityBuilder->setUrl('https://www.test.com'); | ||
$this->assertEquals(['url' => 'https://www.test.com'], $activityBuilder->get()); | ||
} | ||
|
||
public function testSetEmoji(): void | ||
{ | ||
$activityBuilder = new ActivityBuilder(); | ||
$emoji = Emoji::get('::emoji id::', '::emoji name::'); | ||
|
||
$activityBuilder->setEmoji($emoji); | ||
$this->assertEquals(['emoji' => $emoji->getPartial()], $activityBuilder->get()); | ||
} | ||
} |