Skip to content

Commit

Permalink
Add option for always_update_all (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Jan 21, 2022
1 parent 86cf795 commit 619a198
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Config.php
Expand Up @@ -15,6 +15,7 @@ public function __construct()
public function getDefaultConfig()
{
return (object) [
'always_update_all' => 0,
'allow_list' => [],
'update_dev_dependencies' => 1,
'check_only_direct_dependencies' => 1,
Expand Down Expand Up @@ -70,6 +71,11 @@ public function hasConfigForKey($key)
return !empty($this->configOptionsSet[$key]);
}

public function shouldAlwaysUpdateAll()
{
return (bool) $this->config->always_update_all;
}

public function getTimeZone()
{
if (!is_string($this->config->timezone)) {
Expand Down
41 changes: 41 additions & 0 deletions tests/UnitTest.php
Expand Up @@ -191,6 +191,17 @@ public function testUpdatesBeyondConstraint($filename, $expected_result)
self::assertEquals($expected_result, $data->shouldAllowUpdatesBeyondConstraint());
}

/**
* Test the always_update_all option.
*
* @dataProvider getAlwaysUpdateAll
*/
public function testAlwaysUpdateAll($filename, $expected_result)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_result, $data->shouldAlwaysUpdateAll());
}

/**
* Test the security updates config option.
*
Expand Down Expand Up @@ -256,6 +267,36 @@ public function getUpdateWithDeps()
];
}

public function getAlwaysUpdateAll()
{
return [
[
'empty.json',
false,
],
[
'always_all.json',
true,
],
[
'always_all2.json',
false,
],
[
'always_all3.json',
false,
],
[
'always_all4.json',
true,
],
[
'always_all5.json',
true,
]
];
}

public function getUpdatesBeyondConstraint()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/always_all.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_update_all": "yes_of_course_this_should_be_an_int_but_this_evaluates_to_true"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_all2.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_update_all": 0
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_all3.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_update_all": ""
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_all4.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_update_all": "true"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_all5.json
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_update_all": true
}
}
}

0 comments on commit 619a198

Please sign in to comment.