Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #50301 [FrameworkBundle] Ignore vars from dotenv files in secrets…
…:list (nicolas-grekas) This PR was merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Ignore vars from dotenv files in secrets:list | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Sidekick of #48705 Commits ------- 8561045 [FrameworkBundle] Ignore vars from dotenv files in secrets:list
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsListCommandTest.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,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Command; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Bundle\FrameworkBundle\Command\SecretsListCommand; | ||
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
class SecretsListCommandTest extends TestCase | ||
{ | ||
public function testExecute() | ||
{ | ||
$vault = $this->createMock(AbstractVault::class); | ||
$vault->method('list')->willReturn(['A' => 'a', 'B' => 'b', 'C' => null, 'D' => null, 'E' => null]); | ||
$localVault = $this->createMock(AbstractVault::class); | ||
$localVault->method('list')->willReturn(['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null]); | ||
$command = new SecretsListCommand($vault, $localVault); | ||
$tester = new CommandTester($command); | ||
$this->assertSame(0, $tester->execute([])); | ||
|
||
$expectedOutput = <<<EOTXT | ||
// Use "%%env(<name>)%%" to reference a secret in a config file. | ||
// To reveal the secrets run %s secrets:list --reveal | ||
-------- -------- ------------- | ||
Secret Value Local Value | ||
-------- -------- ------------- | ||
A "a" | ||
B "b" "A" | ||
C ****** | ||
D ****** | ||
E ****** | ||
-------- -------- ------------- | ||
// Local values override secret values. | ||
// Use secrets:set --local to define them. | ||
EOTXT; | ||
$this->assertStringMatchesFormat($expectedOutput, trim(preg_replace('/ ++$/m', '', $tester->getDisplay(true)), "\n")); | ||
} | ||
} |