~ubuntu-branches/ubuntu/lucid/gallery2/lucid

« back to all changes in this revision

Viewing changes to lib/tools/phpunit/MockTemplateAdapter.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2007-09-10 20:22:19 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070910202219-0jsuntvqge4ade6b
Tags: 2.2.3-2
Add Slovak translation of Debconf templates.  (Thanks to 
Ivan Masá.  Closes: #441671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Gallery - a web based photo album viewer and editor
4
 
 * Copyright (C) 2000-2007 Bharat Mediratta
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 */
20
 
 
21
 
/**
22
 
 * Mock template adapter for tests
23
 
 * @package Gallery
24
 
 * @subpackage PHPUnit
25
 
 */
26
 
class MockTemplateAdapter {
27
 
    function MockTemplateAdapter($useProgressBar=true) {
28
 
        $this->_useProgressBar = $useProgressBar;
29
 
    }
30
 
 
31
 
    function registerTrailerCallback($callback, $args) {
32
 
        $this->_callbacks[] = array($callback, $args);
33
 
    }
34
 
 
35
 
    function runCallbacks() {
36
 
        foreach ($this->_callbacks as $callback) {
37
 
            $ret = call_user_func_array($callback[0], $callback[1]);
38
 
            if (is_array($ret)) {
39
 
                $ret = $ret[0];
40
 
            }
41
 
            if ($ret) {
42
 
                /* If progress bar is in use, report error via its interface */
43
 
                if ($this->_useProgressBar) {
44
 
                    $this->errorProgressBar($ret);
45
 
                }
46
 
                return $ret;
47
 
            }
48
 
        }
49
 
 
50
 
        return null;
51
 
    }
52
 
 
53
 
    function getCallback($index) {
54
 
        return $this->_callbacks[$index];
55
 
    }
56
 
 
57
 
    function getCallbackCount() {
58
 
        return sizeof($this->_callbacks);
59
 
    }
60
 
 
61
 
    function getProgressBarDump() {
62
 
        return $this->_progress;
63
 
    }
64
 
 
65
 
    function updateProgressBar($title, $description, $percentComplete) {
66
 
        /* Replace localized comma decimal separator with a dot */
67
 
        $this->_progress[] = str_replace(',', '.', round($percentComplete, 2));
68
 
        return null;
69
 
    }
70
 
 
71
 
    function resetProgressBarStats() {
72
 
        $this->_progress[] = 'reset';
73
 
    }
74
 
 
75
 
    function errorProgressBar($status) {
76
 
        $this->_progress[] = 'error';
77
 
    }
78
 
 
79
 
    function completeProgressBar($url) {
80
 
        $this->_progress[] = 'complete:' . $url;
81
 
    }
82
 
}
83
 
?>