* Note: it only test the manager with ConfigJson,
* ConfigPhp is only a workaround to handle the transition to JSON type.
*/
-class ConfigManagerTest extends \PHPUnit\Framework\TestCase
+class ConfigManagerTest extends \Shaarli\TestCase
{
/**
* @var ConfigManager
*/
protected $conf;
- public function setUp()
+ protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
}
/**
* Set with an empty key.
- *
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/
public function testSetEmptyKey()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
+
$this->conf->set('', 'stuff');
}
/**
* Set with an array key.
- *
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/
public function testSetArrayKey()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
+
$this->conf->set(array('foo' => 'bar'), 'stuff');
}
/**
* Remove with an empty key.
- *
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/
public function testRmoveEmptyKey()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
+
$this->conf->remove('');
}
/**
* Try to write the config without mandatory parameter (e.g. 'login').
- *
- * @expectedException Shaarli\Config\Exception\MissingFieldConfigException
*/
public function testWriteMissingParameter()
{
+ $this->expectException(\Shaarli\Config\Exception\MissingFieldConfigException::class);
+
$this->conf->setConfigFile('tests/utils/config/configTmp');
$this->assertFalse(file_exists($this->conf->getConfigFileExt()));
$this->conf->reload();