mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
e2d17d9b99
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112051 467b73ca-7a2a-4603-9d3b-597d59a354a9
81 lines
2.5 KiB
PHP
81 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage testing
|
|
*/
|
|
class TranslatableSearchFormTest extends FunctionalTest {
|
|
|
|
static $fixture_file = 'sapphire/tests/search/TranslatableSearchFormTest.yml';
|
|
|
|
protected $mockController;
|
|
|
|
protected $requiredExtensions = array(
|
|
'SiteTree' => array(
|
|
'Translatable',
|
|
"MySQLFulltextSearchable('Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords')",
|
|
),
|
|
"File" => array(
|
|
"MySQLFulltextSearchable('Filename,Title,Content')",
|
|
),
|
|
"ContentController" => array(
|
|
"ContentControllerSearchExtension",
|
|
),
|
|
);
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
|
|
$holderPage = $this->objFromFixture('SiteTree', 'searchformholder');
|
|
$this->mockController = new ContentController($holderPage);
|
|
|
|
// whenever a translation is created, canTranslate() is checked
|
|
$admin = $this->objFromFixture('Member', 'admin');
|
|
$admin->logIn();
|
|
}
|
|
|
|
|
|
|
|
function testPublishedPagesMatchedByTitleInDefaultLanguage() {
|
|
$sf = new SearchForm($this->mockController, 'SearchForm');
|
|
|
|
$publishedPage = $this->objFromFixture('SiteTree', 'publishedPage');
|
|
$publishedPage->publish('Stage', 'Live');
|
|
$translatedPublishedPage = $publishedPage->createTranslation('de_DE');
|
|
$translatedPublishedPage->Title = 'translatedPublishedPage';
|
|
$translatedPublishedPage->Content = 'German content';
|
|
$translatedPublishedPage->write();
|
|
$translatedPublishedPage->publish('Stage', 'Live');
|
|
|
|
// Translatable::set_current_locale() can't be used because the context
|
|
// from the holder is not present here - we set the language explicitly
|
|
// through a pseudo GET variable in getResults()
|
|
|
|
$lang = 'en_US';
|
|
$results = $sf->getResults(null, array('Search'=>'content', 'locale'=>$lang));
|
|
$this->assertContains(
|
|
$publishedPage->ID,
|
|
$results->column('ID'),
|
|
'Published pages are found by searchform in default language'
|
|
);
|
|
$this->assertNotContains(
|
|
$translatedPublishedPage->ID,
|
|
$results->column('ID'),
|
|
'Published pages in another language are not found when searching in default language'
|
|
);
|
|
|
|
$lang = 'de_DE';
|
|
$results = $sf->getResults(null, array('Search'=>'content', 'locale'=>$lang));
|
|
$this->assertNotContains(
|
|
$publishedPage->ID,
|
|
$results->column('ID'),
|
|
'Published pages in default language are not found when searching in another language'
|
|
);
|
|
$this->assertContains(
|
|
$translatedPublishedPage->ID,
|
|
$results->column('ID'),
|
|
'Published pages in another language are found when searching in this language'
|
|
);
|
|
}
|
|
|
|
}
|
|
?>
|