Skip to content

Commit

Permalink
Add option for allow_update_direct_with_only_dependencies (#16)
Browse files Browse the repository at this point in the history
* Update Config.php

* Update Config.php

* Create allow_indirect.json

* Update UnitTest.php

* Update UnitTest.php

* Create allow_indirect2.json

* Create allow_indirect3.json

* Update UnitTest.php
  • Loading branch information
eiriksm authored Jan 22, 2022
1 parent 619a198 commit e6b077a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function getDefaultConfig()
'number_of_concurrent_updates' => 0,
'branch_prefix' => '',
'commit_message_convention' => '',
'allow_update_indirect_with_direct' => 0,
];
}

Expand Down Expand Up @@ -71,6 +72,11 @@ public function hasConfigForKey($key)
return !empty($this->configOptionsSet[$key]);
}

public function shouldUpdateIndirectWithDirect()
{
return (bool) $this->config->allow_update_indirect_with_direct;
}

public function shouldAlwaysUpdateAll()
{
return (bool) $this->config->always_update_all;
Expand Down
34 changes: 34 additions & 0 deletions tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ public function testUpdatesBeyondConstraint($filename, $expected_result)
self::assertEquals($expected_result, $data->shouldAllowUpdatesBeyondConstraint());
}

/**
* Test the allow_update_direct_with_only_dependencies option.
*
* @dataProvider getAllowUpdateDirect
*/
public function testAllowUpdateDirect($filename, $expected_result)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_result, $data->shouldUpdateIndirectWithDirect());
}

/**
* Test the always_update_all option.
*
Expand Down Expand Up @@ -297,6 +308,29 @@ public function getAlwaysUpdateAll()
];
}

public function getAllowUpdateDirect()
{
return [
[
'empty.json',
false,
],
[
'allow_indirect.json',
true,
],
[
'allow_indirect2.json',
true,
],
[
'allow_indirect3.json',
false,
],
];
}


public function getUpdatesBeyondConstraint()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/allow_indirect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"allow_update_indirect_with_direct": "yes_of_course_this_should_be_an_int_but_this_evaluates_to_true"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/allow_indirect2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"allow_update_indirect_with_direct": 1
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/allow_indirect3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"allow_update_indirect_with_direct": 0
}
}
}

0 comments on commit e6b077a

Please sign in to comment.