3
* Gallery - a web based photo album viewer and editor
4
* Copyright (C) 2000-2007 Bharat Mediratta
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22
* Mock template adapter for tests
26
class MockTemplateAdapter {
27
function MockTemplateAdapter($useProgressBar=true) {
28
$this->_useProgressBar = $useProgressBar;
31
function registerTrailerCallback($callback, $args) {
32
$this->_callbacks[] = array($callback, $args);
35
function runCallbacks() {
36
foreach ($this->_callbacks as $callback) {
37
$ret = call_user_func_array($callback[0], $callback[1]);
42
/* If progress bar is in use, report error via its interface */
43
if ($this->_useProgressBar) {
44
$this->errorProgressBar($ret);
53
function getCallback($index) {
54
return $this->_callbacks[$index];
57
function getCallbackCount() {
58
return sizeof($this->_callbacks);
61
function getProgressBarDump() {
62
return $this->_progress;
65
function updateProgressBar($title, $description, $percentComplete) {
66
/* Replace localized comma decimal separator with a dot */
67
$this->_progress[] = str_replace(',', '.', round($percentComplete, 2));
71
function resetProgressBarStats() {
72
$this->_progress[] = 'reset';
75
function errorProgressBar($status) {
76
$this->_progress[] = 'error';
79
function completeProgressBar($url) {
80
$this->_progress[] = 'complete:' . $url;