diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php index bc50a84..8a73f2e 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php @@ -9,6 +9,7 @@ use Drupal\Component\Annotation\PluginID; use Drupal\views\Plugin\views\style\DefaultSummary; +use Drupal\Component\Utility\Xss; /** * Views area handler to display some configurable result summary. @@ -105,7 +106,7 @@ public function render($empty = FALSE) { } // Send the output. if (!empty($total)) { - $output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format)); + $output .= Xss::filterAdmin(str_replace(array_keys($replacements), array_values($replacements), $format)); } // Return as render array. return array( diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/area/ResultTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/area/ResultTest.php index 4398f7c..de90da8 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Plugin/area/ResultTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/area/ResultTest.php @@ -2,32 +2,26 @@ /** * @file - * Contains \Drupal\views\Tests\Handler\AreaResultTest. + * Contains \Drupal\views\Tests\Plugin\area\ResultTest. */ -namespace Drupal\views\Tests\Handler; +namespace Drupal\views\Tests\Plugin\area; -use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; +use Drupal\Tests\UnitTestCase; +use Drupal\views\ViewExecutable; +use Drupal\views\Plugin\views\area\Result; /** * Tests the result area handler. * * @see Drupal\views\Plugin\views\area\Result */ -class AreaResultTest extends ViewUnitTestBase { - - /** - * Views used by this test. - * - * @var array - */ - public static $testViews = array('test_view'); +class ResultTest extends UnitTestCase { public static function getInfo() { return array( 'name' => 'Area: Result', - 'description' => 'Test the Drupal\views\Plugin\views\area\Result handler.', + 'description' => 'Tests the Drupal\views\Plugin\views\area\Result handler.', 'group' => 'Views Handlers', ); } @@ -36,26 +30,36 @@ public static function getInfo() { * Tests the rendered output of the Result area handler. */ public function testResultArea() { - $view = Views::getView('test_view'); - $view->setDisplay(); - - // Add a result handler. - $view->displayHandlers->get('default')->overrideOption('header', array( - 'result' => array( - 'id' => 'result', - 'table' => 'views', - 'field' => 'result', - 'content' => '', - ), - )); - - // Execute the view. - $this->executeView($view); - - $handler =& $view->display_handler->handlers['header']['result']; - - $handler->options['content'] = '@label'; - $this->assertEqual(array('#markup' => $view->storage->label()), $handler->render()); + $storage = $this->getMockBuilder('Drupal\views\Plugin\Core\Entity\View') + ->disableOriginalConstructor() + ->setMethods(array('label')) + ->getMock(); + $storage->expects($this->once()) + ->method('label') + ->will($this->returnValue('ResultTest')); + + $view = new ViewExecutable($storage); + + $pager = $this->getMockBuilder('Drupal\views\Plugin\views\pager\PagerPluginBase') + ->disableOriginalConstructor() + ->setMethods(array('getItemsPerPage', 'getCurrentPage')) + ->getMock(); + $pager->expects($this->once()) + ->method('getItemsPerPage') + ->will($this->returnValue(10)); + $pager->expects($this->once()) + ->method('getCurrentPage') + ->will($this->returnValue(1)); + + $view->pager = $pager; + $view->style_plugin = new \stdClass(); + $view->total_rows = 100; + + $result_handler = new Result(array(), 'result', array()); + $result_handler->view = $view; + + $result_handler->options['content'] = '@label'; + $this->assertEquals(array('#markup' => 'ResultTest'), $result_handler->render()); } }