Skip to content

Commit 02c2a5c

Browse files
committed
Fixed & Refactored Tests
1 parent 69f32c6 commit 02c2a5c

5 files changed

Lines changed: 40 additions & 6 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"scripts": {
3737
"test": "@php vendor/bin/pest --fail-on-warning --profile",
38-
"psalm": "@php vendor/bin/psalm",
38+
"psalm": "@php vendor/bin/psalm --config=psalm.xml",
3939
"runkit": "./vendor/bin/install-runkit.sh"
4040
},
4141
"require": {
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<?php
22

3-
use TelegramSDK\BotAPI\Utils;
4-
53
it("returns false when PRODUCTION constant is not defined", function () {
64
if(defined("PRODUCTION"))
75
runkit7_constant_remove("PRODUCTION");
86

9-
expect(Utils::isProduction())->toBeFalse();
7+
expect(\TelegramSDK\BotAPI\Utils\isProduction())->toBeFalse();
108
});
119

1210
it("returns true when PRODUCTION constant is defined and true", function () {
@@ -16,7 +14,7 @@
1614
define("PRODUCTION", true);
1715

1816

19-
expect(Utils::isProduction())->toBeTrue();
17+
expect(\TelegramSDK\BotAPI\Utils\isProduction())->toBeTrue();
2018
});
2119

2220
it("returns false when PRODUCTION constant is defined and false", function () {
@@ -25,5 +23,5 @@
2523
else
2624
define("PRODUCTION", false);
2725

28-
expect(Utils::isProduction())->toBeFalse();
26+
expect(\TelegramSDK\BotAPI\Utils\isProduction())->toBeFalse();
2927
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use TelegramSDK\BotAPI\Utils\Translator;
4+
5+
it('translates a string', function () {
6+
$translator = new Translator((object)[
7+
'hello' => 'Hello',
8+
'world' => 'World',
9+
], [
10+
'Hello' => 'Bonjour',
11+
'World' => 'Monde',
12+
]);
13+
14+
expect($translator->translate('Hello, World'))->toBe('Bonjour, Monde');
15+
});
16+
17+
it('translates a property value', function () {
18+
// Create an instance of the Translator class
19+
$translator = new Translator((object)[
20+
'greeting' => 'Hello, World',
21+
], [
22+
'Hello' => 'Bonjour',
23+
'World' => 'Monde',
24+
]);
25+
26+
expect($translator->greeting)->toBe('Bonjour, Monde');
27+
});
28+
29+
it('returns null for non-existing property', function () {
30+
$translator = new Translator((object)[
31+
'hello' => 'Hello',
32+
'world' => 'World',
33+
]);
34+
35+
expect($translator->nonExistingProperty)->toBeNull();
36+
});

0 commit comments

Comments
 (0)