~ubuntu-branches/ubuntu/maverick/gallery2/maverick

« back to all changes in this revision

Viewing changes to modules/core/test/phpunit/LanguageTest.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
 
 * Test language selection functionality
23
 
 * @package GalleryCore
24
 
 * @subpackage PHPUnit
25
 
 * @author Alan Harder <alan.harder@sun.com>
26
 
 * @version $Revision: 15513 $
27
 
 */
28
 
class LanguageTest extends GalleryControllerTestCase {
29
 
 
30
 
    function LanguageTest($methodName) {
31
 
        $this->GalleryControllerTestCase($methodName, 'core.ChangeLanguage');
32
 
    }
33
 
 
34
 
    function setUp() {
35
 
        parent::setUp();
36
 
 
37
 
        list ($ret, $this->_siteLanguage) =
38
 
            GalleryCoreApi::getPluginParameter('module', 'core', 'default.language');
39
 
        if ($ret) {
40
 
            print $ret->getAsHtml();
41
 
            return $this->failWithStatus($ret);
42
 
        }
43
 
    }
44
 
 
45
 
    function testGetActiveLanguageCode() {
46
 
        global $gallery;
47
 
        $session =& $gallery->getSession();
48
 
        $session->remove('core.language');
49
 
 
50
 
        list ($ret, $language) = $gallery->getActiveLanguageCode();
51
 
        if ($ret) {
52
 
            return $this->failWithStatus($ret);
53
 
        }
54
 
        $this->assertEquals(null, $language, 'not set');
55
 
 
56
 
        $user = new GalleryUser();
57
 
        $user->setId('testId');
58
 
        $user->setLanguage('test_language');
59
 
        $gallery->setActiveUser($user);
60
 
 
61
 
        list ($ret, $language) = $gallery->getActiveLanguageCode();
62
 
        if ($ret) {
63
 
            return $this->failWithStatus($ret);
64
 
        }
65
 
        $this->assertEquals('test_language', $language, 'user language');
66
 
 
67
 
        $gallery->setActiveLanguageCode('sess_language');
68
 
 
69
 
        list ($ret, $language) = $gallery->getActiveLanguageCode();
70
 
        if ($ret) {
71
 
            return $this->failWithStatus($ret);
72
 
        }
73
 
        $this->assertEquals('sess_language', $language, 'session language');
74
 
    }
75
 
 
76
 
    function testChangeLanguageController() {
77
 
        global $gallery;
78
 
        GalleryUtilities::putRequestVariable('language', 'test_language');
79
 
 
80
 
        $results = $this->handleRequest();
81
 
        $this->assertEquals(array('return' => 1,
82
 
                                  'status' => array(),
83
 
                                  'error' => array()),
84
 
                            $results);
85
 
 
86
 
        list ($ret, $language) = $gallery->getActiveLanguageCode();
87
 
        if ($ret) {
88
 
            return $this->failWithStatus($ret);
89
 
        }
90
 
        $this->assertEquals('test_language', $language, 'language');
91
 
    }
92
 
}
93
 
?>