2016-01-12 19:50:48 +01:00
|
|
|
<?php
|
2018-12-03 23:49:20 +01:00
|
|
|
namespace Shaarli\Updater;
|
2016-01-12 19:50:48 +01:00
|
|
|
|
2018-12-03 23:49:20 +01:00
|
|
|
use Exception;
|
|
|
|
use ReflectionClass;
|
|
|
|
use ReflectionMethod;
|
2020-01-17 21:34:12 +01:00
|
|
|
use Shaarli\Bookmark\BookmarkFileService;
|
2018-12-03 01:10:39 +01:00
|
|
|
use Shaarli\Bookmark\LinkDB;
|
2018-12-03 23:49:20 +01:00
|
|
|
use Shaarli\Config\ConfigManager;
|
2016-01-12 19:50:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class DummyUpdater.
|
2018-12-03 23:49:20 +01:00
|
|
|
* Extends updater to add update method designed for unit tests.
|
2016-01-12 19:50:48 +01:00
|
|
|
*/
|
|
|
|
class DummyUpdater extends Updater
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Object constructor.
|
|
|
|
*
|
2020-01-17 21:34:12 +01:00
|
|
|
* @param array $doneUpdates Updates which are already done.
|
|
|
|
* @param BookmarkFileService $bookmarkService LinkDB instance.
|
|
|
|
* @param ConfigManager $conf Configuration Manager instance.
|
|
|
|
* @param boolean $isLoggedIn True if the user is logged in.
|
2016-01-12 19:50:48 +01:00
|
|
|
*/
|
2020-01-17 21:34:12 +01:00
|
|
|
public function __construct($doneUpdates, $bookmarkService, $conf, $isLoggedIn)
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
2020-01-17 21:34:12 +01:00
|
|
|
parent::__construct($doneUpdates, $bookmarkService, $conf, $isLoggedIn);
|
2016-01-12 19:50:48 +01:00
|
|
|
|
|
|
|
// Retrieve all update methods.
|
|
|
|
// For unit test, only retrieve final methods,
|
|
|
|
$class = new ReflectionClass($this);
|
|
|
|
$this->methods = $class->getMethods(ReflectionMethod::IS_FINAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 1.
|
|
|
|
*
|
|
|
|
* @return bool true.
|
|
|
|
*/
|
2018-10-13 00:35:47 +02:00
|
|
|
final private function updateMethodDummy1()
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 2.
|
|
|
|
*
|
|
|
|
* @return bool true.
|
|
|
|
*/
|
2018-10-13 00:35:47 +02:00
|
|
|
final private function updateMethodDummy2()
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 3.
|
|
|
|
*
|
|
|
|
* @return bool true.
|
|
|
|
*/
|
2018-10-13 00:35:47 +02:00
|
|
|
final private function updateMethodDummy3()
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 4, raise an exception.
|
|
|
|
*
|
|
|
|
* @throws Exception error.
|
|
|
|
*/
|
2018-10-13 00:35:47 +02:00
|
|
|
final private function updateMethodException()
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
|
|
|
throw new Exception('whatever');
|
|
|
|
}
|
|
|
|
}
|