Skip to content

Commit

Permalink
Merge branch 'backport/bug/dump-check' into 5.4
Browse files Browse the repository at this point in the history
Backporting #12
  • Loading branch information
lcobucci committed Jan 12, 2018
2 parents b89022f + db2194d commit 6dcc58c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Compiler/DumpXmlContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(ConfigCacheInterface $configCache)

public function process(ContainerBuilder $container): void
{
if (! $container->getParameter('app.devmode') || ! $this->configCache->isFresh()) {
if (! $container->getParameter('app.devmode') || $this->configCache->isFresh()) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions test/Compiler/DumpXmlContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public function processShouldBeSkippedWhenDevModeIsNotEnabled(): void
* @covers \Lcobucci\DependencyInjection\Compiler\DumpXmlContainer::__construct
* @covers \Lcobucci\DependencyInjection\Compiler\DumpXmlContainer::process
*/
public function processShouldBeSkippedWhenCacheIsNotFresh(): void
public function processShouldBeSkippedWhenCacheIsFresh(): void
{
$this->configCache->method('isFresh')
->willReturn(false);
->willReturn(true);

$this->configCache->expects($this->never())
->method('write');
Expand All @@ -77,7 +77,7 @@ public function processShouldDumpTheContainerUsingTheXmlDumper(): void
);

$this->configCache->method('isFresh')
->willReturn(true);
->willReturn(false);

$this->configCache->expects($this->once())
->method('write')
Expand Down
13 changes: 12 additions & 1 deletion test/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Lcobucci\DependencyInjection;

use Lcobucci\DependencyInjection\Compiler\DumpXmlContainer;
use Lcobucci\DependencyInjection\Compiler\ParameterBag;
use Lcobucci\DependencyInjection\Config\ContainerConfiguration;
use org\bovigo\vfs\vfsStream;
Expand Down Expand Up @@ -81,7 +82,16 @@ public function generateShouldCompileAndLoadTheContainer(): void

$config = new ContainerConfiguration(
[vfsStream::url('tests/services.yml')],
[[new ParameterBag(['app.devmode' => true]), PassConfig::TYPE_BEFORE_OPTIMIZATION]]
[
[new ParameterBag(['app.devmode' => true]), PassConfig::TYPE_BEFORE_OPTIMIZATION],
[
new DumpXmlContainer(
new ConfigCache(vfsStream::url('tests/dump.xml'), true)
),
PassConfig::TYPE_AFTER_REMOVING,
-255
],
]
);

$dump = new ConfigCache(vfsStream::url('tests/container.php'), false);
Expand All @@ -99,5 +109,6 @@ function (SymfonyBuilder $container, array $paths) {

self::assertInstanceOf(ContainerInterface::class, $container);
self::assertInstanceOf(stdClass::class, $container->get('testing'));
self::assertFileExists(vfsStream::url('tests/dump.xml'));
}
}

0 comments on commit 6dcc58c

Please sign in to comment.