Skip to content

Commit

Permalink
Merge 0d419db into 4e9b096
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Sep 14, 2021
2 parents 4e9b096 + 0d419db commit 7de3e72
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Config.php
Expand Up @@ -85,6 +85,15 @@ public function getBundledPackagesForPackage($package_name)
return [];
}

public function getAssignees()
{
if (!is_array($this->config->assignees)) {
return [];
}

return $this->config->assignees;
}

public function getBlockList()
{
if (!is_array($this->config->blocklist)) {
Expand Down
35 changes: 35 additions & 0 deletions tests/UnitTest.php
Expand Up @@ -135,12 +135,47 @@ public function testOnlyDirectDependencies($filename, $expected_result)
self::assertEquals($expected_result, $data->shouldCheckDirectOnly());
}

/**
* Test the assignees part.
*
* @dataProvider getAssignees
*/
public function testAssignees($filename, $expected_reesult)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_reesult, $data->getAssignees());
}

protected function createDataFromFixture($filename)
{
$file_contents = json_decode(file_get_contents(__DIR__ . '/fixtures/' . $filename));
return Config::createFromComposerData($file_contents);
}

public function getAssignees()
{
return [
[
'empty.json',
[],
],
[
'assignees.json',
[],
],
[
'assignees2.json',
[],
],
[
'assignees3.json',
[
"test_user"
],
],
];
}

public function getBranchPrefix()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/assignees.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"assignees": "should_be_array"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/assignees2.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"assignees": []
}
}
}
9 changes: 9 additions & 0 deletions tests/fixtures/assignees3.json
@@ -0,0 +1,9 @@
{
"extra": {
"violinist": {
"assignees": [
"test_user"
]
}
}
}

0 comments on commit 7de3e72

Please sign in to comment.