Skip to content

Commit 1f7fa43

Browse files
committed
PHPDocs
1 parent 24ce432 commit 1f7fa43

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/Discord/Discord.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use Discord\Repository\LobbyRepository;
4343
use Discord\Repository\PrivateChannelRepository;
4444
use Discord\Repository\SoundRepository;
45+
use Discord\Repository\StickerPackRepository;
4546
use Discord\Repository\UserRepository;
4647
use Discord\Voice\Manager;
4748
use Discord\Voice\Region;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Discord\Discord;
6+
use Discord\Helpers\Collection;
7+
use Discord\Parts\Guild\Sticker;
8+
use Discord\Parts\StickerPack;
9+
use Discord\Repository\StickerPackRepository;
10+
11+
final class StickerPackTest extends DiscordTestCase
12+
{
13+
/**
14+
* @covers \Discord\Parts\User\Client::getSticker
15+
*/
16+
public function testCanGetSticker()
17+
{
18+
return wait(function (Discord $discord, $resolve) {
19+
$discord->sticker_packs->freshen()
20+
->then(function (StickerPackRepository $sticker_packs) {
21+
$this->assertGreaterThan(0, $sticker_packs->count());
22+
$message = 'Sticker pack: '.$sticker_packs->first()->name.' ('.$sticker_packs->first()->id.')';
23+
$this->channel()->sendMessage($message);
24+
})
25+
->then($resolve, $resolve);
26+
});
27+
}
28+
public function testCanBuildStickerPackWithStickerInstances()
29+
{
30+
$discordMock = $this->getMockBuilder(Discord::class)
31+
->disableOriginalConstructor()
32+
->getMock();
33+
34+
$httpMock = $this->getMockBuilder(\Discord\Http\Http::class)
35+
->disableOriginalConstructor()
36+
->getMock();
37+
38+
$factoryMock = $this->getMockBuilder(\Discord\Factory\Factory::class)
39+
->disableOriginalConstructor()
40+
->getMock();
41+
42+
$discordMock->method('getHttpClient')->willReturn($httpMock);
43+
$discordMock->method('getFactory')->willReturn($factoryMock);
44+
$discordMock->method('getCollectionClass')->willReturn(Collection::class);
45+
46+
$sticker1 = new Sticker($discordMock, ['id' => 's1', 'name' => 'One', 'format_type' => Sticker::FORMAT_TYPE_PNG], true);
47+
$sticker2 = new Sticker($discordMock, ['id' => 's2', 'name' => 'Two', 'format_type' => Sticker::FORMAT_TYPE_PNG], true);
48+
49+
$pack = new StickerPack($discordMock, [
50+
'id' => 'pack1',
51+
'name' => 'Pack',
52+
'stickers' => [$sticker1, $sticker2],
53+
'sku_id' => 'sku',
54+
'description' => 'desc',
55+
'cover_sticker_id' => null,
56+
'banner_asset_id' => null,
57+
], true);
58+
59+
$this->assertEquals('pack1', $pack->id);
60+
$this->assertEquals('Pack', $pack->name);
61+
$this->assertEquals(2, $pack->stickers->count());
62+
$this->assertInstanceOf(Sticker::class, $pack->stickers->first());
63+
$this->assertEquals('pack1', (string) $pack);
64+
}
65+
}
66+

0 commit comments

Comments
 (0)