file_path = tempnam(sys_get_temp_dir(), 'psalm-test-config');
}
/** @return void */
public function tearDown()
{
@unlink($this->file_path);
}
/**
* @return void
* @test
*/
public function canCreateConfigObject()
{
file_put_contents($this->file_path, trim('
'));
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$this->assertInstanceOf(Config::class, $config_file->getConfig());
}
/**
* @return void
* @test
*/
public function addCanAddPluginClassToExistingPluginsNode()
{
file_put_contents($this->file_path, trim('
'));
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$config_file->addPlugin('a\b\c');
$this->assertXmlStringEqualsXmlString(
'',
file_get_contents($this->file_path)
);
}
/**
* @return void
* @test
*/
public function addCanCreateMissingPluginsNode()
{
file_put_contents($this->file_path, trim('
'));
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$config_file->addPlugin('a\b\c');
$this->assertXmlStringEqualsXmlString(
'',
file_get_contents($this->file_path)
);
}
/**
* @return void
* @test
*/
public function removeDoesNothingWhenThereIsNoPluginsNode()
{
$noPlugins = trim('
');
file_put_contents($this->file_path, $noPlugins);
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$config_file->removePlugin('a\b\c');
$this->assertXmlStringEqualsXmlString(
$noPlugins,
file_get_contents($this->file_path)
);
}
/**
* @return void
* @test
*/
public function removeKillsEmptyPluginsNode()
{
$noPlugins = trim('
');
$emptyPlugins = trim('
');
file_put_contents($this->file_path, $emptyPlugins);
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$config_file->removePlugin('a\b\c');
$this->assertXmlStringEqualsXmlString(
$noPlugins,
file_get_contents($this->file_path)
);
}
/**
* @return void
* @test
*/
public function removeKillsSpecifiedPlugin()
{
$noPlugins = trim('
');
$abcEnabled = trim('
');
file_put_contents($this->file_path, $abcEnabled);
$config_file = new ConfigFile((string)getcwd(), $this->file_path);
$config_file->removePlugin('a\b\c');
$this->assertXmlStringEqualsXmlString(
$noPlugins,
file_get_contents($this->file_path)
);
}
}