Skip to content

Commit

Permalink
Refactor the Contao Manager extension test
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Nov 26, 2018
1 parent 8f8a27e commit 35b2908
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,33 @@ public function testRegistersTheRoutingLoader(): void
$this->assertSame('%kernel.project_dir%', (string) $definition->getArgument(3));
}

public function testRegistersTheDefaultContaoManagerPath(): void
/**
* @dataProvider getManagerPaths
*/
public function testRegistersTheContaoManagerPath(string $file, array $config): void
{
$webDir = $this->container->getParameter('contao.web_dir');

$fs = new Filesystem();
$fs->dumpFile($webDir.'/contao-manager.phar.php', '');
$fs->dumpFile($webDir.'/'.$file, '');

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

$this->assertFileExists($webDir.'/contao-manager.phar.php');
$this->assertSame('contao-manager.phar.php', $this->container->getParameter('contao_manager.manager_path'));
$this->assertFileExists($webDir.'/'.$file);
$this->assertSame($file, $this->container->getParameter('contao_manager.manager_path'));

$fs->remove($webDir.'/contao-manager.phar.php');
$fs->remove($webDir.'/'.$file);
}

public function testRegistersACustomContaoManagerPath(): void
/**
* @return array<int,array<int,array<string,string>|string>>
*/
private function getManagerPaths(): array
{
$webDir = $this->container->getParameter('contao.web_dir');

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

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

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

$fs->remove($webDir.'/custom.phar.php');
return [
['contao-manager.phar.php', []],
['custom.phar.php', ['manager_path' => 'custom.phar.php']],
];
}
}

0 comments on commit 35b2908

Please sign in to comment.