2009-01-19 03:18:41 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage testing
|
|
|
|
*/
|
|
|
|
class TranslatableSearchFormTest extends FunctionalTest {
|
|
|
|
|
|
|
|
static $fixture_file = 'sapphire/tests/search/TranslatableSearchFormTest.yml';
|
|
|
|
|
|
|
|
protected $mockController;
|
|
|
|
|
|
|
|
protected $recreateTempDb = true;
|
|
|
|
|
|
|
|
function setUp() {
|
2009-03-20 09:56:57 +01:00
|
|
|
$this->origTranslatableSettings['enabled'] = Translatable::is_enabled();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->origTranslatableSettings['default_locale'] = Translatable::default_locale();
|
2009-01-19 03:18:41 +01:00
|
|
|
Translatable::enable();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
Translatable::set_default_locale("en");
|
2009-01-19 03:18:41 +01:00
|
|
|
|
|
|
|
// needs to recreate the database schema with language properties
|
|
|
|
self::kill_temp_db();
|
|
|
|
// refresh the decorated statics - different fields in $db with Translatable enabled
|
|
|
|
singleton('SiteTree')->loadExtraStatics();
|
|
|
|
singleton('TranslatableTest_DataObject')->loadExtraStatics();
|
|
|
|
$dbname = self::create_temp_db();
|
|
|
|
DB::set_alternative_database_name($dbname);
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$holderPage = $this->objFromFixture('SiteTree', 'searchformholder');
|
|
|
|
$this->mockController = new ContentController($holderPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
function tearDown() {
|
|
|
|
if(!$this->origTranslatableSettings['enabled']) Translatable::disable();
|
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
Translatable::set_default_locale($this->origTranslatableSettings['default_locale']);
|
2009-01-19 03:18:41 +01:00
|
|
|
|
|
|
|
self::kill_temp_db();
|
|
|
|
self::create_temp_db();
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testPublishedPagesMatchedByTitleInDefaultLanguage() {
|
|
|
|
$sf = new SearchForm($this->mockController, 'SearchForm');
|
|
|
|
|
|
|
|
$publishedPage = $this->objFromFixture('SiteTree', 'publishedPage');
|
|
|
|
$publishedPage->publish('Stage', 'Live');
|
|
|
|
$translatedPublishedPage = $publishedPage->createTranslation('de');
|
|
|
|
$translatedPublishedPage->Title = 'translatedPublishedPage';
|
|
|
|
$translatedPublishedPage->Content = 'German content';
|
|
|
|
$translatedPublishedPage->write();
|
|
|
|
$translatedPublishedPage->publish('Stage', 'Live');
|
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
// Translatable::set_reading_locale() can't be used because the context
|
2009-01-19 03:18:41 +01:00
|
|
|
// from the holder is not present here - we set the language explicitly
|
|
|
|
// through a pseudo GET variable in getResults()
|
|
|
|
|
|
|
|
$lang = 'en';
|
|
|
|
$results = $sf->getResults(null, array('Search'=>'content', 'lang'=>$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';
|
|
|
|
$results = $sf->getResults(null, array('Search'=>'content', 'lang'=>$lang));
|
|
|
|
$this->assertNotContains(
|
|
|
|
$publishedPage->ID,
|
|
|
|
$results->column('ID'),
|
|
|
|
'Published pages in default language are not found when searching in another language'
|
|
|
|
);
|
|
|
|
$this->assertContains(
|
|
|
|
(string)$translatedPublishedPage->ID,
|
|
|
|
$results->column('ID'),
|
|
|
|
'Published pages in another language are found when searching in this language'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|