Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* This test will check SimpleTest's treatment of hook_install during setUp.
|
||||
* Image module is used for test.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class FolderTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['image'];
|
||||
|
||||
public function testFolderSetup() {
|
||||
$directory = file_default_scheme() . '://styles';
|
||||
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Core\Test\AssertMailTrait;
|
||||
|
||||
/**
|
||||
* Tests the SimpleTest email capturing logic, the assertMail assertion and the
|
||||
* drupalGetMails function.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class MailCaptureTest extends BrowserTestBase {
|
||||
use AssertMailTrait {
|
||||
getMails as drupalGetMails;
|
||||
}
|
||||
/**
|
||||
* Test to see if the wrapper function is executed correctly.
|
||||
*/
|
||||
public function testMailSend() {
|
||||
// Create an email.
|
||||
$subject = $this->randomString(64);
|
||||
$body = $this->randomString(128);
|
||||
$message = [
|
||||
'id' => 'drupal_mail_test',
|
||||
'headers' => ['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(['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.', ['@field' => $field]), 'Email');
|
||||
}
|
||||
|
||||
// Send additional emails so more than one email is captured.
|
||||
for ($index = 0; $index < 5; $index++) {
|
||||
$message = [
|
||||
'id' => 'drupal_mail_test_' . $index,
|
||||
'headers' => ['Content-type' => 'text/html'],
|
||||
'subject' => $this->randomString(64),
|
||||
'to' => $this->randomMachineName(32) . '@example.com',
|
||||
'body' => $this->randomString(512),
|
||||
];
|
||||
\Drupal::service('plugin.manager.mail')->getInstance(['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(['id' => 'drupal_mail_test']);
|
||||
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id.', 'Email');
|
||||
$captured_emails = $this->drupalGetMails(['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(['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(['module' => 'drupal_mail_test', 'key' => $index])->mail($message);
|
||||
$captured_emails = $this->drupalGetMails(['id' => 'drupal_mail_test_4']);
|
||||
$this->assertEqual(count($captured_emails), 2, 'All emails with the same id are returned when filtering by id.', 'Email');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* This test should not load since it requires a module that is not found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @dependencies simpletest_missing_module
|
||||
*/
|
||||
class MissingDependentModuleUnitTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Ensure that this test will not be loaded despite its dependency.
|
||||
*/
|
||||
public function testFail() {
|
||||
$this->fail('Running test with missing required module.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Verifies that tests in other installation profiles are found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @see SimpleTestInstallationProfileModuleTestsTestCase
|
||||
*/
|
||||
class OtherInstallationProfileTestsTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['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(['administer unit tests']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that tests located in another installation profile appear.
|
||||
*/
|
||||
public 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');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests User related helper methods of WebTestBase.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class UserHelpersTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Tests WebTestBase::drupalUserIsLoggedIn().
|
||||
*/
|
||||
public 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));
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ class JavascriptGetDrupalSettingsTest extends JavascriptTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['test_page_test'];
|
||||
protected static $modules = ['test_page_test'];
|
||||
|
||||
/**
|
||||
* Tests retrieval of Drupal settings.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\simpletest\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ class MigrateSimpletestConfigsTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('simpletest');
|
||||
public static $modules = ['simpletest'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
32
web/core/modules/simpletest/tests/src/Traits/TestTrait.php
Normal file
32
web/core/modules/simpletest/tests/src/Traits/TestTrait.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Traits;
|
||||
|
||||
/**
|
||||
* A nothing trait, but declared in the Drupal\Tests namespace.
|
||||
*
|
||||
* We use this trait to test autoloading of traits outside of the normal test
|
||||
* suite namespaces.
|
||||
*
|
||||
* @see \Drupal\Tests\simpletest\Unit\TraitAccessTest
|
||||
*/
|
||||
trait TestTrait {
|
||||
|
||||
/**
|
||||
* Random string for a not very interesting trait.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stuff = 'stuff';
|
||||
|
||||
/**
|
||||
* Return a test string to a trait user.
|
||||
*
|
||||
* @return string
|
||||
* Just a random sort of string.
|
||||
*/
|
||||
protected function getStuff() {
|
||||
return $this->stuff;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,13 +25,13 @@ class TestBaseTest extends UnitTestCase {
|
|||
*/
|
||||
public function getTestBaseForAssertionTests($test_id) {
|
||||
$mock_test_base = $this->getMockBuilder('Drupal\simpletest\TestBase')
|
||||
->setConstructorArgs(array($test_id))
|
||||
->setMethods(array('storeAssertion'))
|
||||
->getMockForAbstractClass();
|
||||
->setConstructorArgs([$test_id])
|
||||
->setMethods(['storeAssertion'])
|
||||
->getMockForAbstractClass();
|
||||
// Override storeAssertion() so we don't need a database.
|
||||
$mock_test_base->expects($this->any())
|
||||
->method('storeAssertion')
|
||||
->will($this->returnValue(NULL));
|
||||
->method('storeAssertion')
|
||||
->will($this->returnValue(NULL));
|
||||
return $mock_test_base;
|
||||
}
|
||||
|
||||
|
@ -62,16 +62,16 @@ class TestBaseTest extends UnitTestCase {
|
|||
* - The string to validate.
|
||||
*/
|
||||
public function providerRandomStringValidate() {
|
||||
return array(
|
||||
array(FALSE, ' curry paste'),
|
||||
array(FALSE, 'curry paste '),
|
||||
array(FALSE, 'curry paste'),
|
||||
array(FALSE, 'curry paste'),
|
||||
array(TRUE, 'curry paste'),
|
||||
array(TRUE, 'thai green curry paste'),
|
||||
array(TRUE, '@startswithat'),
|
||||
array(TRUE, 'contains@at'),
|
||||
);
|
||||
return [
|
||||
[FALSE, ' curry paste'],
|
||||
[FALSE, 'curry paste '],
|
||||
[FALSE, 'curry paste'],
|
||||
[FALSE, 'curry paste'],
|
||||
[TRUE, 'curry paste'],
|
||||
[TRUE, 'thai green curry paste'],
|
||||
[TRUE, '@startswithat'],
|
||||
[TRUE, 'contains@at'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertInternalType(
|
||||
'array',
|
||||
$this->invokeProtectedMethod($test_base, 'checkRequirements', array())
|
||||
$this->invokeProtectedMethod($test_base, 'checkRequirements', [])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -153,14 +153,14 @@ class TestBaseTest extends UnitTestCase {
|
|||
* - Caller, passed to assert().
|
||||
*/
|
||||
public function providerAssert() {
|
||||
return array(
|
||||
array(TRUE, 'pass', TRUE, 'Yay pass', 'test', array()),
|
||||
array(FALSE, 'fail', FALSE, 'Boo fail', 'test', array()),
|
||||
array(TRUE, 'pass', 'pass', 'Yay pass', 'test', array()),
|
||||
array(FALSE, 'fail', 'fail', 'Boo fail', 'test', array()),
|
||||
array(FALSE, 'exception', 'exception', 'Boo fail', 'test', array()),
|
||||
array(FALSE, 'debug', 'debug', 'Boo fail', 'test', array()),
|
||||
);
|
||||
return [
|
||||
[TRUE, 'pass', TRUE, 'Yay pass', 'test', []],
|
||||
[FALSE, 'fail', FALSE, 'Boo fail', 'test', []],
|
||||
[TRUE, 'pass', 'pass', 'Yay pass', 'test', []],
|
||||
[FALSE, 'fail', 'fail', 'Boo fail', 'test', []],
|
||||
[FALSE, 'exception', 'exception', 'Boo fail', 'test', []],
|
||||
[FALSE, 'debug', 'debug', 'Boo fail', 'test', []],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +185,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$this->assertEquals(
|
||||
$expected,
|
||||
$ref_assert->invokeArgs($test_base,
|
||||
array($status, $message, $group, $caller)
|
||||
[$status, $message, $group, $caller]
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -211,10 +211,10 @@ class TestBaseTest extends UnitTestCase {
|
|||
* Data provider for assertTrue().
|
||||
*/
|
||||
public function providerAssertTrue() {
|
||||
return array(
|
||||
array(TRUE, TRUE),
|
||||
array(FALSE, FALSE),
|
||||
);
|
||||
return [
|
||||
[TRUE, TRUE],
|
||||
[FALSE, FALSE],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,7 +225,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->invokeProtectedMethod($test_base, 'assertTrue', array($value))
|
||||
$this->invokeProtectedMethod($test_base, 'assertTrue', [$value])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
(!$expected),
|
||||
$this->invokeProtectedMethod($test_base, 'assertFalse', array($value))
|
||||
$this->invokeProtectedMethod($test_base, 'assertFalse', [$value])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -245,10 +245,10 @@ class TestBaseTest extends UnitTestCase {
|
|||
* Data provider for assertNull().
|
||||
*/
|
||||
public function providerAssertNull() {
|
||||
return array(
|
||||
array(TRUE, NULL),
|
||||
array(FALSE, ''),
|
||||
);
|
||||
return [
|
||||
[TRUE, NULL],
|
||||
[FALSE, ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,7 +259,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->invokeProtectedMethod($test_base, 'assertNull', array($value))
|
||||
$this->invokeProtectedMethod($test_base, 'assertNull', [$value])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
(!$expected),
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotNull', array($value))
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotNull', [$value])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
$expected_identical,
|
||||
$this->invokeProtectedMethod($test_base, 'assertIdentical', array($first, $second))
|
||||
$this->invokeProtectedMethod($test_base, 'assertIdentical', [$first, $second])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
(!$expected_identical),
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotIdentical', array($first, $second))
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotIdentical', [$first, $second])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
$expected_equal,
|
||||
$this->invokeProtectedMethod($test_base, 'assertEqual', array($first, $second))
|
||||
$this->invokeProtectedMethod($test_base, 'assertEqual', [$first, $second])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
(!$expected_equal),
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotEqual', array($first, $second))
|
||||
$this->invokeProtectedMethod($test_base, 'assertNotEqual', [$first, $second])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -374,11 +374,11 @@ class TestBaseTest extends UnitTestCase {
|
|||
$obj2 = $obj1;
|
||||
$obj3 = clone $obj1;
|
||||
$obj4 = new \stdClass();
|
||||
return array(
|
||||
array(TRUE, $obj1, $obj2),
|
||||
array(TRUE, $obj1, $obj3),
|
||||
array(FALSE, $obj1, $obj4),
|
||||
);
|
||||
return [
|
||||
[TRUE, $obj1, $obj2],
|
||||
[TRUE, $obj1, $obj3],
|
||||
[FALSE, $obj1, $obj4],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,7 +389,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->invokeProtectedMethod($test_base, 'assertIdenticalObject', array($first, $second))
|
||||
$this->invokeProtectedMethod($test_base, 'assertIdenticalObject', [$first, $second])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
TRUE,
|
||||
$this->invokeProtectedMethod($test_base, 'pass', array())
|
||||
$this->invokeProtectedMethod($test_base, 'pass', [])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertEquals(
|
||||
FALSE,
|
||||
$this->invokeProtectedMethod($test_base, 'fail', array())
|
||||
$this->invokeProtectedMethod($test_base, 'fail', [])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -423,10 +423,10 @@ class TestBaseTest extends UnitTestCase {
|
|||
* - Group for use in assert().
|
||||
*/
|
||||
public function providerError() {
|
||||
return array(
|
||||
array('debug', 'User notice'),
|
||||
array('exception', 'Not User notice'),
|
||||
);
|
||||
return [
|
||||
['debug', 'User notice'],
|
||||
['exception', 'Not User notice'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -436,7 +436,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
public function testError($status, $group) {
|
||||
// Mock up a TestBase object.
|
||||
$mock_test_base = $this->getMockBuilder('Drupal\simpletest\TestBase')
|
||||
->setMethods(array('assert'))
|
||||
->setMethods(['assert'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
// Set expectations for assert().
|
||||
|
@ -451,7 +451,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
// Invoke error().
|
||||
$this->assertEquals(
|
||||
"$status:$group",
|
||||
$this->invokeProtectedMethod($mock_test_base, 'error', array('msg', $group))
|
||||
$this->invokeProtectedMethod($mock_test_base, 'error', ['msg', $group])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ class TestBaseTest extends UnitTestCase {
|
|||
$test_base = $this->getTestBaseForAssertionTests('test_id');
|
||||
$this->assertInstanceOf(
|
||||
'Drupal\Component\Utility\Random',
|
||||
$this->invokeProtectedMethod($test_base, 'getRandomGenerator', array())
|
||||
$this->invokeProtectedMethod($test_base, 'getRandomGenerator', [])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Drupal\Tests\simpletest\Unit;
|
|||
use Composer\Autoload\ClassLoader;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\simpletest\Exception\MissingGroupException;
|
||||
use Drupal\simpletest\TestDiscovery;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
@ -235,8 +236,6 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* @covers ::getTestInfo
|
||||
* @expectedException \Drupal\simpletest\Exception\MissingGroupException
|
||||
* @expectedExceptionMessage Missing @group annotation in Drupal\KernelTests\field\BulkDeleteTest
|
||||
*/
|
||||
public function testTestInfoParserMissingGroup() {
|
||||
$classname = 'Drupal\KernelTests\field\BulkDeleteTest';
|
||||
|
@ -245,6 +244,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
* Bulk delete storages and fields, and clean up afterwards.
|
||||
*/
|
||||
EOT;
|
||||
$this->setExpectedException(MissingGroupException::class, 'Missing @group annotation in Drupal\KernelTests\field\BulkDeleteTest');
|
||||
TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\simpletest\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Tests\simpletest\Traits\TestTrait;
|
||||
|
||||
/**
|
||||
* Test whether traits are autoloaded during PHPUnit discovery time.
|
||||
*
|
||||
* @group simpletest
|
||||
*/
|
||||
class TraitAccessTest extends UnitTestCase {
|
||||
|
||||
use TestTrait;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testSimpleStuff() {
|
||||
$stuff = $this->getStuff();
|
||||
$this->assertSame($stuff, 'stuff', "Same old stuff");
|
||||
}
|
||||
|
||||
}
|
|
@ -18,12 +18,12 @@ class WebTestBaseTest extends UnitTestCase {
|
|||
* An array of values passed to the test method.
|
||||
*/
|
||||
public function providerAssertFieldByName() {
|
||||
$data = array();
|
||||
$data[] = array('select_2nd_selected', 'test', '1', FALSE);
|
||||
$data[] = array('select_2nd_selected', 'test', '2', TRUE);
|
||||
$data[] = array('select_none_selected', 'test', '', FALSE);
|
||||
$data[] = array('select_none_selected', 'test', '1', TRUE);
|
||||
$data[] = array('select_none_selected', 'test', NULL, TRUE);
|
||||
$data = [];
|
||||
$data[] = ['select_2nd_selected', 'test', '1', FALSE];
|
||||
$data[] = ['select_2nd_selected', 'test', '2', TRUE];
|
||||
$data[] = ['select_none_selected', 'test', '', FALSE];
|
||||
$data[] = ['select_none_selected', 'test', '1', TRUE];
|
||||
$data[] = ['select_none_selected', 'test', NULL, TRUE];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class WebTestBaseTest extends UnitTestCase {
|
|||
|
||||
$web_test = $this->getMockBuilder('Drupal\simpletest\WebTestBase')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getRawContent', 'assertTrue', 'pass'))
|
||||
->setMethods(['getRawContent', 'assertTrue', 'pass'])
|
||||
->getMock();
|
||||
|
||||
$web_test->expects($this->any())
|
||||
|
@ -65,7 +65,7 @@ class WebTestBaseTest extends UnitTestCase {
|
|||
|
||||
$test_method = new \ReflectionMethod('Drupal\simpletest\WebTestBase', 'assertFieldByName');
|
||||
$test_method->setAccessible(TRUE);
|
||||
$test_method->invokeArgs($web_test, array($name, $value, 'message'));
|
||||
$test_method->invokeArgs($web_test, [$name, $value, 'message']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,32 +87,32 @@ class WebTestBaseTest extends UnitTestCase {
|
|||
* to mock no link found on the page.
|
||||
*/
|
||||
public function providerTestClickLink() {
|
||||
return array(
|
||||
return [
|
||||
// Test for a non-existent label.
|
||||
array(
|
||||
[
|
||||
FALSE,
|
||||
'does_not_exist',
|
||||
0,
|
||||
array(),
|
||||
),
|
||||
[],
|
||||
],
|
||||
// Test for an existing label.
|
||||
array(
|
||||
[
|
||||
'This Text Returned By drupalGet()',
|
||||
'exists',
|
||||
0,
|
||||
array(0 => array('href' => 'this_is_a_url')),
|
||||
),
|
||||
[0 => ['href' => 'this_is_a_url']],
|
||||
],
|
||||
// Test for an existing label that isn't the first one.
|
||||
array(
|
||||
[
|
||||
'This Text Returned By drupalGet()',
|
||||
'exists',
|
||||
1,
|
||||
array(
|
||||
0 => array('href' => 'this_is_a_url'),
|
||||
1 => array('href' => 'this_is_another_url'),
|
||||
),
|
||||
),
|
||||
);
|
||||
[
|
||||
0 => ['href' => 'this_is_a_url'],
|
||||
1 => ['href' => 'this_is_another_url'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,14 +134,14 @@ class WebTestBaseTest extends UnitTestCase {
|
|||
// Mock a WebTestBase object and some of its methods.
|
||||
$web_test = $this->getMockBuilder('Drupal\simpletest\WebTestBase')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array(
|
||||
->setMethods([
|
||||
'pass',
|
||||
'fail',
|
||||
'getUrl',
|
||||
'xpath',
|
||||
'drupalGet',
|
||||
'getAbsoluteUrl',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
// Mocked getUrl() is only used for reporting so we just return a string.
|
||||
|
|
Reference in a new issue