/lib/plugins/sfPropelPlugin/test/functional/i18nTest.php

https://github.com/bheneka/gitta · PHP · 159 lines · 128 code · 18 blank · 13 comment · 1 complexity · 0f1243b5d9b76fdc4302506577efecde MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. $app = 'frontend';
  10. $fixtures = 'fixtures/fixtures.yml';
  11. if (!include(dirname(__FILE__).'/../bootstrap/functional.php'))
  12. {
  13. return;
  14. }
  15. $b = new sfTestBrowser(new sfBrowser());
  16. $b->setTester('propel', 'sfTesterPropel');
  17. // en
  18. $b->
  19. get('/i18n/default')->
  20. with('request')->begin()->
  21. isParameter('module', 'i18n')->
  22. isParameter('action', 'default')->
  23. end()->
  24. with('response')->begin()->
  25. isStatusCode(200)->
  26. checkElement('#movies .toString:first', '')->
  27. checkElement('#movies .default:first', '')->
  28. checkElement('#movies .it:first', 'La Vita è bella')->
  29. checkElement('#movies .fr:first', 'La Vie est belle')->
  30. end()
  31. ;
  32. // fr
  33. $b->
  34. get('/i18n/index')->
  35. with('request')->begin()->
  36. isParameter('module', 'i18n')->
  37. isParameter('action', 'index')->
  38. end()->
  39. with('response')->begin()->
  40. isStatusCode(200)->
  41. checkElement('#movies .toString:first', 'La Vie est belle')->
  42. checkElement('#movies .default:first', 'La Vie est belle')->
  43. checkElement('#movies .it:first', 'La Vita è bella')->
  44. checkElement('#movies .fr:first', 'La Vie est belle')->
  45. end()
  46. ;
  47. // still fr
  48. $b->
  49. get('/i18n/default')->
  50. with('request')->begin()->
  51. isParameter('module', 'i18n')->
  52. isParameter('action', 'default')->
  53. end()->
  54. with('response')->begin()->
  55. isStatusCode(200)->
  56. checkElement('#movies .toString:first', 'La Vie est belle')->
  57. checkElement('#movies .default:first', 'La Vie est belle')->
  58. checkElement('#movies .it:first', 'La Vita è bella')->
  59. checkElement('#movies .fr:first', 'La Vie est belle')->
  60. end()
  61. ;
  62. // i18n forms
  63. $b->
  64. get('/i18n/movie')->
  65. with('request')->begin()->
  66. isParameter('module', 'i18n')->
  67. isParameter('action', 'movie')->
  68. end()->
  69. with('response')->begin()->
  70. isStatusCode(200)->
  71. checkElement('#movie_fr_id', false)->
  72. checkElement('#movie_fr_culture', false)->
  73. end()->
  74. click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->
  75. with('response')->begin()->
  76. isRedirected()->
  77. followRedirect()->
  78. end()->
  79. with('response')->begin()->
  80. checkElement('input[value="Robert Aldrich"]')->
  81. checkElement('input[value="The Dirty Dozen"]')->
  82. checkElement('input[value="Les Douze Salopards"]')->
  83. checkElement('#movie_fr_id', true)->
  84. checkElement('#movie_fr_culture', true)->
  85. end()->
  86. with('propel')->begin()->
  87. check('Movie', array(), 2)->
  88. check('Movie', array('director' => 'Robert Aldrich', 'id' => 2))->
  89. check('MovieI18N', array(), 4)->
  90. check('MovieI18N', array('id' => 2), 2)->
  91. check('MovieI18N', array('culture' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards'))->
  92. check('MovieI18N', array('culture' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen'))->
  93. end()->
  94. click('submit', array('movie' => array('director' => 'Robert Aldrich (1)', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->
  95. with('response')->begin()->
  96. isRedirected()->
  97. followRedirect()->
  98. end()->
  99. with('response')->begin()->
  100. checkElement('input[value="Robert Aldrich (1)"]')->
  101. checkElement('input[value="The Dirty Dozen (1)"]')->
  102. checkElement('input[value="Les Douze Salopards (1)"]')->
  103. end()->
  104. with('propel')->begin()->
  105. check('Movie', array(), 2)->
  106. check('Movie', array('director' => 'Robert Aldrich (1)', 'id' => 2))->
  107. check('MovieI18N', array(), 4)->
  108. check('MovieI18N', array('id' => 2), 2)->
  109. check('MovieI18N', array('culture' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards (1)'))->
  110. check('MovieI18N', array('culture' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen (1)'))->
  111. end()->
  112. // Bug #7486
  113. click('submit')->
  114. with('form')->begin()->
  115. hasErrors(false)->
  116. end()->
  117. get('/i18n/movie')->
  118. click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->
  119. with('form')->begin()->
  120. hasErrors(2)->
  121. end()->
  122. click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->
  123. with('form')->begin()->
  124. hasErrors(false)->
  125. end()->
  126. with('response')->begin()->
  127. isRedirected()->
  128. followRedirect()->
  129. end()->
  130. with('response')->begin()->
  131. checkElement('input[value="Robert Aldrich"]')->
  132. checkElement('input[value="The Dirty Dozen"]')->
  133. checkElement('input[value="Les Douze Salopards"]')->
  134. end()
  135. // END: Bug #7486
  136. ;
  137. $b->getAndCheck('i18n', 'products')
  138. ->with('response')->begin()
  139. ->checkElement('ul#products li.toString', 'PRIMARY STRING')
  140. ->end()
  141. ;