Skip to content

Commit

Permalink
Use contao.web_dir instead of hardcoded web dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus authored and leofeyer committed Nov 26, 2018
1 parent aafb0f1 commit deca785
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected function configureManagerUrlParameter(array $mergedConfig, ContainerBu
if ($mergedConfig['manager_path']) {
$managerPath = $mergedConfig['manager_path'];
} else {
$projectDir = $container->getParameter('kernel.project_dir');
$webDir = $container->getParameter('contao.web_dir');

if (is_file($projectDir . '/web/contao-manager.phar.php')) {
if (is_file($webDir . '/contao-manager.phar.php')) {
$managerPath = 'contao-manager.phar.php';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function setUp(): void

$this->container = new ContainerBuilder();
$this->container->setParameter('kernel.project_dir', $this->getTempDir());
$this->container->setParameter('contao.web_dir', $this->getTempDir() . '/web');

$extension = new ContaoManagerExtension();
$extension->load([], $this->container);
Expand Down Expand Up @@ -115,38 +116,34 @@ public function testRegistersTheRoutingLoader(): void
public function testDefaultContaoManagerPathIsRegisteredAutomatically(): void
{
$defaultPath = 'contao-manager.phar.php';
$container = new ContainerBuilder();
$container->setParameter('kernel.project_dir', $this->getTempDir());
$webDir = $this->container->getParameter('contao.web_dir');

$tmpDir = $this->getTempDir();
$fs = new Filesystem();
$fs->dumpFile($tmpDir . '/web/' . $defaultPath, '');
$fs->dumpFile($webDir . '/' . $defaultPath, '');

$extension = new ContaoManagerExtension();
$extension->load([], $container);
$extension->load([], $this->container);

$this->assertFileExists($tmpDir . '/web/' . $defaultPath);
$this->assertSame($defaultPath, $container->getParameter('contao_manager.manager_path'));
$this->assertFileExists($webDir . '/' . $defaultPath);
$this->assertSame($defaultPath, $this->container->getParameter('contao_manager.manager_path'));

$fs->remove($tmpDir . '/web/' . $defaultPath);
$fs->remove($webDir . '/' . $defaultPath);
}

public function testCustomContaoManagerPathIsRegistered(): void
{
$container = new ContainerBuilder();
$container->setParameter('kernel.project_dir', $this->getTempDir());
$webDir = $this->container->getParameter('contao.web_dir');

$tmpDir = $this->getTempDir();
$fs = new Filesystem();
$fs->dumpFile($tmpDir . '/web/custom.phar.php' , '');
$fs->dumpFile($webDir . '/custom.phar.php' , '');

$config = ['manager_path' => 'custom.phar.php'];
$extension = new ContaoManagerExtension();
$extension->load([$config], $container);
$extension->load([$config], $this->container);

$this->assertFileExists($tmpDir . '/web/custom.phar.php');
$this->assertSame('custom.phar.php', $container->getParameter('contao_manager.manager_path'));
$this->assertFileExists($webDir . '/custom.phar.php');
$this->assertSame('custom.phar.php', $this->container->getParameter('contao_manager.manager_path'));

$fs->remove($tmpDir . '/web/custom.phar.php');
$fs->remove($webDir . '/custom.phar.php');
}
}

0 comments on commit deca785

Please sign in to comment.