From e6b077a746d9a0380d6bbb85298948b60e678ff8 Mon Sep 17 00:00:00 2001 From: Eirik Stanghelle Morland Date: Sat, 22 Jan 2022 19:05:15 +0100 Subject: [PATCH] Add option for allow_update_direct_with_only_dependencies (#16) * 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 --- src/Config.php | 6 +++++ tests/UnitTest.php | 34 +++++++++++++++++++++++++++++ tests/fixtures/allow_indirect.json | 7 ++++++ tests/fixtures/allow_indirect2.json | 7 ++++++ tests/fixtures/allow_indirect3.json | 7 ++++++ 5 files changed, 61 insertions(+) create mode 100644 tests/fixtures/allow_indirect.json create mode 100644 tests/fixtures/allow_indirect2.json create mode 100644 tests/fixtures/allow_indirect3.json diff --git a/src/Config.php b/src/Config.php index 727abc5..264385c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -33,6 +33,7 @@ public function getDefaultConfig() 'number_of_concurrent_updates' => 0, 'branch_prefix' => '', 'commit_message_convention' => '', + 'allow_update_indirect_with_direct' => 0, ]; } @@ -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; diff --git a/tests/UnitTest.php b/tests/UnitTest.php index de99ba3..6b2a5ed 100644 --- a/tests/UnitTest.php +++ b/tests/UnitTest.php @@ -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. * @@ -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 [ diff --git a/tests/fixtures/allow_indirect.json b/tests/fixtures/allow_indirect.json new file mode 100644 index 0000000..a33da0f --- /dev/null +++ b/tests/fixtures/allow_indirect.json @@ -0,0 +1,7 @@ +{ + "extra": { + "violinist": { + "allow_update_indirect_with_direct": "yes_of_course_this_should_be_an_int_but_this_evaluates_to_true" + } + } +} diff --git a/tests/fixtures/allow_indirect2.json b/tests/fixtures/allow_indirect2.json new file mode 100644 index 0000000..d38a1ca --- /dev/null +++ b/tests/fixtures/allow_indirect2.json @@ -0,0 +1,7 @@ +{ + "extra": { + "violinist": { + "allow_update_indirect_with_direct": 1 + } + } +} diff --git a/tests/fixtures/allow_indirect3.json b/tests/fixtures/allow_indirect3.json new file mode 100644 index 0000000..b6af763 --- /dev/null +++ b/tests/fixtures/allow_indirect3.json @@ -0,0 +1,7 @@ +{ + "extra": { + "violinist": { + "allow_update_indirect_with_direct": 0 + } + } +}