Ticket #95: ticket_95.unit_tests.patch

File ticket_95.unit_tests.patch, 5.9 kB (added by laurentj, 1 year ago)

premiers tests unitaires pour le patch

  • build/manifests/testapp.mn

    old new  
    8686  test_I.properties 
    8787cd testapp/modules/jelix_tests/locales/fr_FR 
    8888  testunit.ISO-8859-1.properties 
     89  tests1.UTF-8.properties 
     90  tests2.UTF-8.properties 
     91cd testapp/modules/jelix_tests/locales/fr_CA 
     92  tests1.UTF-8.properties 
    8993cd testapp/modules/jelix_tests/locales/en_US 
    9094  testunit.ISO-8859-1.properties 
     95  tests1.UTF-8.properties 
     96cd testapp/modules/jelix_tests/locales/en_EN 
     97  tests1.UTF-8.properties 
     98  tests3.UTF-8.properties 
    9199cd testapp/modules/jelix_tests/templates 
    92100  menu.tpl 
    93101  test_plugin_jurl.tpl 
  • testapp/modules/jelix_tests/locales/en_EN/tests1.UTF-8.properties

    old new  
     1first.locale           = this is an en_EN sentence 
     2third.locale           = this is the 3th en_EN sentence 
  • testapp/modules/jelix_tests/locales/en_EN/tests3.UTF-8.properties

    old new  
  • testapp/modules/jelix_tests/locales/en_US/tests1.UTF-8.properties

    old new  
  • testapp/modules/jelix_tests/locales/fr_CA/tests1.UTF-8.properties

    old new  
  • testapp/modules/jelix_tests/locales/fr_FR/tests1.UTF-8.properties

    old new  
     1first.locale           = ceci est une phrase fr_FR 
     2second.locale          = ceci est une phrase 2 fr_FR 
  • testapp/modules/jelix_tests/locales/fr_FR/tests2.UTF-8.properties

    old new  
  • testapp/modules/jelix_tests/tests/core.jlocale.html.php

    old new  
    5252        ); 
    5353 
    5454    public function testBundle(){ 
    55          
    5655        foreach($this->firstlist as $file=>$content){ 
    5756            $b = new bundleTest('',''); 
    5857            try{ 
     
    6362            } 
    6463        } 
    6564    } 
     65 
     66 
     67    function testSimpleLocale(){ 
     68        $this->assertEqual('ceci est une phrase fr_FR',jLocale::get('test1.first.locale')); 
     69        $this->assertEqual('ceci est une phrase fr_FR',jLocale::get('test1.first.locale', null, 'fr_FR')); 
     70        $this->assertEqual('ceci est une phrase fr_CA',jLocale::get('test1.first.locale', null, 'fr_CA')); 
     71        $this->assertEqual('this is an en_US sentence',jLocale::get('test1.first.locale', null, 'en_US')); 
     72        $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.first.locale', null, 'en_EN')); 
     73    } 
     74 
     75    function testWithNoAskedLocale(){ 
     76        // all this tests are made on an existing locale file 
     77 
     78        $this->assertEqual('ceci est une phrase 2 fr_FR',jLocale::get('test1.second.locale')); 
     79        // no test1.second.locale in fr_CA, so we should have the fr_FR one 
     80        $this->assertEqual('ceci est une phrase 2 fr_FR',jLocale::get('test1.second.locale', null, 'fr_CA')); 
     81        // no test1.third.locale in fr_CA, fr_FR, so we should have the en_EN one 
     82        $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.third.locale', null, 'fr_CA')); 
     83        $this->assertEqual('this is an en_EN sentence',jLocale::get('test1.third.locale', null, 'fr_FR')); 
     84 
     85        try{ 
     86            jLocale::get('test1.fourth.locale', null, 'fr_FR') 
     87            $this->fail('no exception when trying to get test1.fourth.locale locale'); 
     88        }catch(jException $e){ 
     89            $this->pass(); 
     90        } 
     91    } 
     92 
     93    function testWithNoAskedLocaleFile(){ 
     94        // all this tests are made on an non existing locale file 
     95 
     96        $this->assertEqual('ceci est une phrase fr_FR test2',jLocale::get('test2.first.locale')); 
     97        // no test2.properties file for fr_CA, so we should have the fr_FR one 
     98        $this->assertEqual('ceci est une phrase fr_FR test2',jLocale::get('test2.first.locale', null, 'fr_CA')); 
     99        // no test3.properties file for fr_CA and fr_FR, so we should have the en_EN one 
     100        $this->assertEqual('this is an en_EN sentence test3',jLocale::get('test3.first.locale', null, 'fr_CA')); 
     101        $this->assertEqual('this is an en_EN sentence test3',jLocale::get('test3.first.locale', null, 'fr_FR')); 
     102    } 
     103 
    66104} 
    67105 
    68106?> 
Download in other formats: Original Format