Skip to content

Commit

Permalink
Add method for update with dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Sep 14, 2021
1 parent ef58376 commit 48856db
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Config.php
Expand Up @@ -63,6 +63,11 @@ public function setConfig($config)
}
}

public function shouldUpdateWithDependencies()
{
return (bool) $this->config->update_with_dependencies;
}

public function shouldAllowUpdatesBeyondConstraint()
{
return (bool) $this->config->allow_updates_beyond_constraint;
Expand Down
37 changes: 37 additions & 0 deletions tests/UnitTest.php
Expand Up @@ -125,6 +125,17 @@ public function testOnePrPerPackage($filename, $expected_result)
self::assertEquals($expected_result, $data->shouldUseOneMergeRequestPerPackage());
}

/**
* Test the update_with_dependencies option.
*
* @dataProvider getUpdateWithDeps
*/
public function testUpdateWithDeps($filename, $expected_result)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_result, $data->shouldUpdateWithDependencies());
}

/**
* Test the allow_updates_beyond_constraint option.
*
Expand Down Expand Up @@ -175,6 +186,32 @@ protected function createDataFromFixture($filename)
return Config::createFromComposerData($file_contents);
}

public function getUpdateWithDeps()
{
return [
[
'empty.json',
true,
],
[
'update_with_dependencies.json',
true,
],
[
'update_with_dependencies2.json',
false,
],
[
'update_with_dependencies3.json',
true,
],
[
'update_with_dependencies4.json',
false,
],
];
}

public function getUpdatesBeyondConstraint()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/update_with_dependencies.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"update_with_dependencies": 1
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/update_with_dependencies2.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"update_with_dependencies": 0
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/update_with_dependencies3.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"update_with_dependencies": "1"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/update_with_dependencies4.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"update_with_dependencies": "0"
}
}
}

0 comments on commit 48856db

Please sign in to comment.