diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php index 4f6a06a..75c73bc 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php @@ -7,21 +7,21 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Tests\ViewTestBase; +use Drupal\views\Tests\ViewUnitTestBase; /** * Tests the generic entity row plugin. * * @see \Drupal\views\Plugin\views\row\EntityRow */ -class RowEntityTest extends ViewTestBase { +class RowEntityTest extends ViewUnitTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('entity_test'); + public static $modules = array('entity_test', 'taxonomy', 'field', 'entity', 'system'); /** * Views used by this test. @@ -30,6 +30,13 @@ class RowEntityTest extends ViewTestBase { */ public static $testViews = array('test_entity_row'); + /** + * A string for assert raw and text helper methods. + * + * @var string + */ + protected $content; + public static function getInfo() { return array( 'name' => 'Row: Entity', @@ -38,28 +45,50 @@ public static function getInfo() { ); } - /** - * Overrides \Drupal\views\Tests\ViewTestBase::viewsData(). - */ - protected function viewsData() { - $data = parent::viewsData(); + protected function setUp() { + parent::setUp(); - $data['entity_test_render'] = $data['entity_test']; - $data['entity_test_render']['real table'] = 'entity_test'; - return $data; + $this->installSchema('system', array('menu_router')); + $this->installSchema('taxonomy', array('taxonomy_term_data', 'taxonomy_term_hierarchy')); + $this->installSchema('field', array('field_config', 'field_config_instance')); } + /** * Tests the entity row handler. */ public function testEntityRow() { - $term = entity_create('entity_test', array('name' => $this->randomName())); + $term = entity_create('taxonomy_term', array('name' => $this->randomName())); $term->save(); $view = views_get_view('test_entity_row'); - $this->drupalSetContent($view->preview()); + $this->content = $view->preview(); $this->assertText($term->label(), 'The rendered entity appears as row in the view.'); } + /** + * Pass if the text IS found in set string. + * + * @param string $text + * Text to look for. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use format_string() to embed variables in the message text, not + * t(). If left blank, a default message will be displayed. + * @param string $group + * (optional) The group this message is in, which is displayed in a column + * in test output. Use 'Debug' to indicate this is debugging output. Do not + * translate this string. Defaults to 'Other'; most tests do not override + * this default. + * + * @return bool TRUE on pass, FALSE on fail. + */ + protected function assertText($text, $message = '', $group = 'Other') { + if (!$message) { + $message = t('Raw "@raw" found', array('@raw' => $text)); + } + return $this->assert(strpos(filter_xss($this->content, array()), $text) !== FALSE, $message, $group); + } + } diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_row.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_row.yml index 3e57407..d1da58e 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_row.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_row.yml @@ -1,4 +1,4 @@ -base_table: entity_test_render +base_table: taxonomy_term_data core: '8' description: '' status: '1' @@ -16,7 +16,7 @@ display: type: none pager_options: { } row: - type: 'entity:entity_test_render' + type: 'entity:taxonomy_term' options: relationship: none view_mode: full