ENHANCEMENT Testing new File.ShowInSearch flag, and adding it to AssetTableField view

This commit is contained in:
Ingo Schommer 2011-09-15 15:59:18 +02:00
parent ad88e28907
commit 2693f675db
3 changed files with 36 additions and 2 deletions

View File

@ -194,6 +194,13 @@ class AssetTableField extends ComplexTableField {
)
);
}
if(!($childData instanceof Folder)) {
$mainTab->addFieldToTab(
'BottomRoot.Main',
new CheckboxField("ShowInSearch", $childData->fieldLabel('ShowInSearch'))
);
}
if($childData && $childData->hasMethod('BackLinkTracking')) {
if(class_exists('Subsite')) Subsite::disable_subsite_filter(true);

View File

@ -170,7 +170,7 @@ class SearchFormTest extends FunctionalTest {
$member->logOut();
}
function testDisabledShowInSearchFlagNotIncluded() {
function testDisabledShowInSearchFlagNotIncludedForSiteTree() {
$sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
@ -181,6 +181,26 @@ class SearchFormTest extends FunctionalTest {
'Page with "Show in Search" disabled doesnt show'
);
}
function testDisabledShowInSearchFlagNotIncludedForFiles() {
$sf = new SearchForm($this->mockController, 'SearchForm');
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
$showInSearchFile = $this->objFromFixture('File', 'showInSearchFile');
$results = $sf->getResults(null, array('Search'=>'dontShowInSearchFile'));
$this->assertNotContains(
$dontShowInSearchFile->ID,
$results->column('ID'),
'File with "Show in Search" disabled doesnt show'
);
$results = $sf->getResults(null, array('Search'=>'showInSearchFile'));
$this->assertContains(
$showInSearchFile->ID,
$results->column('ID'),
'File with "Show in Search" enabled can be found'
);
}
function testSearchTitleAndContentWithSpecialCharacters() {
$sf = new SearchForm($this->mockController, 'SearchForm');

View File

@ -33,4 +33,11 @@ SiteTree:
ShowInSearch: 0
pageWithSpecialChars:
Title: Brötchen
Content: Frisch vom Bäcker
Content: Frisch vom Bäcker
File:
showInSearchFile:
Title: showInSearchFile
ShowInSearch: 1
dontShowInSearchFile:
Title: dontShowInSearchFile
ShowInSearch: 0