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
* Test storage class used for testing functions that interact with the database.
23
* Only the features required for testing the repository code are implemented.
24
* @package GalleryCore
26
* @author Jozef Selesi <selesi at gmail dot com>
27
* @version $Revision: 15513 $
29
class RepositoryTestStorage {
37
function &getSingleton() {
39
if (!isset($singleton)) {
40
$singleton = new RepositoryTestStorage();
47
$singleton =& $this->getSingleton();
48
$singleton->_searches = array();
49
$singleton->_searchResults = array();
50
$singleton->_addedMapData = array();
51
$singleton->_updatedMapData = array();
52
$singleton->_removedMapData = array();
55
function search($query, $args) {
56
$singleton =& $this->getSingleton();
57
$singleton->_searches[] = array('query' => $query, 'arguments' => $args);
60
new RepositoryTestSearchResults($singleton->_searchResults));
63
function setSearchResults($results) {
64
$singleton =& $this->getSingleton();
65
$singleton->_searchResults = $results;
68
function getSearches() {
69
$singleton =& $this->getSingleton();
70
return $singleton->_searches;
73
function addMapEntry($map, $data) {
74
$singleton =& $this->getSingleton();
75
$singleton->_addedMapData[$map][] = $data;
79
function getMapEntry($map, $data, $match) {
80
$singleton =& $this->getSingleton();
81
$singleton->_searches[] = array('map' => $map, 'select' => $data, 'where' => $match);
84
new RepositoryTestSearchResults($singleton->_searchResults));
87
function getAddedMapData() {
88
$singleton =& $this->getSingleton();
89
return $singleton->_addedMapData;
92
function updateMapEntry($map, $match, $change) {
93
$singleton =& $this->getSingleton();
94
$singleton->_updatedMapData[$map][] = array('match' => $match, 'change' => $change);
98
function removeMapEntry($map, $match) {
99
$singleton =& $this->getSingleton();
100
$singleton->_removedMapData[$map][] = array('match' => $match);
104
function getUpdatedMapData() {
105
$singleton =& $this->getSingleton();
106
return $singleton->_updatedMapData;
109
function getRemovedMapData() {
110
$singleton =& $this->getSingleton();
111
return $singleton->_removedMapData;
114
function rollbackTransaction() {
118
class RepositoryTestSearchResults {
123
function RepositoryTestSearchResults($results) {
124
$this->_results = $results;
125
$this->_resultIndex = 0;
128
function resultCount() {
129
return count($this->_results);
132
function nextResult() {
133
$result = $this->_resultIndex < $this->resultCount() ? $this->_results[$this->_resultIndex]
135
$this->_resultIndex++;