Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// $Id: gettext_mo_test.php 228524 2007-01-30 19:48:22Z quipo $
3
 
4
require_once 'db_test_base.php';
5
 
6
class TestOfGettextMO extends TestOfContainerDB {
7
    function TestOfGettextMO($name='Test of Container gettext MO') {
8
        $this->UnitTestCase($name);
9
    }
10
    function setUp() {
11
        $driver = 'gettext';
12
        $options = array(
13
            'prefetch'          => false,
14
            'langs_avail_file'  => 'gettext_langs.ini',
15
            'domains_path_file' => 'gettext_domains.ini',
16
            'default_domain'    => 'messages',
17
            'file_type'         => 'mo',
18
        );
19
        $this->tr = Translation2::factory($driver, $options);
20
    }
21
    /*
22
    function testDefaultTextDecorator() {
23
        $this->tr->setLang('it');
24
        //without decorator
25
        //with gettext, empty strings are replaced by the stringID
26
        $this->assertEqual('isempty', $this->tr->get('isempty'));
27
        $expected = array(
28
            'only_english' => null,
29
            'only_italian' => 'testo solo in italiano',
30
            'hello_user'   => 'ciao, &&user&&, oggi è il &&day&& &&month&& &&year&& (&&weekday&&)',
31
            'isempty'      => null,
32
            'prova_conflitto' => 'testo con conflitto - globale',
33
            'test'         => 'stringa di prova',
34
            'Entirely new string' => null,
35
        );
36
        //with decorator
37
        $this->tr =& $this->tr->getDecorator('DefaultText');
38
        $this->assertEqual('isempty', $this->tr->get('isempty'));
39
        $this->assertEqual($expected, $this->tr->getRawPage());
40
        $expected = array(
41
            'only_english' => 'only_english',
42
            'only_italian' => 'testo solo in italiano',
43
            'hello_user'   => 'ciao, &&user&&, oggi è il &&day&& &&month&& &&year&& (&&weekday&&)',
44
            'isempty'      => 'isempty',
45
            'prova_conflitto' => 'testo con conflitto - globale',
46
            'test'         => 'stringa di prova',
47
            'Entirely new string' => 'Entirely new string',
48
        );
49
        $this->assertEqual($expected, $this->tr->getPage());
50
    }
51
    */
52
    function testLangDecorator() {
53
        $this->tr->setLang('it');
54
        $this->tr =& $this->tr->getDecorator('Lang');
55
        $this->tr->setOption('fallbackLang', 'en');
56
        //with gettext, empty strings are replaced by the stringID
57
        $this->assertEqual('only_english', $this->tr->get('only_english'));
58
        $expected = array(
59
            'only_english' => null,
60
            'only_italian' => 'testo solo in italiano',
61
            'hello_user'   => 'ciao, &&user&&, oggi è il &&day&& &&month&& &&year&& (&&weekday&&)',
62
            'isempty'      => null,
63
            'prova_conflitto' => 'testo con conflitto - globale',
64
            'test'         => 'stringa di prova',
65
            'Entirely new string' => null,
66
        );
67
        $this->assertEqual($expected, $this->tr->getRawPage());
68
        $this->tr =& $this->tr->getDecorator('Lang');
69
        $this->tr->setOption('fallbackLang', 'de');
70
        $expected = array(
71
            'only_english' => 'only english text',
72
            'only_italian' => 'testo solo in italiano',
73
            'hello_user'   => 'ciao, &&user&&, oggi è il &&day&& &&month&& &&year&& (&&weekday&&)',
74
            'isempty'      => 'this string is empty in English and Italian, but not in German!',
75
            'test'         => 'stringa di prova',
76
            'prova_conflitto' => 'testo con conflitto - globale',
77
            'Entirely new string' => 'Entirely new string',
78
        );
79
        $this->assertEqual($expected, $this->tr->getPage());
80
    }
81
}
82
 
83
if (!defined('TEST_RUNNING')) {
84
    define('TEST_RUNNING', true);
85
    $test = &new TestOfGettextMO();
86
    $test->run(new HtmlReporter());
87
}
88
?>