@@ -250,22 +250,22 @@ |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Returns the native language name for the selected locale/language, empty string if Translatable is not available |
|
| 254 | - * |
|
| 255 | - * @return string |
|
| 256 | - */ |
|
| 257 | - public function getSelectedLanguage() |
|
| 258 | - { |
|
| 259 | - if (!class_exists('Translatable')) { |
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - $language = explode('_', Translatable::get_current_locale()); |
|
| 264 | - $languageCode = array_shift($language); |
|
| 265 | - $nativeName = i18n::get_language_name($languageCode, true); |
|
| 266 | - |
|
| 267 | - return $nativeName; |
|
| 268 | - } |
|
| 253 | + * Returns the native language name for the selected locale/language, empty string if Translatable is not available |
|
| 254 | + * |
|
| 255 | + * @return string |
|
| 256 | + */ |
|
| 257 | + public function getSelectedLanguage() |
|
| 258 | + { |
|
| 259 | + if (!class_exists('Translatable')) { |
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + $language = explode('_', Translatable::get_current_locale()); |
|
| 264 | + $languageCode = array_shift($language); |
|
| 265 | + $nativeName = i18n::get_language_name($languageCode, true); |
|
| 266 | + |
|
| 267 | + return $nativeName; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | class BasePage_Controller extends ContentController { |
@@ -1,80 +1,80 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class BasePageTest extends SapphireTest |
| 3 | 3 | { |
| 4 | - public static $fixture_file = 'BasePageTest.yml'; |
|
| 4 | + public static $fixture_file = 'BasePageTest.yml'; |
|
| 5 | 5 | |
| 6 | - public function setUp() |
|
| 7 | - { |
|
| 8 | - parent::setUp(); |
|
| 6 | + public function setUp() |
|
| 7 | + { |
|
| 8 | + parent::setUp(); |
|
| 9 | 9 | |
| 10 | - Config::nest(); |
|
| 11 | - Config::inst()->update('BasePage', 'pdf_export', true); |
|
| 12 | - Config::inst()->update('BasePage', 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 13 | - } |
|
| 10 | + Config::nest(); |
|
| 11 | + Config::inst()->update('BasePage', 'pdf_export', true); |
|
| 12 | + Config::inst()->update('BasePage', 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function testPdfFilename() |
|
| 16 | - { |
|
| 17 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 18 | - $this->assertContains( |
|
| 19 | - 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 20 | - $page->getPdfFilename(), |
|
| 21 | - 'Generated filename for PDF' |
|
| 22 | - ); |
|
| 23 | - } |
|
| 15 | + public function testPdfFilename() |
|
| 16 | + { |
|
| 17 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 18 | + $this->assertContains( |
|
| 19 | + 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 20 | + $page->getPdfFilename(), |
|
| 21 | + 'Generated filename for PDF' |
|
| 22 | + ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function testPdfLink() |
|
| 26 | - { |
|
| 27 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 28 | - $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 29 | - } |
|
| 25 | + public function testPdfLink() |
|
| 26 | + { |
|
| 27 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 28 | + $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function testHomePagePdfLink() |
|
| 32 | - { |
|
| 33 | - $page = $this->objFromFixture('BasePage', 'home-page'); |
|
| 34 | - $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 35 | - } |
|
| 31 | + public function testHomePagePdfLink() |
|
| 32 | + { |
|
| 33 | + $page = $this->objFromFixture('BasePage', 'home-page'); |
|
| 34 | + $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function testPdfLinkDisabled() |
|
| 38 | - { |
|
| 39 | - Config::inst()->update('BasePage', 'pdf_export', false); |
|
| 40 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 41 | - $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 42 | - } |
|
| 37 | + public function testPdfLinkDisabled() |
|
| 38 | + { |
|
| 39 | + Config::inst()->update('BasePage', 'pdf_export', false); |
|
| 40 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 41 | + $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Test that the native language name can be returned for the current locale |
|
| 46 | - * |
|
| 47 | - * @see i18n |
|
| 48 | - * @param string $locale |
|
| 49 | - * @param string $expected |
|
| 50 | - * @dataProvider localeProvider |
|
| 51 | - */ |
|
| 52 | - public function testGetSelectedLanguage($locale, $expected) |
|
| 53 | - { |
|
| 54 | - if (!class_exists('Translatable')) { |
|
| 55 | - $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 56 | - } |
|
| 44 | + /** |
|
| 45 | + * Test that the native language name can be returned for the current locale |
|
| 46 | + * |
|
| 47 | + * @see i18n |
|
| 48 | + * @param string $locale |
|
| 49 | + * @param string $expected |
|
| 50 | + * @dataProvider localeProvider |
|
| 51 | + */ |
|
| 52 | + public function testGetSelectedLanguage($locale, $expected) |
|
| 53 | + { |
|
| 54 | + if (!class_exists('Translatable')) { |
|
| 55 | + $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - Translatable::set_current_locale($locale); |
|
| 59 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 60 | - $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 61 | - } |
|
| 58 | + Translatable::set_current_locale($locale); |
|
| 59 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 60 | + $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @return array[] |
|
| 65 | - */ |
|
| 66 | - public function localeProvider() |
|
| 67 | - { |
|
| 68 | - return array( |
|
| 69 | - array('en_NZ', 'English'), |
|
| 70 | - array('af_ZA', 'Afrikaans'), |
|
| 71 | - array('es_ES', 'español') |
|
| 72 | - ); |
|
| 73 | - } |
|
| 63 | + /** |
|
| 64 | + * @return array[] |
|
| 65 | + */ |
|
| 66 | + public function localeProvider() |
|
| 67 | + { |
|
| 68 | + return array( |
|
| 69 | + array('en_NZ', 'English'), |
|
| 70 | + array('af_ZA', 'Afrikaans'), |
|
| 71 | + array('es_ES', 'español') |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function tearDown() |
|
| 76 | - { |
|
| 77 | - Config::unnest(); |
|
| 78 | - parent::tearDown(); |
|
| 79 | - } |
|
| 75 | + public function tearDown() |
|
| 76 | + { |
|
| 77 | + Config::unnest(); |
|
| 78 | + parent::tearDown(); |
|
| 79 | + } |
|
| 80 | 80 | } |