Skip to content

Commit

Permalink
Make it possible to indicate ignore platform reqs (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored Oct 16, 2023
1 parent 6fc48dd commit 6c77af1
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getDefaultConfig()
return (object) [
'always_update_all' => 0,
'always_allow_direct_dependencies' => 0,
'ignore_platform_requirements' => 0,
'allow_list' => [],
'update_dev_dependencies' => 1,
'check_only_direct_dependencies' => 1,
Expand Down Expand Up @@ -287,6 +288,11 @@ public function getBranchPrefix()
return '';
}

public function shouldIgnorePlatformRequirements() : bool
{
return (bool) $this->config->ignore_platform_requirements;
}

public function getCommitMessageConvention()
{
if (!$this->config->commit_message_convention || !is_string($this->config->commit_message_convention)) {
Expand Down
41 changes: 41 additions & 0 deletions tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ public function testAlwaysDirect($filename, $expected_result)
self::assertEquals($expected_result, $data->shouldAlwaysAllowDirect());
}

/**
* Test the different things we can set in ignore platform.
*
* @dataProvider getIgnorePlatform
*/
public function testIgnorePlatform($filename, $expected_result)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_result, $data->shouldIgnorePlatformRequirements());
}

/**
* Test the different things we can set in run scripts, and what we expect from it.
*
Expand Down Expand Up @@ -752,6 +763,36 @@ public function emptyConfigs()
];
}

public function getIgnorePlatform()
{
return [
[
'empty.json',
false,
],
[
'ignore_platform.json',
true
],
[
'ignore_platform2.json',
true
],
[
'ignore_platform3.json',
true
],
[
'ignore_platform4.json',
false
],
[
'ignore_platform5.json',
false
],
];
}

public function getAlwaysAllowDirect()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/ignore_platform.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"ignore_platform_requirements": "yes_of_course_this_should_be_an_int_but_this_evaluates_to_true"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/ignore_platform2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"ignore_platform_requirements": 1
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/ignore_platform3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"ignore_platform_requirements": "1"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/ignore_platform4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"ignore_platform_requirements": "0"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/ignore_platform5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"ignore_platform_requirements": 0
}
}
}

0 comments on commit 6c77af1

Please sign in to comment.