Merge pull request #2279 from creative-commoners/pulls/4.3/searching-for-sugarman

FIX Update field names in Behat tests for new search form namespacing
This commit is contained in:
Robbie Averill 2018-10-02 15:12:33 +02:00 committed by GitHub
commit 3b3ce70378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 15 deletions

View File

@ -911,13 +911,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$params = $this->getRequest()->requestVar('q') ?: []; $params = $this->getRequest()->requestVar('q') ?: [];
$context->setSearchParams($params); $context->setSearchParams($params);
$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERLABELTEXT', 'Search') . ' "' . SiteTree::singleton()->i18n_plural_name() . '"'; $placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERLABELTEXT', 'Search') . ' "' .
SiteTree::singleton()->i18n_plural_name() . '"';
$searchParams = $context->getSearchParams();
$searchParams = array_combine(array_map(function ($key) {
return 'Search__' . $key;
}, array_keys($searchParams)), $searchParams);
$schema = [ $schema = [
'formSchemaUrl' => $schemaUrl, 'formSchemaUrl' => $schemaUrl,
'name' => 'Term', 'name' => 'Term',
'placeholder' => $placeholder, 'placeholder' => $placeholder,
'filters' => $context->getSearchParams() ?: new \stdClass // stdClass maps to empty json object '{}' 'filters' => $searchParams ?: new \stdClass // stdClass maps to empty json object '{}'
]; ];
return Convert::raw2json($schema); return Convert::raw2json($schema);
@ -934,24 +941,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
{ {
// Create the fields // Create the fields
$dateFrom = DateField::create( $dateFrom = DateField::create(
'LastEditedFrom', 'Search__LastEditedFrom',
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM', 'From') _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM', 'From')
)->setLocale(Security::getCurrentUser()->Locale); )->setLocale(Security::getCurrentUser()->Locale);
$dateTo = DateField::create( $dateTo = DateField::create(
'LastEditedTo', 'Search__LastEditedTo',
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATETO', 'To') _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATETO', 'To')
)->setLocale(Security::getCurrentUser()->Locale); )->setLocale(Security::getCurrentUser()->Locale);
$filters = CMSSiteTreeFilter::get_all_filters(); $filters = CMSSiteTreeFilter::get_all_filters();
// Remove 'All pages' as we set that to empty/default value // Remove 'All pages' as we set that to empty/default value
unset($filters[CMSSiteTreeFilter_Search::class]); unset($filters[CMSSiteTreeFilter_Search::class]);
$pageFilter = DropdownField::create( $pageFilter = DropdownField::create(
'FilterClass', 'Search__FilterClass',
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGES', 'Page status'), _t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGES', 'Page status'),
$filters $filters
); );
$pageFilter->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGESALLOPT', 'All pages')); $pageFilter->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGESALLOPT', 'All pages'));
$pageClasses = DropdownField::create( $pageClasses = DropdownField::create(
'ClassName', 'Search__ClassName',
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'), _t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
$this->getPageTypes() $this->getPageTypes()
); );
@ -961,7 +968,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$dateGroup = FieldGroup::create( $dateGroup = FieldGroup::create(
_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'), _t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'),
[$dateFrom, $dateTo] [$dateFrom, $dateTo]
)->setName('LastEdited') )->setName('Search__LastEdited')
->addExtraClass('fieldgroup--fill-width'); ->addExtraClass('fieldgroup--fill-width');
// Create the Field list // Create the Field list

View File

@ -14,7 +14,7 @@ Feature: Search for a page
Scenario: I can search for a page by its title Scenario: I can search for a page by its title
Given I fill in "Search" with "About Us" Given I fill in "Search" with "About Us"
And I press the "Enter" key in the "Term" field And I press the "Enter" key in the "SearchBox__Term" field
Then I should see "About Us" in the cms list Then I should see "About Us" in the cms list
But I should not see "Contact Us" in the cms list But I should not see "Contact Us" in the cms list
@ -22,7 +22,7 @@ Feature: Search for a page
Given a "Virtual Page" "My Virtual Page" Given a "Virtual Page" "My Virtual Page"
When I press the "Advanced" button When I press the "Advanced" button
And I select "Virtual Page" from "Page type" And I select "Virtual Page" from "Page type"
And I press the "Enter" key in the "Term" field And I press the "Enter" key in the "SearchBox__Term" field
Then I should see "My Virtual Page" in the cms list Then I should see "My Virtual Page" in the cms list
But I should not see "Contact Us" in the cms list But I should not see "Contact Us" in the cms list
@ -50,7 +50,7 @@ Feature: Search for a page
Given a "page" "Deleted Page" Given a "page" "Deleted Page"
And the "page" "Deleted Page" is unpublished And the "page" "Deleted Page" is unpublished
And the "page" "Deleted Page" is deleted And the "page" "Deleted Page" is deleted
When I press the "Enter" key in the "Term" field When I press the "Enter" key in the "SearchBox__Term" field
Then I should not see "Deleted Page" in the cms list Then I should not see "Deleted Page" in the cms list
When I press the "Advanced" button When I press the "Advanced" button
And I select "All pages, including archived" from "Page status" And I select "All pages, including archived" from "Page status"
@ -61,7 +61,7 @@ Feature: Search for a page
Given a "page" "Deleted Page" Given a "page" "Deleted Page"
And the "page" "Deleted Page" is unpublished And the "page" "Deleted Page" is unpublished
And the "page" "Deleted Page" is deleted And the "page" "Deleted Page" is deleted
When I press the "Enter" key in the "Term" field When I press the "Enter" key in the "SearchBox__Term" field
Then I should not see "Deleted Page" in the cms list Then I should not see "Deleted Page" in the cms list
When I press the "Advanced" button When I press the "Advanced" button
And I select "Archived pages" from "Page status" And I select "Archived pages" from "Page status"
@ -72,7 +72,7 @@ Feature: Search for a page
Scenario: I can include draft pages in my search Scenario: I can include draft pages in my search
Given a "page" "Draft Page" Given a "page" "Draft Page"
And the "page" "Draft Page" is not published And the "page" "Draft Page" is not published
When I press the "Enter" key in the "Term" field When I press the "Enter" key in the "SearchBox__Term" field
Then I should see "Draft Page" in the cms list Then I should see "Draft Page" in the cms list
When I press the "Advanced" button When I press the "Advanced" button
And I select "Draft pages" from "Page status" And I select "Draft pages" from "Page status"
@ -100,7 +100,7 @@ Feature: Search for a page
Given a "page" "Live Page" Given a "page" "Live Page"
And the "page" "Live Page" is published And the "page" "Live Page" is published
And the "page" "Live Page" is deleted And the "page" "Live Page" is deleted
When I press the "Enter" key in the "Term" field When I press the "Enter" key in the "SearchBox__Term" field
Then I should not see "Live Page" in the cms list Then I should not see "Live Page" in the cms list
When I press the "Advanced" button When I press the "Advanced" button
And I select "Live but removed from draft" from "Page status" And I select "Live but removed from draft" from "Page status"

View File

@ -653,8 +653,8 @@ class CMSMainTest extends FunctionalTest
'name' => 'Term', 'name' => 'Term',
'placeholder' => 'Search "Pages"', 'placeholder' => 'Search "Pages"',
'filters' => [ 'filters' => [
'Term' => 'test', 'Search__Term' => 'test',
'FilterClass' => 'SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search' 'Search__FilterClass' => 'SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search'
] ]
]), ]),
$searchSchema $searchSchema