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