Skip to content

Commit fee1655

Browse files
authored
Add GitHub Actions workflow for tests (#504)
1 parent 36085b2 commit fee1655

32 files changed

+1759
-0
lines changed

.github/workflows/phpunit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
branches: ["*"]
6+
pull_request:
7+
8+
jobs:
9+
phpunit:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php: ["8.1", "8.2"]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: ${{ matrix.php }}
19+
coverage: none
20+
- name: Install dependencies
21+
run: composer install --prefer-dist --no-progress --no-interaction
22+
- name: Run tests
23+
run: composer test

src/Types/AcceptedGiftTypes.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\TypeInterface;
7+
8+
class AcceptedGiftTypes extends BaseType implements TypeInterface
9+
{
10+
protected static $requiredParams = ['unlimited_gifts', 'limited_gifts', 'unique_gifts', 'premium_subscription'];
11+
12+
protected static $map = [
13+
'unlimited_gifts' => true,
14+
'limited_gifts' => true,
15+
'unique_gifts' => true,
16+
'premium_subscription' => true,
17+
];
18+
19+
protected $unlimitedGifts;
20+
protected $limitedGifts;
21+
protected $uniqueGifts;
22+
protected $premiumSubscription;
23+
24+
public function getUnlimitedGifts()
25+
{
26+
return $this->unlimitedGifts;
27+
}
28+
29+
public function setUnlimitedGifts($unlimitedGifts)
30+
{
31+
$this->unlimitedGifts = $unlimitedGifts;
32+
}
33+
34+
public function getLimitedGifts()
35+
{
36+
return $this->limitedGifts;
37+
}
38+
39+
public function setLimitedGifts($limitedGifts)
40+
{
41+
$this->limitedGifts = $limitedGifts;
42+
}
43+
44+
public function getUniqueGifts()
45+
{
46+
return $this->uniqueGifts;
47+
}
48+
49+
public function setUniqueGifts($uniqueGifts)
50+
{
51+
$this->uniqueGifts = $uniqueGifts;
52+
}
53+
54+
public function getPremiumSubscription()
55+
{
56+
return $this->premiumSubscription;
57+
}
58+
59+
public function setPremiumSubscription($premiumSubscription)
60+
{
61+
$this->premiumSubscription = $premiumSubscription;
62+
}
63+
}

src/Types/ArrayOfGift.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace TelegramBot\Api\Types;
4+
5+
use TelegramBot\Api\InvalidArgumentException;
6+
7+
abstract class ArrayOfGift
8+
{
9+
/**
10+
* @param array $data
11+
* @return Gift[]
12+
* @throws InvalidArgumentException
13+
*/
14+
public static function fromResponse($data)
15+
{
16+
$array = [];
17+
foreach ($data as $datum) {
18+
$array[] = Gift::fromResponse($datum);
19+
}
20+
21+
return $array;
22+
}
23+
}

src/Types/ArrayOfOwnedGift.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace TelegramBot\Api\Types;
4+
5+
use TelegramBot\Api\InvalidArgumentException;
6+
7+
abstract class ArrayOfOwnedGift
8+
{
9+
/**
10+
* @param array $data
11+
* @return OwnedGift[]
12+
* @throws InvalidArgumentException
13+
*/
14+
public static function fromResponse($data)
15+
{
16+
$array = [];
17+
foreach ($data as $datum) {
18+
$array[] = OwnedGift::fromResponse($datum);
19+
}
20+
21+
return $array;
22+
}
23+
}

src/Types/Gift.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\TypeInterface;
7+
8+
/**
9+
* Class Gift
10+
* This object represents a gift that can be sent by the bot.
11+
*/
12+
class Gift extends BaseType implements TypeInterface
13+
{
14+
protected static $requiredParams = ['id', 'sticker', 'star_count'];
15+
16+
protected static $map = [
17+
'id' => true,
18+
'sticker' => Sticker::class,
19+
'star_count' => true,
20+
'upgrade_star_count' => true,
21+
'total_count' => true,
22+
'remaining_count' => true,
23+
];
24+
25+
protected $id;
26+
protected $sticker;
27+
protected $starCount;
28+
protected $upgradeStarCount;
29+
protected $totalCount;
30+
protected $remainingCount;
31+
32+
public function getId()
33+
{
34+
return $this->id;
35+
}
36+
37+
public function setId($id)
38+
{
39+
$this->id = $id;
40+
}
41+
42+
public function getSticker()
43+
{
44+
return $this->sticker;
45+
}
46+
47+
public function setSticker($sticker)
48+
{
49+
$this->sticker = $sticker;
50+
}
51+
52+
public function getStarCount()
53+
{
54+
return $this->starCount;
55+
}
56+
57+
public function setStarCount($starCount)
58+
{
59+
$this->starCount = $starCount;
60+
}
61+
62+
public function getUpgradeStarCount()
63+
{
64+
return $this->upgradeStarCount;
65+
}
66+
67+
public function setUpgradeStarCount($upgradeStarCount)
68+
{
69+
$this->upgradeStarCount = $upgradeStarCount;
70+
}
71+
72+
public function getTotalCount()
73+
{
74+
return $this->totalCount;
75+
}
76+
77+
public function setTotalCount($totalCount)
78+
{
79+
$this->totalCount = $totalCount;
80+
}
81+
82+
public function getRemainingCount()
83+
{
84+
return $this->remainingCount;
85+
}
86+
87+
public function setRemainingCount($remainingCount)
88+
{
89+
$this->remainingCount = $remainingCount;
90+
}
91+
}

src/Types/GiftInfo.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\TypeInterface;
7+
8+
class GiftInfo extends BaseType implements TypeInterface
9+
{
10+
protected static $requiredParams = ['gift'];
11+
12+
protected static $map = [
13+
'gift' => Gift::class,
14+
'owned_gift_id' => true,
15+
'convert_star_count' => true,
16+
'prepaid_upgrade_star_count' => true,
17+
'can_be_upgraded' => true,
18+
'text' => true,
19+
'entities' => ArrayOfMessageEntity::class,
20+
'is_private' => true,
21+
];
22+
23+
protected $gift;
24+
protected $ownedGiftId;
25+
protected $convertStarCount;
26+
protected $prepaidUpgradeStarCount;
27+
protected $canBeUpgraded;
28+
protected $text;
29+
protected $entities;
30+
protected $isPrivate;
31+
32+
public function getGift()
33+
{
34+
return $this->gift;
35+
}
36+
37+
public function setGift($gift)
38+
{
39+
$this->gift = $gift;
40+
}
41+
42+
public function getOwnedGiftId()
43+
{
44+
return $this->ownedGiftId;
45+
}
46+
47+
public function setOwnedGiftId($ownedGiftId)
48+
{
49+
$this->ownedGiftId = $ownedGiftId;
50+
}
51+
52+
public function getConvertStarCount()
53+
{
54+
return $this->convertStarCount;
55+
}
56+
57+
public function setConvertStarCount($convertStarCount)
58+
{
59+
$this->convertStarCount = $convertStarCount;
60+
}
61+
62+
public function getPrepaidUpgradeStarCount()
63+
{
64+
return $this->prepaidUpgradeStarCount;
65+
}
66+
67+
public function setPrepaidUpgradeStarCount($prepaidUpgradeStarCount)
68+
{
69+
$this->prepaidUpgradeStarCount = $prepaidUpgradeStarCount;
70+
}
71+
72+
public function getCanBeUpgraded()
73+
{
74+
return $this->canBeUpgraded;
75+
}
76+
77+
public function setCanBeUpgraded($canBeUpgraded)
78+
{
79+
$this->canBeUpgraded = $canBeUpgraded;
80+
}
81+
82+
public function getText()
83+
{
84+
return $this->text;
85+
}
86+
87+
public function setText($text)
88+
{
89+
$this->text = $text;
90+
}
91+
92+
public function getEntities()
93+
{
94+
return $this->entities;
95+
}
96+
97+
public function setEntities($entities)
98+
{
99+
$this->entities = $entities;
100+
}
101+
102+
public function getIsPrivate()
103+
{
104+
return $this->isPrivate;
105+
}
106+
107+
public function setIsPrivate($isPrivate)
108+
{
109+
$this->isPrivate = $isPrivate;
110+
}
111+
}

src/Types/Gifts.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace TelegramBot\\Api\\Types;
4+
5+
use TelegramBot\\Api\\BaseType;
6+
use TelegramBot\\Api\\TypeInterface;
7+
8+
class Gifts extends BaseType implements TypeInterface
9+
{
10+
protected static $requiredParams = ['gifts'];
11+
12+
protected static $map = [
13+
'gifts' => ArrayOfGift::class,
14+
];
15+
16+
protected $gifts;
17+
18+
public function getGifts()
19+
{
20+
return $this->gifts;
21+
}
22+
23+
public function setGifts($gifts)
24+
{
25+
$this->gifts = $gifts;
26+
}
27+
}

0 commit comments

Comments
 (0)