2016-01-12 19:50:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'application/Updater.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class DummyUpdater.
|
|
|
|
* Extends Updater to add update method designed for unit tests.
|
|
|
|
*/
|
|
|
|
class DummyUpdater extends Updater
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Object constructor.
|
|
|
|
*
|
2016-06-09 20:04:02 +02:00
|
|
|
* @param array $doneUpdates Updates which are already done.
|
|
|
|
* @param LinkDB $linkDB 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
|
|
|
*/
|
2016-06-09 20:04:02 +02:00
|
|
|
public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
|
2016-01-12 19:50:48 +01:00
|
|
|
{
|
2016-06-09 20:04:02 +02:00
|
|
|
parent::__construct($doneUpdates, $linkDB, $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.
|
|
|
|
*/
|
|
|
|
private final function updateMethodDummy1()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 2.
|
|
|
|
*
|
|
|
|
* @return bool true.
|
|
|
|
*/
|
|
|
|
private final function updateMethodDummy2()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 3.
|
|
|
|
*
|
|
|
|
* @return bool true.
|
|
|
|
*/
|
|
|
|
private final function updateMethodDummy3()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update method 4, raise an exception.
|
|
|
|
*
|
|
|
|
* @throws Exception error.
|
|
|
|
*/
|
|
|
|
private final function updateMethodException()
|
|
|
|
{
|
|
|
|
throw new Exception('whatever');
|
|
|
|
}
|
|
|
|
}
|