-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make configuration and dependency injection container immutable
This avoids having other services hacking into the DI container or config object at runtime (avoiding inconsistent retrieval of services
- Loading branch information
Showing
8 changed files
with
155 additions
and
17 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
15 changes: 15 additions & 0 deletions
15
lib/Doctrine/Migrations/Configuration/Exception/FrozenConfiguration.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Configuration\Exception; | ||
|
||
use LogicException; | ||
|
||
final class FrozenConfiguration extends LogicException implements ConfigurationException | ||
{ | ||
public static function new() : self | ||
{ | ||
return new self('The configuration is frozen and cannot be edited anymore.'); | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Exception; | ||
|
||
use LogicException; | ||
|
||
final class FrozenDependencies extends LogicException implements MigrationException | ||
{ | ||
public static function new() : self | ||
{ | ||
return new self('The dependencies are frozen and cannot be edited anymore.'); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
tests/Doctrine/Migrations/Tests/Tools/Console/Command/DoctrineCommandTest.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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Tests\Tools\Console\Command; | ||
|
||
use Doctrine\Migrations\DependencyFactory; | ||
use Doctrine\Migrations\Tests\MigrationTestCase; | ||
use Doctrine\Migrations\Tools\Console\Command\DoctrineCommand; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
class DoctrineCommandTest extends MigrationTestCase | ||
{ | ||
public function testCommandFreezes() : void | ||
{ | ||
$dependencyFactory = $this->getMockBuilder(DependencyFactory::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['freeze']) | ||
->getMock(); | ||
|
||
$dependencyFactory | ||
->expects(self::once()) | ||
->method('freeze'); | ||
|
||
$command = $this->getMockBuilder(DoctrineCommand::class) | ||
->setConstructorArgs(['foo', $dependencyFactory]) | ||
->setMethods(['execute']) | ||
->getMockForAbstractClass(); | ||
|
||
$commandTester = new CommandTester($command); | ||
|
||
$commandTester->execute( | ||
[], | ||
['interactive' => false] | ||
); | ||
} | ||
} |