Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 48 additions & 2 deletions spec/Repo/Milestone/Converter/GithubMilestoneConverterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function it_will_have_milestone_description_in_converted_result($arrayDat
}

/**
* @dataProvider provideAllMilestones
* @dataProvider provideMilestonesWithCreator
*/
public function it_will_have_user_id_of_creator_in_converted_result($arrayData)
{
Expand All @@ -131,7 +131,7 @@ public function it_will_have_user_id_of_creator_in_converted_result($arrayData)
}

/**
* @dataProvider provideAllMilestones
* @dataProvider provideMilestonesWithCreator
*/
public function it_will_have_creator_in_converted_result($arrayData)
{
Expand All @@ -141,6 +141,26 @@ public function it_will_have_creator_in_converted_result($arrayData)
->shouldBeAnInstanceOf('DevBoardLib\GithubCore\User\GithubUserSource');
}

/**
* @dataProvider provideMilestonesWithOutCreator
*/
public function it_will_have_null_for_user_id_of_creator_in_converted_result($arrayData)
{
$result = $this->convert($arrayData);

$result->getCreatedByUserId()->shouldReturn(null);
}

/**
* @dataProvider provideMilestonesWithOutCreator
*/
public function it_will_have_null_for_creator_in_converted_result($arrayData)
{
$result = $this->convert($arrayData);

$result->getCreatedByUser()->shouldReturn(null);
}

/**
* @dataProvider provideAllMilestones
*/
Expand Down Expand Up @@ -290,6 +310,32 @@ public function provideMilestonesWithOutDueDate()
return $testData;
}

public function provideMilestonesWithCreator()
{
$testData = [];

foreach ($this->getDataProvider()->getAllMilestones() as $item) {
if (null !== $item['creator']) {
$testData[] = [$item];
}
}

return $testData;
}

public function provideMilestonesWithOutCreator()
{
$testData = [];

foreach ($this->getDataProvider()->getAllMilestones() as $item) {
if (null === $item['creator']) {
$testData[] = [$item];
}
}

return $testData;
}

protected function getDataProvider()
{
return new SampleDataProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function convertMilestone($data)
GithubMilestoneStateFactory::create($data['state']),
$data['title'],
$data['description'],
$this->getUser($data['creator']),
$this->getUserIfExists($data['creator']),
$data['open_issues'],
$data['closed_issues'],
$this->getDateIfExists($data['due_on']),
Expand Down
20 changes: 1 addition & 19 deletions tests/sample-data/devboard/test-hitman/milestones.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,7 @@
"number": 2,
"title": "Second milestone",
"description": "Milestone #2",
"creator": {
"login": "msvrtan",
"id": 1780572,
"avatar_url": "https://avatars.githubusercontent.com/u/1780572?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/msvrtan",
"html_url": "https://github.com/msvrtan",
"followers_url": "https://api.github.com/users/msvrtan/followers",
"following_url": "https://api.github.com/users/msvrtan/following{/other_user}",
"gists_url": "https://api.github.com/users/msvrtan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/msvrtan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/msvrtan/subscriptions",
"organizations_url": "https://api.github.com/users/msvrtan/orgs",
"repos_url": "https://api.github.com/users/msvrtan/repos",
"events_url": "https://api.github.com/users/msvrtan/events{/privacy}",
"received_events_url": "https://api.github.com/users/msvrtan/received_events",
"type": "User",
"site_admin": false
},
"creator": null,
"open_issues": 1,
"closed_issues": 1,
"state": "open",
Expand Down