|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use CSlant\TelegramGitNotifier\Bot; |
4 | | -use CSlant\TelegramGitNotifier\Enums\Platform; |
5 | 4 | use CSlant\TelegramGitNotifier\Models\Event; |
6 | 5 | use CSlant\TelegramGitNotifier\Models\Setting; |
7 | 6 |
|
8 | 7 | it('can be instantiated with default parameters', function () { |
9 | | - $bot = new Bot(); |
| 8 | + $bot = new Bot( |
| 9 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 10 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 11 | + ); |
10 | 12 |
|
11 | 13 | expect($bot)->toBeInstanceOf(Bot::class) |
12 | 14 | ->and($bot->event)->toBeInstanceOf(Event::class) |
|
15 | 17 |
|
16 | 18 | it('can be instantiated with custom event', function () { |
17 | 19 | $event = new Event(); |
18 | | - $bot = new Bot(event: $event); |
| 20 | + $bot = new Bot( |
| 21 | + event: $event, |
| 22 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 23 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 24 | + ); |
19 | 25 |
|
20 | 26 | expect($bot->event)->toBe($event); |
21 | 27 | }); |
22 | 28 |
|
23 | 29 | it('can be instantiated with custom platform', function () { |
24 | | - $bot = new Bot(platform: Platform::GITHUB); |
| 30 | + $bot = new Bot( |
| 31 | + platform: 'github', |
| 32 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 33 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 34 | + ); |
25 | 35 |
|
26 | | - expect($bot->event->platform)->toBe(Platform::GITHUB); |
| 36 | + expect($bot->event->platform)->toBe('github'); |
27 | 37 | }); |
28 | 38 |
|
29 | 39 | it('can be instantiated with custom setting', function () { |
30 | 40 | $setting = new Setting(); |
31 | | - $bot = new Bot(setting: $setting); |
| 41 | + $bot = new Bot( |
| 42 | + setting: $setting, |
| 43 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 44 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 45 | + ); |
32 | 46 |
|
33 | 47 | expect($bot->setting)->toBe($setting); |
34 | 48 | }); |
35 | 49 |
|
36 | 50 | it('sets default platform when not specified', function () { |
37 | | - $bot = new Bot(); |
| 51 | + $bot = new Bot( |
| 52 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 53 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 54 | + ); |
38 | 55 |
|
39 | | - expect($bot->event->platform)->toBe(Platform::DEFAULT); |
| 56 | + expect($bot->event->platform)->toBe('github'); |
40 | 57 | }); |
41 | 58 |
|
42 | 59 | it('validates platform file on construction', function () { |
43 | 60 | // This should not throw if the platform file exists |
44 | | - $bot = new Bot(platform: Platform::GITHUB); |
| 61 | + $bot = new Bot( |
| 62 | + platform: 'github', |
| 63 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 64 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 65 | + ); |
45 | 66 |
|
46 | 67 | expect($bot->event->getEventConfig())->toBeArray(); |
47 | 68 | }); |
48 | 69 |
|
49 | 70 | it('validates setting file on construction', function () { |
50 | | - $bot = new Bot(); |
| 71 | + $bot = new Bot( |
| 72 | + platformFile: __DIR__.'/../config/jsons/github-events.json', |
| 73 | + settingFile: __DIR__.'/../config/jsons/tgn-settings.json' |
| 74 | + ); |
51 | 75 |
|
52 | 76 | expect($bot->setting->getSettingFile())->not->toBeEmpty(); |
53 | 77 | }); |
0 commit comments