diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index 681f2de..e531b65 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -9,13 +9,12 @@ use Behat\Mink\Driver\GoutteDriver; use Behat\Mink\Element\Element; -use Behat\Mink\Element\NodeElement; use Behat\Mink\Exception\Exception; use Behat\Mink\Mink; use Behat\Mink\Session; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Random; -use Drupal\Component\Utility\String; +use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\Database\Database; @@ -300,7 +299,10 @@ protected function setUp() { * The file path. */ public static function filePreDeleteCallback($path) { - chmod($path, 0700); + $success = @chmod($path, 0700); + if (!$success) { + trigger_error("Can not make $path writable whilst cleaning up test directory. The webserver and phpunit are probably not being run by the same user."); + } } /** @@ -487,7 +489,7 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL) $account = entity_create('user', $edit); $account->save(); - $this->assertNotNull($account->id(), String::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass']))); + $this->assertNotNull($account->id(), SafeMarkup::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass']))); if (!$account->id()) { return FALSE; } @@ -541,7 +543,7 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL } $result = $role->save(); - $this->assertSame($result, SAVED_NEW, String::format('Created role ID @rid with name @name.', array( + $this->assertSame($result, SAVED_NEW, SafeMarkup::format('Created role ID @rid with name @name.', array( '@name' => var_export($role->label(), TRUE), '@rid' => var_export($role->id(), TRUE), ))); @@ -553,7 +555,7 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL $assigned_permissions = entity_load('user_role', $role->id())->getPermissions(); $missing_permissions = array_diff($permissions, $assigned_permissions); if ($missing_permissions) { - $this->fail(String::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions)))); + $this->fail(SafeMarkup::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions)))); } } return $role->id(); @@ -639,7 +641,7 @@ protected function checkPermissions(array $permissions) { $valid = TRUE; foreach ($permissions as $permission) { if (!in_array($permission, $available)) { - $this->fail(String::format('Invalid permission %permission.', array('%permission' => $permission))); + $this->fail(SafeMarkup::format('Invalid permission %permission.', array('%permission' => $permission))); $valid = FALSE; } } @@ -687,7 +689,7 @@ protected function drupalLogin(AccountInterface $account) { // @see BrowserTestBase::drupalUserIsLoggedIn() $account->sessionId = $this->getSession()->getCookie(session_name()); - $this->assertTrue($this->drupalUserIsLoggedIn($account), String::format('User %name successfully logged in.', array('name' => $account->getUsername()))); + $this->assertTrue($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', array('name' => $account->getUsername()))); $this->loggedInUser = $account; $this->container->get('current_user')->setAccount($account); @@ -934,7 +936,7 @@ public function installDrupal() { if ($modules) { $modules = array_unique($modules); $success = $container->get('module_installer')->install($modules, TRUE); - $this->assertTrue($success, String::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); + $this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); $this->rebuildContainer(); } @@ -1046,7 +1048,7 @@ private function changeDatabasePrefix() { // Clone the current connection and replace the current prefix. $connection_info = Database::getConnectionInfo('default'); if (is_null($connection_info)) { - throw new \InvalidArgumentException('There is no database connection so no tests can be run.'); + throw new \InvalidArgumentException('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh.'); } else { Database::renameConnection('default', 'simpletest_original_default'); diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index fce7345..743bf08 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -6,8 +6,10 @@ - - + + + +