commit fca1c4e5f4328f3345cac92f6a950614a0044b89 Author: Joel Pittet Date: Mon Aug 31 20:43:02 2015 -0700 poor tests diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php index 8329d04..b7d8e70 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php @@ -43,6 +43,27 @@ public function testViewsHandlerAllTermsField() { $this->assertEqual($actual[1]->__toString(), $this->term2->label()); } + public function testViewsHandlerAllTermsFieldWithTemplate() { + // Install theme to test with template system. + \Drupal::service('theme_handler')->install(array('views_test_theme')); + + // Make base theme default then test for hook invocations. + $this->config('system.theme') + ->set('default', 'views_test_theme') + ->save(); + $this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme'); + $this->drupalGet('test_page_display_200'); + + // Assert that we are using the correct template. + $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template'); + + // @todo Fix this. + $this->testViewsHandlerAllTermsField(); + + // Assert that there are no escaped '<'s characters. + $this->assertNoEscaped('<'); + } + /** * Tests token replacement in the "all terms" field handler. */ diff --git a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php index 0072d67..acd3ed2 100644 --- a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php @@ -18,12 +18,24 @@ */ class HandlerFieldRoleTest extends UserTestBase { + public static $modules = array('views', 'theme_test'); + /** * Views used by this test. * * @var array */ - public static $testViews = array('test_views_handler_field_role'); + public static $testViews = array('test_views_handler_field_role', 'test_page_display'); + + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->enableViewsTestModule(); + } public function testRole() { // Create a couple of roles for the view. @@ -42,8 +54,6 @@ public function testRole() { $user->addRole($rolename_b); $user->save(); - debug(db_query('SELECT * FROM {user__roles}')->fetchAll()); - $view = Views::getView('test_views_handler_field_role'); $this->executeView($view); // The role field is populated during preRender. @@ -54,4 +64,28 @@ public function testRole() { $this->assertFalse(strpos($render, $rolename_not_assigned), 'View test_views_handler_field_role does not render a role not assigned to a user.'); } + /** + * Tests Role fields with + */ + public function testRoleWithTemplate() { + // Install theme to test with template system. + \Drupal::service('theme_handler')->install(array('views_test_theme')); + + // Make base theme default then test for hook invocations. + $this->config('system.theme') + ->set('default', 'views_test_theme') + ->save(); + $this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme'); + $this->drupalGet('test_page_display_200'); + + // Assert that we are using the correct template. + $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template'); + + // @todo Fix this. + $this->testRole(); + + // Assert that there are no escaped '<'s characters. + $this->assertNoEscaped('<'); + } + } diff --git a/core/modules/views/src/Tests/ViewsEscapingTest.php b/core/modules/views/src/Tests/ViewsEscapingTest.php index 400ed26..63f750a 100644 --- a/core/modules/views/src/Tests/ViewsEscapingTest.php +++ b/core/modules/views/src/Tests/ViewsEscapingTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Tests output of Views. * @@ -21,7 +19,7 @@ class ViewsEscapingTest extends ViewTestBase { * * @var array */ - public static $testViews = array('test_page_display', 'taxonomy_all_terms_test'); + public static $testViews = array('test_page_display'); /** * Used by WebTestBase::setup() @@ -32,7 +30,7 @@ class ViewsEscapingTest extends ViewTestBase { * * @see \Drupal\simpletest\WebTestBase::setup() */ - public static $modules = array('views', 'theme_test', 'taxonomy', 'taxonomy_test_views'); + public static $modules = array('views', 'theme_test'); /** * {@inheritdoc} @@ -78,6 +76,9 @@ public function testViewsViewFieldEscaping() { // Test with system theme using theme function. $this->drupalGet('test_page_display_200'); + // Assert that we are using the theme function. + $this->assertNoText('llama', 'Loaded the correct theme function views_view_field()'); + // Assert that there are no escaped '<'s characters. $this->assertNoEscaped('<'); @@ -89,7 +90,6 @@ public function testViewsViewFieldEscaping() { ->set('default', 'views_test_theme') ->save(); $this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme'); - $this->drupalGet('test_page_display_200'); // Assert that we are using the correct template. @@ -97,12 +97,6 @@ public function testViewsViewFieldEscaping() { // Assert that there are no escaped '<'s characters. $this->assertNoEscaped('<'); - - // Assert taxonomy field links are not escaped. - $view = Views::getView('taxonomy_all_terms_test'); - $this->executeView($view); - $this->drupalGet('taxonomy_all_terms_test'); - $this->assertNoEscaped('<'); } } diff --git a/core/modules/views_ui/src/Tests/CustomBooleanTest.php b/core/modules/views_ui/src/Tests/CustomBooleanTest.php index 08fbda8..618079a 100644 --- a/core/modules/views_ui/src/Tests/CustomBooleanTest.php +++ b/core/modules/views_ui/src/Tests/CustomBooleanTest.php @@ -108,5 +108,29 @@ public function testCustomOption() { } } + /** + * Tests the setting and output of custom labels for boolean values. + */ + public function testCustomOptionWithTemplate() { + // Install theme to test with template system. + \Drupal::service('theme_handler')->install(array('views_test_theme')); + + // Make base theme default then test for hook invocations. + $this->config('system.theme') + ->set('default', 'views_test_theme') + ->save(); + $this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme'); + $this->drupalGet('test_page_display_200'); + + // Assert that we are using the correct template. + $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template'); + + // @todo Fix this. + $this->testCustomOption(); + + // Assert that there are no escaped '<'s characters. + $this->assertNoEscaped('<'); + } + }