|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of forecast.it.fill project. |
|
7
|
|
|
* (c) Patrick Jaja <[email protected]> |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace ForecastAutomationTests\JiraClient\Shared\Plugin; |
|
13
|
|
|
|
|
14
|
|
|
use ForecastAutomation\JiraClient\JiraClientFacade; |
|
15
|
|
|
use ForecastAutomation\JiraClient\Shared\Plugin\JiraActivityPlugin; |
|
16
|
|
|
use JiraRestApi\Issue\Comment; |
|
17
|
|
|
use JiraRestApi\Request\Author; |
|
18
|
|
|
use PHPUnit\Framework\TestCase; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @internal |
|
22
|
|
|
* @covers |
|
23
|
|
|
*/ |
|
24
|
|
|
final class JiraActivityPluginTest extends TestCase |
|
25
|
|
|
{ |
|
26
|
|
|
public const TICKET_PATTERN = 'TESTNR-1'; |
|
27
|
|
|
public const TESTUSER_EXAMPLE_COM = '[email protected]'; |
|
28
|
|
|
public const TICKET_COMMENT_UPDATED = '2021-01-02 11:00:00'; |
|
29
|
|
|
public const TICKET_COMMENT_BODY = 'test'; |
|
30
|
|
|
|
|
31
|
|
|
public function testCanReadEvents(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$comments = $this->createJiraActivityPlugin()->collect()->wait(); |
|
34
|
|
|
static::assertSame(self::TICKET_PATTERN, $comments->offsetGet(0)->needle); |
|
35
|
|
|
static::assertSame('Ticket Bearbeitung: TESTNR-1 - test...', $comments->offsetGet(0)->description); |
|
36
|
|
|
static::assertSame('2021-01-02', $comments->offsetGet(0)->created->format('Y-m-d')); |
|
37
|
|
|
static::assertSame(JiraActivityPlugin::ACTIVITY_DURATION, $comments->offsetGet(0)->duration); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
private function createJiraActivityPlugin(): JiraActivityPlugin |
|
41
|
|
|
{ |
|
42
|
|
|
$gitlabClientFacadeMock = $this->getMockBuilder(JiraClientFacade::class) |
|
43
|
|
|
->onlyMethods(['getComments']) |
|
44
|
|
|
->getMock() |
|
45
|
|
|
; |
|
46
|
|
|
|
|
47
|
|
|
$testComment = new Comment(); |
|
48
|
|
|
$testComment->body = self::TICKET_COMMENT_BODY; |
|
49
|
|
|
$testComment->updated = self::TICKET_COMMENT_UPDATED; |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$testComments = new \stdClass(); |
|
52
|
|
|
$testComments->comments = [$testComment]; |
|
53
|
|
|
$testAuthor = new Author(); |
|
54
|
|
|
$testAuthor->emailAddress = self::TESTUSER_EXAMPLE_COM; |
|
55
|
|
|
$testComment->author = $testAuthor; |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
$gitlabClientFacadeMock |
|
58
|
|
|
->method('getComments') |
|
59
|
|
|
->willReturn([self::TICKET_PATTERN => [$testComment]]) |
|
60
|
|
|
; |
|
61
|
|
|
|
|
62
|
|
|
$gitlabActivityPluginMock = $this->getMockBuilder(JiraActivityPlugin::class) |
|
63
|
|
|
->onlyMethods(['getFacade']) |
|
64
|
|
|
->getMock() |
|
65
|
|
|
; |
|
66
|
|
|
$gitlabActivityPluginMock |
|
67
|
|
|
->method('getFacade') |
|
68
|
|
|
->willReturn($gitlabClientFacadeMock) |
|
69
|
|
|
; |
|
70
|
|
|
|
|
71
|
|
|
return $gitlabActivityPluginMock; |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..