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.
21
GalleryCoreApi::requireOnce('modules/captcha/classes/CaptchaHelper.class');
27
* @author Bharat Mediratta <bharat@menalto.com>
28
* @version $Revision: 15513 $
30
class CaptchaHelperTest extends GalleryTestCase {
31
function CaptchaHelperTest($methodName) {
32
$this->GalleryTestCase($methodName);
35
function testTestRequiredGdFunctionsAllPresent() {
38
$phpVm = new CaptchaHelperTestPhpVm();
39
$phpVm->setFunctionExists('ImageCreateFromJPEG', true);
40
$phpVm->setFunctionExists('ImageColorAllocate', true);
41
$phpVm->setFunctionExists('ImageString', true);
42
$phpVm->setFunctionExists('ImageJPEG', true);
43
$phpVm->setFunctionExists('ImageDestroy', true);
44
$phpVm->setFunctionExists('imagesx', true);
45
$gallery->_phpVm = $phpVm;
47
$report = CaptchaHelper::testRequiredGdFunctions();
48
$this->assertEquals(array('success' => array('ImageCreateFromJPEG',
58
function testTestRequiredGdFunctionsSomeMissing() {
61
$phpVm = new CaptchaHelperTestPhpVm();
62
$phpVm->setFunctionExists('ImageCreateFromJPEG', true);
63
$phpVm->setFunctionExists('ImageColorAllocate', true);
64
$phpVm->setFunctionExists('ImageString', false);
65
$phpVm->setFunctionExists('ImageJPEG', true);
66
$phpVm->setFunctionExists('ImageDestroy', true);
67
$phpVm->setFunctionExists('imagesx', false);
68
$gallery->_phpVm = $phpVm;
70
$report = CaptchaHelper::testRequiredGdFunctions();
71
$this->assertEquals(array('success' => array('ImageCreateFromJPEG',
75
'fail' => array('ImageString',
80
function testTestRequiredGdFunctionsAllMissing() {
82
$phpVm = new CaptchaHelperTestPhpVm();
83
$phpVm->setFunctionExists('ImageCreateFromJPEG', false);
84
$phpVm->setFunctionExists('ImageColorAllocate', false);
85
$phpVm->setFunctionExists('ImageString', false);
86
$phpVm->setFunctionExists('ImageJPEG', false);
87
$phpVm->setFunctionExists('ImageDestroy', false);
88
$phpVm->setFunctionExists('imagesx', false);
89
$gallery->_phpVm = $phpVm;
91
$report = CaptchaHelper::testRequiredGdFunctions();
92
$this->assertEquals(array('success' => array(),
93
'fail' => array('ImageCreateFromJPEG',
103
class CaptchaHelperTestPhpVm {
104
function setFunctionExists($functionName, $bool) {
105
$this->_function_exists[$functionName] = $bool;
108
function function_exists($functionName) {
109
return $this->_function_exists[$functionName];