Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Fixed issue where inline files where not being detected as changed #60

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Bundler/Pipeline/ContentPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private function checkIfChanged(File $output_file, DependencyNodeInterface $depe
$files = [];

// Collect all inline dependencies, since if any of those changed we need to recompile.
$walker = new TreeWalker(function (DependencyNodeInterface $d) use (&$files) {
if (!$d->isInlineDependency()) {
$walker = new TreeWalker(function (DependencyNodeInterface $d) use ($dependency, &$files) {
if ($d !== $dependency && !$d->isInlineDependency()) {
return false;
}

Expand Down
49 changes: 49 additions & 0 deletions test/Bundler/Pipeline/ContentPipelineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Hostnet\Component\Resolver\Import\RootFile;
use Hostnet\Component\Resolver\Module;
use Hostnet\Component\Resolver\Report\NullReporter;
use Hostnet\Component\Resolver\Report\ReporterInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Psr\Log\NullLogger;
Expand Down Expand Up @@ -156,6 +157,54 @@ public function testPushDevAlreadyUpToDate()
);
}

public function testPushDevInlineChanged()
{
$reporter = new class implements ReporterInterface
{
public $files;

public function reportOutputFile(File $file): void
{
}
public function reportFileDependencies(File $file, array $dependencies): void
{
}
public function reportFileState(File $file, string $state): void
{
$this->files[$file->path] = $state;
}
public function reportFileContent(File $file, string $content): void
{
}
};

$this->config->isDev()->willReturn(true);
$this->config->getSourceRoot()->willReturn('fixtures');
$this->config->getCacheDir()->willReturn(__DIR__ . '/cache/new');
$this->config->getReporter()->willReturn($reporter);

$input_file = new RootFile(new Module('fixtures/bar.foo', 'fixtures/bar.foo'));
$target_file = new File('fixtures/output.foo');
$reader = new FileReader(__DIR__);

$file = tempnam(__DIR__, 'asset');

try {
$input_file->addChild($dep = new Dependency(new File($file), true));

$this->content_pipeline->addProcessor(new IdentityProcessor('foo'));
$output = $this->content_pipeline->push([$input_file, $dep], $reader, $target_file);

self::assertEquals("foobar\n", $output);
self::assertEquals([
'fixtures/bar.foo' => ReporterInterface::STATE_BUILT,
$file => ReporterInterface::STATE_INLINE,
], $reporter->files);
} finally {
unlink($file);
}
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage Failed to compile resource "input.js".
Expand Down