Fixing #138
[akelos.git] / test / unit / lib / AkActiveRecord / _AkActiveRecord_i18n.php
bloba1f27baa10f10e0292127ec6234e166b39a78943
1 <?php
3 defined('AK_TEST_DATABASE_ON') ? null : define('AK_TEST_DATABASE_ON', true);
5 require_once(dirname(__FILE__).'/../../../fixtures/config/config.php');
7 class test_AkActiveRecord_i18n extends AkUnitTest
9 function test_start()
11 $this->installAndIncludeModels(array('Article'));
14 function test_multilingual_setting()
16 $Article = new Article();
18 $Article->set('headline', array(
19 'en'=>'New PHP Framework released',
20 'es'=>'Se ha liberado un nuevo Framework para PHP'));
22 $Article->set('body', array(
23 'en'=>'The Akelos Framework has been released...',
24 'es'=>'Un equipo de programadores españoles ha lanzado un entorno de desarrollo para PHP...'));
26 $Article->set('excerpt_limit', array('en'=> 7, 'es'=> 3));
28 $this->assertTrue($Article->save());
30 $Article = $Article->find($Article->getId());
31 $this->assertEqual($Article->get('en_headline'), 'New PHP Framework released');
32 $this->assertEqual($Article->get('es_body'), 'Un equipo de programadores españoles ha lanzado un entorno de desarrollo para PHP...');
33 $this->assertEqual($Article->get('en_excerpt_limit'), 7);
38 function test_multilingual_setting_by_reference()
40 $Article =& new Article();
42 $Article->set('headline', array(
43 'en'=>'New PHP Framework re-released',
44 'es'=>'Se ha re-liberado un nuevo Framework para PHP'));
46 $Article->set('body', array(
47 'en'=>'The Akelos Framework has been re-released...',
48 'es'=>'Un equipo de programadores españoles ha re-lanzado un entorno de desarrollo para PHP...'));
50 $Article->set('excerpt_limit', array('en'=> 7, 'es'=> 3));
52 $this->assertTrue($Article->save());
54 $Article =& $Article->find($Article->getId());
55 $this->assertEqual($Article->get('en_headline'), 'New PHP Framework re-released');
56 $this->assertEqual($Article->get('es_body'), 'Un equipo de programadores españoles ha re-lanzado un entorno de desarrollo para PHP...');
57 $this->assertEqual($Article->get('en_excerpt_limit'), 7);
61 function test_multilingual_getting_an_specific_locale()
63 $Article =& new Article();
64 $this->assertTrue($Article =& $Article->findFirstBy('en_headline', 'New PHP Framework released'));
66 $this->assertEqual($Article->get('excerpt_limit', 'en'), 7);
67 $this->assertEqual($Article->get('excerpt_limit', 'es'), 3);
68 $this->assertEqual($Article->getAttribute('excerpt_limit', 'en'), 7);
69 $this->assertEqual($Article->getAttribute('excerpt_limit', 'es'), 3);
72 $this->assertEqual($Article->get('headline', 'en'), 'New PHP Framework released');
73 $this->assertEqual($Article->get('headline', 'es'), 'Se ha liberado un nuevo Framework para PHP');
74 $this->assertEqual($Article->getAttribute('headline', 'en'), 'New PHP Framework released');
75 $this->assertEqual($Article->getAttribute('headline', 'es'), 'Se ha liberado un nuevo Framework para PHP');
76 $this->assertEqual($Article->get('headline'), 'New PHP Framework released');
77 $this->assertEqual($Article->getAttribute('headline'), 'New PHP Framework released');
79 $this->assertEqual($Article->getAttributeLocales('headline'), array('en'=>'New PHP Framework released', 'es'=>'Se ha liberado un nuevo Framework para PHP'));
84 function test_multilingual_setting_an_specific_locale()
86 $Article =& new Article();
87 $Article->set('headline','Happiness on developers boost productivity', 'en');
88 $Article->set('headline','La felicidad de los programadores mejora la productivdad', 'es');
90 $this->assertEqual($Article->en_headline,'Happiness on developers boost productivity');
91 $this->assertEqual($Article->es_headline,'La felicidad de los programadores mejora la productivdad');
96 ak_test('test_AkActiveRecord_i18n',true);