forked from phar-io/phive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[phar-io#233 phar-io#17]: Rethink configuration storage at project level
- Read configuration from .phive and current working directory (phars + auth) - Update skel command - Add warning in output if both configuration exist - Add project level repositories - Copy phive.xml to .phive/phars.xml
- Loading branch information
Showing
18 changed files
with
229 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="phpab" version="^1.25.1" installed="1.25.9" location="./tools/phpab" copy="false"/> | ||
<phar name="phpunit" version="^8.1" installed="8.5.3" location="./tools/phpunit" copy="false"/> | ||
<phar name="phpstan" version="^0.11.5" installed="0.12.18" location="./tools/phpstan" copy="false"/> | ||
<phar name="psalm" version="^3.4.10" installed="3.11.2" location="./tools/psalm" copy="false"/> | ||
<phar name="php-cs-fixer" version="^2.15.3" installed="2.16.3" location="./tools/php-cs-fixer" copy="false"/> | ||
</phive> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types = 1); | ||
namespace PharIo\Phive; | ||
|
||
use PharIo\FileSystem\Directory; | ||
use PharIo\Phive\Cli\Output; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AuthXmlConfigFileLocatorTest extends TestCase { | ||
public function testWarnAboutDoubleConfigFile(): void { | ||
$environmentMock = $this->getEnvironmentMock(); | ||
$environmentMock->method('getWorkingDirectory') | ||
->willReturn(new Directory(__DIR__ . '/fixtures/doubleConfig')); | ||
|
||
$outputMock = $this->getOutputMock(); | ||
$outputMock | ||
->expects($this->once()) | ||
->method('writeWarning') | ||
->with('Both .phive/auth.xml and phive-auth.xml shouldn\'t be defined. Please prefer using .phive/auth.xml'); | ||
|
||
$locator = new AuthXmlConfigFileLocator( | ||
$environmentMock, | ||
$this->getConfigMock(), | ||
$outputMock | ||
); | ||
|
||
$locator->getFile(false); | ||
} | ||
|
||
/** | ||
* @return Output|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getOutputMock() { | ||
return $this->createMock(Output::class); | ||
} | ||
|
||
/** | ||
* @return Environment|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private function getEnvironmentMock() { | ||
return $this->createMock(Environment::class); | ||
} | ||
|
||
/** | ||
* @return Config|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private function getConfigMock() { | ||
return $this->createMock(Config::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/unit/shared/config/PhiveXmlConfigFileLocatorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types = 1); | ||
namespace PharIo\Phive; | ||
|
||
use PharIo\FileSystem\Directory; | ||
use PharIo\Phive\Cli\Output; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PhiveXmlConfigFileLocatorTest extends TestCase { | ||
public function testWarnAboutDoubleConfigFile(): void { | ||
$environmentMock = $this->getEnvironmentMock(); | ||
$environmentMock->method('getWorkingDirectory') | ||
->willReturn(new Directory(__DIR__ . '/fixtures/doubleConfig')); | ||
|
||
$outputMock = $this->getOutputMock(); | ||
$outputMock | ||
->expects($this->once()) | ||
->method('writeWarning') | ||
->with('Both .phive/phars.xml and phive.xml shouldn\'t be defined. Please prefer using .phive/phars.xml'); | ||
|
||
$locator = new PhiveXmlConfigFileLocator( | ||
$environmentMock, | ||
$this->getConfigMock(), | ||
$outputMock | ||
); | ||
|
||
$locator->getFile(false); | ||
} | ||
|
||
/** | ||
* @return Output|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getOutputMock() { | ||
return $this->createMock(Output::class); | ||
} | ||
|
||
/** | ||
* @return Environment|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private function getEnvironmentMock() { | ||
return $this->createMock(Environment::class); | ||
} | ||
|
||
/** | ||
* @return Config|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private function getConfigMock() { | ||
return $this->createMock(Config::class); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/unit/shared/config/fixtures/doubleConfig/.phive/auth.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
PHIVE AUTH CONFIGURATION SKELETON FILE | ||
This file was automatically generated by PHIVE %%VERSION%% on %%DATE%% | ||
--> | ||
<auth xmlns="https://phar.io/phive-auth"> | ||
|
||
<!-- PHIVE AUTH CONFIGURATION --> | ||
|
||
<!-- | ||
<domain host="api.github.com" type="token" credentials="ThisIsASecretToken" /> | ||
<domain host="example.com" type="basic" username="Aladdin" password="open sesame" /> | ||
<domain host="example.org" type="basic" credentials="QWxhZGRpbjpvcGVuIHNlc2FtZQ==" /> | ||
<domain host="gitlab.com" type="bearer" credentials="ThisIsAPrivateToken" /> | ||
--> | ||
|
||
</auth> |
4 changes: 4 additions & 0 deletions
4
tests/unit/shared/config/fixtures/doubleConfig/.phive/phars.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="theseer/Autoload" version="^1.24.1" installed="1.24.1" location="./tools/phpab"/> | ||
</phive> |
Oops, something went wrong.