* Class UpdaterTest.
* Runs unit tests against the updater class.
*/
-class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
+class LegacyUpdaterTest extends \Shaarli\TestCase
{
/**
* @var string Path to test datastore.
/**
* Executed before each test.
*/
- public function setUp()
+ protected function setUp(): void
{
copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
$this->conf = new ConfigManager(self::$configFile);
*/
public function testReadEmptyUpdatesFile()
{
- $this->assertEquals(array(), UpdaterUtils::read_updates_file(''));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
- $this->assertEquals(array(), UpdaterUtils::read_updates_file($updatesFile));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
unlink($updatesFile);
}
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
$updatesMethods = array('m1', 'm2', 'm3');
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
// Update
$updatesMethods[] = 'm4';
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
unlink($updatesFile);
}
/**
* Test errors in UpdaterUtils::write_updates_file(): empty updates file.
- *
- * @expectedException Exception
- * @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
*/
public function testWriteEmptyUpdatesFile()
{
- UpdaterUtils::write_updates_file('', array('test'));
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
+
+ UpdaterUtils::writeUpdatesFile('', array('test'));
}
/**
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
- *
- * @expectedException Exception
- * @expectedExceptionMessageRegExp /Unable to write(.*)/
*/
public function testWriteUpdatesFileNotWritable()
{
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/Unable to write(.*)/');
+
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
chmod($updatesFile, 0444);
try {
- @UpdaterUtils::write_updates_file($updatesFile, array('test'));
+ @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
} catch (Exception $e) {
unlink($updatesFile);
throw $e;
/**
* Test Update failed.
- *
- * @expectedException \Exception
*/
public function testUpdateFailed()
{
+ $this->expectException(\Exception::class);
+
$updates = array(
'updateMethodDummy1',
'updateMethodDummy2',
$this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode'));
$this->assertEquals(125, $this->conf->get('thumbnails.width'));
$this->assertEquals(90, $this->conf->get('thumbnails.height'));
- $this->assertContains('You have enabled or changed thumbnails', $_SESSION['warnings'][0]);
+ $this->assertContainsPolyfill('You have enabled or changed thumbnails', $_SESSION['warnings'][0]);
}
/**
if (isset($_SESSION['warnings'])) {
unset($_SESSION['warnings']);
}
-
+
$updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION);
$this->assertTrue($updater->updateMethodWebThumbnailer());
$this->assertFalse($this->conf->exists('thumbnail'));