1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use CSlant\TelegramGitNotifier\Bot; |
4
|
|
|
|
5
|
|
|
beforeEach(function () { |
6
|
|
|
$this->bot = new Bot(); |
|
|
|
|
7
|
|
|
}); |
8
|
|
|
|
9
|
|
|
it('should return true', function () { |
10
|
|
|
$this->assertTrue(true); |
|
|
|
|
11
|
|
|
}); |
12
|
|
|
|
13
|
|
|
it('platform can be set for event with platform parameter', function () { |
14
|
|
|
$this->bot->setPlatFormForEvent('gitlab'); |
|
|
|
|
15
|
|
|
expect($this->bot->event->platform)->toBe('gitlab'); |
16
|
|
|
}); |
17
|
|
|
|
18
|
|
|
it('platform can be set for event with null parameter', function () { |
19
|
|
|
$this->bot->setPlatFormForEvent(); |
|
|
|
|
20
|
|
|
expect($this->bot->event->platform)->toBe('github'); |
21
|
|
|
}); |
22
|
|
|
|
23
|
|
|
it('platform can be set for event with platform file', function () { |
24
|
|
|
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); |
|
|
|
|
25
|
|
|
expect($this->bot->event->platform)->toBe('gitlab') |
26
|
|
|
->and($this->bot->event->getPlatformFile()) |
27
|
|
|
->toBe('storage/json/tgn/gitlab-events.json'); |
28
|
|
|
}); |
29
|
|
|
|
30
|
|
|
it('can get json config for event - github', function () { |
31
|
|
|
$this->bot->setPlatFormForEvent(); |
|
|
|
|
32
|
|
|
expect($this->bot->event->getEventConfig())->toBeArray() |
33
|
|
|
->and($this->bot->event->getEventConfig())->toHaveKey('issue_comment'); |
34
|
|
|
}); |
35
|
|
|
|
36
|
|
|
it('can get json config for event - gitlab', function () { |
37
|
|
|
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); |
|
|
|
|
38
|
|
|
expect($this->bot->event->getEventConfig())->toBeArray() |
39
|
|
|
->and($this->bot->event->getEventConfig())->toHaveKey('tag_push'); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
it('setting file is valid', function () { |
43
|
|
|
$this->bot->updateSetting(); |
|
|
|
|
44
|
|
|
$this->bot->validateSettingFile(); |
45
|
|
|
|
46
|
|
|
expect($this->bot->setting->getSettings())->toBeArray(); |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
it('platform file is valid', function () { |
50
|
|
|
$this->bot->setPlatFormForEvent(); |
|
|
|
|
51
|
|
|
$this->bot->validatePlatformFile(); |
52
|
|
|
|
53
|
|
|
expect($this->bot->event->getEventConfig())->toBeArray(); |
54
|
|
|
}); |
55
|
|
|
|