diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 6d951aad30074efb4cf1c0381c916e289815ee61..7eb7643b19ab8eda1794de0d04c7bbc809340ebc 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase { use Storm_Test_THelpers; @@ -103,11 +103,14 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe parent::setUp(); + Zend_Registry::get('locale')->setLocale('fr'); + Zend_Registry::get('translate')->setLocale('fr'); + $this->_login(); $session = new Zend_Session_Namespace('FlashMessenger'); $session->unsetAll(); - + $admin_var_loader = Class_AdminVar::getLoader(); $admin_var_loader ->newInstanceWithId('WORKFLOW') @@ -127,7 +130,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe $admin_var_loader ->newInstanceWithId('OAI_SERVER') - ->setValeur(1); + ->setValeur(1); $admin_var_loader ->newInstanceWithId('PACK_MOBILE') @@ -169,7 +172,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe } /** - * Retourne la valeur du header Location + * Retourne la valeur du header Location * @return String */ function getResponseLocation() { @@ -209,7 +212,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe public function assertHTML5($content=null) { if ($content == null) $content = $this->_response->getBody(); - + $httpClient = new Zend_Http_Client(); $httpClient->setUri('http://html5.validator.nu/'); $httpClient->setMethod(Zend_Http_Client::POST); @@ -246,8 +249,8 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe public function assertFlashMessengerContains($value, $message = '') { - $this->assertContains($value, - $this->_getFlashMessengerMessages(), + $this->assertContains($value, + $this->_getFlashMessengerMessages(), $message); } diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index b160e1d58f34d2eaac5e2f188b27838f450ce1fc..3dd325f15a7416bb4524c42135d9e3ebcfd99165 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -756,6 +756,32 @@ abstract class CmsControllerWithFeteDeLaFriteTestCase extends AbstractController +class CmsControllerArticleViewInEnglishTest extends CmsControllerWithFeteDeLaFriteTestCase { + /** @test */ + function withLanguageEnShouldReturnEnglishTranslation() { + $this->dispatch('/cms/articleview/id/224/language/en'); + $this->assertXpathContentContains('//h1', 'Feast of fried'); + } + + + /** @test */ + function withLanguageEnEventDateShouldBeTranslated() { + $this->dispatch('/cms/articleview/id/224/language/en', true); + $this->assertXpathContentContains('//span[@class="calendar_event_date"]', + 'From 03 September to 05 October 2011', + $this->_response->getBody()); + } + + + /** @test */ + function withCurrentLocaleEnShouldReturnEnglishTranslation() { + Zend_Registry::get('session')->language = 'en'; + $this->dispatch('/cms/articleview/id/224'); + $this->assertXpathContentContains('//h1', 'Feast of fried'); + } +} + + class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCase { protected function _loginHook($account) { @@ -891,31 +917,6 @@ class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCas } - /** @test */ - function withLanguageEnShouldReturnEnglishTranslation() { - $this->bootstrap(); - $this->dispatch('/cms/articleview/id/224/language/en'); - $this->assertXpathContentContains('//h1', 'Feast of fried'); - } - - - /** @test */ - function withLanguageEnEventDateShouldBeTranslated() { - $this->bootstrap(); - $this->dispatch('/cms/articleview/id/224/language/en'); - $this->assertXpathContentContains('//span[@class="calendar_event_date"]', - 'From 03 September to 05 October 2011'); - } - - - /** @test */ - function withCurrentLocaleEnShouldReturnEnglishTranslation() { - $this->bootstrap(); - Zend_Registry::get('session')->language = 'en'; - $this->dispatch('/cms/articleview/id/224'); - $this->assertXpathContentContains('//h1', 'Feast of fried'); - } - /** @test */ public function avisArgShouldNotHaveLinkForDeletion() { $this->assertNotXPath('//a[contains(@href, "admin/modo/delete-cms-avis/id/35")]');