@@ -12,80 +12,80 @@ |
||
| 12 | 12 | |
| 13 | 13 | class BasePageTest extends SapphireTest |
| 14 | 14 | { |
| 15 | - public static $fixture_file = 'BasePageTest.yml'; |
|
| 16 | - |
|
| 17 | - public function setUp() |
|
| 18 | - { |
|
| 19 | - parent::setUp(); |
|
| 20 | - |
|
| 21 | - Config::nest(); |
|
| 22 | - Config::inst()->update(BasePage::class, 'pdf_export', true); |
|
| 23 | - Config::inst()->update(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function testPdfFilename() |
|
| 27 | - { |
|
| 28 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 29 | - $this->assertContains( |
|
| 30 | - 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 31 | - $page->getPdfFilename(), |
|
| 32 | - 'Generated filename for PDF' |
|
| 33 | - ); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function testPdfLink() |
|
| 37 | - { |
|
| 38 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 39 | - $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function testHomePagePdfLink() |
|
| 43 | - { |
|
| 44 | - $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
| 45 | - $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function testPdfLinkDisabled() |
|
| 49 | - { |
|
| 50 | - Config::inst()->update(BasePage::class, 'pdf_export', false); |
|
| 51 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 52 | - $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Test that the native language name can be returned for the current locale |
|
| 57 | - * |
|
| 58 | - * @see i18n |
|
| 59 | - * @param string $locale |
|
| 60 | - * @param string $expected |
|
| 61 | - * @dataProvider localeProvider |
|
| 62 | - */ |
|
| 63 | - public function testGetSelectedLanguage($locale, $expected) |
|
| 64 | - { |
|
| 65 | - if (!class_exists('Translatable')) { |
|
| 66 | - $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - Translatable::set_current_locale($locale); |
|
| 70 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 71 | - $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return array[] |
|
| 76 | - */ |
|
| 77 | - public function localeProvider() |
|
| 78 | - { |
|
| 79 | - return array( |
|
| 80 | - array('en_NZ', 'English'), |
|
| 81 | - array('af_ZA', 'Afrikaans'), |
|
| 82 | - array('es_ES', 'español') |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - public function tearDown() |
|
| 87 | - { |
|
| 88 | - Config::unnest(); |
|
| 89 | - parent::tearDown(); |
|
| 90 | - } |
|
| 15 | + public static $fixture_file = 'BasePageTest.yml'; |
|
| 16 | + |
|
| 17 | + public function setUp() |
|
| 18 | + { |
|
| 19 | + parent::setUp(); |
|
| 20 | + |
|
| 21 | + Config::nest(); |
|
| 22 | + Config::inst()->update(BasePage::class, 'pdf_export', true); |
|
| 23 | + Config::inst()->update(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function testPdfFilename() |
|
| 27 | + { |
|
| 28 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 29 | + $this->assertContains( |
|
| 30 | + 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 31 | + $page->getPdfFilename(), |
|
| 32 | + 'Generated filename for PDF' |
|
| 33 | + ); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function testPdfLink() |
|
| 37 | + { |
|
| 38 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 39 | + $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function testHomePagePdfLink() |
|
| 43 | + { |
|
| 44 | + $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
| 45 | + $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function testPdfLinkDisabled() |
|
| 49 | + { |
|
| 50 | + Config::inst()->update(BasePage::class, 'pdf_export', false); |
|
| 51 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 52 | + $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Test that the native language name can be returned for the current locale |
|
| 57 | + * |
|
| 58 | + * @see i18n |
|
| 59 | + * @param string $locale |
|
| 60 | + * @param string $expected |
|
| 61 | + * @dataProvider localeProvider |
|
| 62 | + */ |
|
| 63 | + public function testGetSelectedLanguage($locale, $expected) |
|
| 64 | + { |
|
| 65 | + if (!class_exists('Translatable')) { |
|
| 66 | + $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + Translatable::set_current_locale($locale); |
|
| 70 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
| 71 | + $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return array[] |
|
| 76 | + */ |
|
| 77 | + public function localeProvider() |
|
| 78 | + { |
|
| 79 | + return array( |
|
| 80 | + array('en_NZ', 'English'), |
|
| 81 | + array('af_ZA', 'Afrikaans'), |
|
| 82 | + array('es_ES', 'español') |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + public function tearDown() |
|
| 87 | + { |
|
| 88 | + Config::unnest(); |
|
| 89 | + parent::tearDown(); |
|
| 90 | + } |
|
| 91 | 91 | } |