updated core
This commit is contained in:
@@ -10,7 +10,7 @@ use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\AssertHelperTrait instead.
|
||||
* \Drupal\Tests\block\Traits\BlockCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ use Drupal\Tests\node\Traits\ContentTypeCreationTrait as BaseContentTypeCreation
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\ContentTypeCreationTrait instead.
|
||||
* \Drupal\Tests\node\Traits\ContentTypeCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
|
||||
@@ -226,7 +226,6 @@ EOD;
|
||||
$this->kernel->shutdown();
|
||||
$this->kernel->boot();
|
||||
|
||||
|
||||
// Save the original site directory path, so that extensions in the
|
||||
// site-specific directory can still be discovered in the test site
|
||||
// environment.
|
||||
|
||||
@@ -10,7 +10,7 @@ use Drupal\Tests\node\Traits\NodeCreationTrait as BaseNodeCreationTrait;
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\NodeCreationTrait instead.
|
||||
* \Drupal\Tests\node\Traits\NodeCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preLoadRoutes($names){
|
||||
public function preLoadRoutes($names) {
|
||||
return $this->lazyLoadItself()->preLoadRoutes($names);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ abstract class TestBase {
|
||||
|
||||
/**
|
||||
* Time limit for the test.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $timeLimit = 500;
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* This test will check SimpleTest's treatment of hook_install during setUp.
|
||||
* Image module is used for test.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class FolderTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('image');
|
||||
|
||||
function testFolderSetup() {
|
||||
$directory = file_default_scheme() . '://styles';
|
||||
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,8 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
|
||||
* contained in the Testing profile.
|
||||
*
|
||||
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $profile = 'testing';
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests the SimpleTest email capturing logic, the assertMail assertion and the
|
||||
* drupalGetMails function.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class MailCaptureTest extends WebTestBase {
|
||||
/**
|
||||
* Test to see if the wrapper function is executed correctly.
|
||||
*/
|
||||
function testMailSend() {
|
||||
// Create an email.
|
||||
$subject = $this->randomString(64);
|
||||
$body = $this->randomString(128);
|
||||
$message = array(
|
||||
'id' => 'drupal_mail_test',
|
||||
'headers' => array('Content-type' => 'text/html'),
|
||||
'subject' => $subject,
|
||||
'to' => 'foobar@example.com',
|
||||
'body' => $body,
|
||||
);
|
||||
|
||||
// Before we send the email, drupalGetMails should return an empty array.
|
||||
$captured_emails = $this->drupalGetMails();
|
||||
$this->assertEqual(count($captured_emails), 0, 'The captured emails queue is empty.', 'Email');
|
||||
|
||||
// Send the email.
|
||||
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'simpletest', 'key' => 'drupal_mail_test'))->mail($message);
|
||||
|
||||
// Ensure that there is one email in the captured emails array.
|
||||
$captured_emails = $this->drupalGetMails();
|
||||
$this->assertEqual(count($captured_emails), 1, 'One email was captured.', 'Email');
|
||||
|
||||
// Assert that the email was sent by iterating over the message properties
|
||||
// and ensuring that they are captured intact.
|
||||
foreach ($message as $field => $value) {
|
||||
$this->assertMail($field, $value, format_string('The email was sent and the value for property @field is intact.', array('@field' => $field)), 'Email');
|
||||
}
|
||||
|
||||
// Send additional emails so more than one email is captured.
|
||||
for ($index = 0; $index < 5; $index++) {
|
||||
$message = array(
|
||||
'id' => 'drupal_mail_test_' . $index,
|
||||
'headers' => array('Content-type' => 'text/html'),
|
||||
'subject' => $this->randomString(64),
|
||||
'to' => $this->randomMachineName(32) . '@example.com',
|
||||
'body' => $this->randomString(512),
|
||||
);
|
||||
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
|
||||
}
|
||||
|
||||
// There should now be 6 emails captured.
|
||||
$captured_emails = $this->drupalGetMails();
|
||||
$this->assertEqual(count($captured_emails), 6, 'All emails were captured.', 'Email');
|
||||
|
||||
// Test different ways of getting filtered emails via drupalGetMails().
|
||||
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test'));
|
||||
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id.', 'Email');
|
||||
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject));
|
||||
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id and subject.', 'Email');
|
||||
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
|
||||
$this->assertEqual(count($captured_emails), 0, 'No emails are returned when querying with an unused from address.', 'Email');
|
||||
|
||||
// Send the last email again, so we can confirm that the
|
||||
// drupalGetMails-filter correctly returns all emails with a given
|
||||
// property/value.
|
||||
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
|
||||
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
|
||||
$this->assertEqual(count($captured_emails), 2, 'All emails with the same id are returned when filtering by id.', 'Email');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* This test should not load since it requires a module that is not found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @dependencies simpletest_missing_module
|
||||
*/
|
||||
class MissingDependentModuleUnitTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Ensure that this test will not be loaded despite its dependency.
|
||||
*/
|
||||
function testFail() {
|
||||
$this->fail('Running test with missing required module.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Verifies that tests in other installation profiles are found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @see SimpleTestInstallationProfileModuleTestsTestCase
|
||||
*/
|
||||
class OtherInstallationProfileTestsTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('simpletest');
|
||||
|
||||
/**
|
||||
* Use the Minimal profile.
|
||||
*
|
||||
* The Testing profile contains drupal_system_listing_compatible_test.test,
|
||||
* which should be found.
|
||||
*
|
||||
* The Standard profile contains \Drupal\standard\Tests\StandardTest, which
|
||||
* should be found.
|
||||
*
|
||||
* @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
|
||||
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
|
||||
*/
|
||||
protected $profile = 'minimal';
|
||||
|
||||
/**
|
||||
* An administrative user with permission to administer unit tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that tests located in another installation profile appear.
|
||||
*/
|
||||
function testOtherInstallationProfile() {
|
||||
// Assert the existence of a test in a different installation profile than
|
||||
// the current.
|
||||
$this->drupalGet('admin/config/development/testing');
|
||||
$this->assertText('Tests Standard installation profile expectations.');
|
||||
|
||||
// Assert the existence of a test for a module in a different installation
|
||||
// profile than the current.
|
||||
$this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests User related helper methods of WebTestBase.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class UserHelpersTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Tests WebTestBase::drupalUserIsLoggedIn().
|
||||
*/
|
||||
function testDrupalUserIsLoggedIn() {
|
||||
$first_user = $this->drupalCreateUser();
|
||||
$second_user = $this->drupalCreateUser();
|
||||
|
||||
// After logging in, the first user should be logged in, the second not.
|
||||
$this->drupalLogin($first_user);
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
|
||||
|
||||
// Verify that logged in state is retained across pages.
|
||||
$this->drupalGet('');
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
|
||||
|
||||
// After logging out, both users should be logged out.
|
||||
$this->drupalLogout();
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
|
||||
|
||||
// After logging back in, the second user should still be logged out.
|
||||
$this->drupalLogin($first_user);
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
|
||||
|
||||
// After logging in the second user, the first one should be logged out.
|
||||
$this->drupalLogin($second_user);
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($second_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
|
||||
|
||||
// After logging out, both should be logged out.
|
||||
$this->drupalLogout();
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
|
||||
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ use Drupal\Tests\user\Traits\UserCreationTrait as BaseUserCreationTrait;
|
||||
* \Drupal\simpletest\TestBase.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\UserCreationTrait instead.
|
||||
* \Drupal\Tests\user\Traits\UserCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
|
||||
@@ -96,7 +96,7 @@ abstract class WebTestBase extends TestBase {
|
||||
/**
|
||||
* The headers of the page currently loaded in the internal browser.
|
||||
*
|
||||
* @var Array
|
||||
* @var array
|
||||
*/
|
||||
protected $headers;
|
||||
|
||||
@@ -168,6 +168,8 @@ abstract class WebTestBase extends TestBase {
|
||||
|
||||
/**
|
||||
* The maximum number of redirects to follow when handling responses.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $maximumRedirects = 5;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user