only in patch2: unchanged: --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterCompareUiTest.php @@ -0,0 +1,78 @@ + 'name', + ); + + /** + * Views used by this test. + ); + + /** + * Views used by this test. + * + * @var array + */ + public static $testViews = array('test_filter_compare'); + + public static function getInfo() { + return array( + 'name' => 'Filter: Compare UI', + 'description' => 'Tests the compare filter handler UI.', + 'group' => 'Views Handlers', + ); + } + + /** + * Tests the compare handler. + */ + public function testCompare() { + $this->drupalGet('admin/structure/views/nojs/config-item/test_filter_compare/default/filter/fields_compare'); + + $left_field = $this->xpath('//select[@name="options[left_field]"]/option'); + $right_field = $this->xpath('//select[@name="options[right_field]"]/option'); + + // Ensure available options. + $this->assertEqual((string) $left_field[0]['value'], 'created'); + $this->assertEqual((string) $right_field[0]['value'], 'created'); + $this->assertEqual((string) $left_field[1]['value'], 'age'); + $this->assertEqual((string) $right_field[1]['value'], 'age'); + $this->assertEqual((string) $left_field[2]['value'], 'name'); + $this->assertEqual((string) $right_field[2]['value'], 'name'); + + $edit = array(); + $edit['options[left_field]'] = 'name'; + $edit['options[right_field]'] = 'age'; + + $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->drupalPostForm(NULL, array(), t('Save')); + + $view = \Drupal::entityManager()->getStorageController('view')->load('test_filter_compare'); + $display = $view->getDisplay('default'); + $this->assertEqual($display['display_options']['filters']['fields_compare']['left_field'], 'name'); + $this->assertEqual($display['display_options']['filters']['fields_compare']['right_field'], 'age'); + } + +}