PluginHandlerTest.php in Database Sanitize 7
File
vendor/edisonlabs/merge-yaml/tests/src/Unit/PluginHandlerTest.php
View source
<?php
namespace EdisonLabs\MergeYaml\Unit;
use Composer\Composer;
use EdisonLabs\MergeYaml\PluginHandler;
use PHPUnit\Framework\TestCase;
class PluginHandlerTest extends TestCase {
protected $defaultConfig;
protected $io;
protected function setUp() {
$this->defaultConfig = [
'files' => [
'test',
],
'locations' => [
dirname(__FILE__) . '/../../assets',
],
'output-dir' => '/tmp/merge-yaml',
];
$this->io = $this
->getMockBuilder('Composer\\IO\\IOInterface')
->getMock();
}
protected function tearDown() {
$file = '/tmp/merge-yaml/test.merge.yml';
if (file_exists($file)) {
unlink($file);
}
}
public function testPlugin() {
$mergeYaml = new PluginHandler(new Composer(), $this->io, $this->defaultConfig);
$this
->assertEquals($this->defaultConfig['files'], $mergeYaml->fileNamePatterns);
$this
->assertEquals($this->defaultConfig['locations'], $mergeYaml->sourcePaths);
$this
->assertEquals($this->defaultConfig['output-dir'], $mergeYaml->outputDir);
$this
->assertTrue($mergeYaml->isConfigured);
$mergeYaml
->createMergeFiles();
$this
->assertFileExists('/tmp/merge-yaml/test.merge.yml');
}
public function testMissingFilesConfiguration() {
$configParameters = $this->defaultConfig;
unset($configParameters['files']);
$this
->expectException(\RuntimeException::class);
$mergeYaml = new PluginHandler(new Composer(), $this->io, $configParameters);
}
public function testMissingLocationsConfiguration() {
$configParameters = $this->defaultConfig;
unset($configParameters['locations']);
$this
->expectException(\RuntimeException::class);
$mergeYaml = new PluginHandler(new Composer(), $this->io, $configParameters);
}
public function testMissingOuptutDirConfiguration() {
$configParameters = $this->defaultConfig;
unset($configParameters['output-dir']);
$this
->expectException(\RuntimeException::class);
$mergeYaml = new PluginHandler(new Composer(), $this->io, $configParameters);
}
}