diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/RandomStringTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/RandomStringTest.php new file mode 100644 index 0000000..7851680 --- /dev/null +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/RandomStringTest.php @@ -0,0 +1,84 @@ + 'RandomString functionality', + 'description' => "Test SimpleTest's xpath on randomly generated strings", + 'group' => 'SimpleTest' + ); + } + + public function setUp() { + parent::setUp(); + + // Create and login user. + $this->web_user = $this->drupalCreateUser(array( + 'administer permissions', + )); + $this->drupalLogin($this->web_user); + } + + /** + * Checks that the UI will display a link created within the parameters of + * WebTestBase::RandomString. + * + * @see entity_test_entity_operation_alter() + */ + public function testXpathRandomString() { + + // Create roles. + $role_names = array( + 'abcdefgh', // should pass + 'abc\\123', // should fail - double \\ escaping + '$abcd123', // should pass, possibly with warning about variable name undefined + '$123abcd', // should fail - xpath variable missing + 'n57fk&$4', // recent test failure for #2019071 + 'n57fk&$a', // fail + 'n57fk&b4', // pass + '$a', // pass + '$1', // fail + '1$', // pass + ); + + foreach ($role_names as $role_name) { + $this->drupalCreateRole(array('administer permissions'), NULL, $role_name); + } + + // Check that role listing contain our test_operation operation. + $this->drupalGet('admin/people/roles'); + $roles = user_roles(); + foreach ($roles as $role) { + $uri = $role->uri(); + $this->assertLinkByHref($uri['path'] . '/test_operation'); + $this->assertLink(format_string('Test Operation: @label', array('@label' => $role->label()))); + } + } + +}