From 2693f675db4df12ca0a5043d0a29ec2143132926 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 15 Sep 2011 15:59:18 +0200 Subject: [PATCH] ENHANCEMENT Testing new File.ShowInSearch flag, and adding it to AssetTableField view --- code/forms/AssetTableField.php | 7 +++++++ tests/search/SearchFormTest.php | 22 +++++++++++++++++++++- tests/search/SearchFormTest.yml | 9 ++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/code/forms/AssetTableField.php b/code/forms/AssetTableField.php index cce13569..a446b38c 100755 --- a/code/forms/AssetTableField.php +++ b/code/forms/AssetTableField.php @@ -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); diff --git a/tests/search/SearchFormTest.php b/tests/search/SearchFormTest.php index e56236e1..9d5b9ebe 100644 --- a/tests/search/SearchFormTest.php +++ b/tests/search/SearchFormTest.php @@ -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'); diff --git a/tests/search/SearchFormTest.yml b/tests/search/SearchFormTest.yml index 91c18cfb..a88861ae 100644 --- a/tests/search/SearchFormTest.yml +++ b/tests/search/SearchFormTest.yml @@ -33,4 +33,11 @@ SiteTree: ShowInSearch: 0 pageWithSpecialChars: Title: Brötchen - Content: Frisch vom Bäcker \ No newline at end of file + Content: Frisch vom Bäcker +File: + showInSearchFile: + Title: showInSearchFile + ShowInSearch: 1 + dontShowInSearchFile: + Title: dontShowInSearchFile + ShowInSearch: 0 \ No newline at end of file