Issues (29)

tests/ValidatorTest.php (7 issues)

1
<?php
2
3
use CSlant\TelegramGitNotifier\Bot;
4
use CSlant\TelegramGitNotifier\Objects\Validator;
5
6
beforeEach(function () {
7
    $this->bot = new Bot();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
8
    $this->bot->updateSetting('storage/json/tgn/setting.json');
9
    $this->bot->setPlatFormForEvent();
10
    $this->validator = new Validator($this->bot->setting, $this->bot->event);
11
});
12
13
it('can validate the event that has no action to send a notification - GitHub', function () {
14
    $result = $this->validator->isAccessEvent('github', 'push', (object)[]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
15
    expect($result)->toBeTrue();
16
});
17
18
it('can validate the event that has an action to send a notification - GitHub', function () {
19
    $result = $this->validator->isAccessEvent('github', 'pull_request', (object)[
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
20
        'action' => 'opened',
21
    ]);
22
    expect($result)->toBeTrue();
23
});
24
25
it('can\'t validate the event that has an action but no payload to send a notification - GitHub', function () {
26
    $result = $this->validator->isAccessEvent('github', 'pull_request', (object)[]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
27
    expect($result)->toBeFalse();
28
});
29
30
it('can validate the event that has no action to send a notification - gitlab', function () {
31
    $this->bot->setPlatFormForEvent('gitlab');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
32
    $result = $this->validator->isAccessEvent('gitlab', 'push', (object)[]);
33
    expect($result)->toBeTrue();
34
});
35
36
it('can validate the event that has an action to send a notification - gitlab', function () {
37
    $this->bot->setPlatFormForEvent('gitlab');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
38
    $result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[
39
        'action' => 'open',
40
    ]);
41
    expect($result)->toBeTrue();
42
});
43
44
it('can\'t validate the event that has an action but no payload to send a notification - gitlab', function () {
45
    $this->bot->setPlatFormForEvent('gitlab');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
46
    $result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[]);
47
    expect($result)->toBeFalse();
48
});
49