Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -15,6 +15,7 @@ class MailCaptureTest extends BrowserTestBase {
use AssertMailTrait {
getMails as drupalGetMails;
}
/**
* Test to see if the wrapper function is executed correctly.
*/

View file

@ -1,22 +0,0 @@
<?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.');
}
}

View file

@ -8,7 +8,7 @@ use Drupal\Tests\BrowserTestBase;
* Verifies that tests in other installation profiles are found.
*
* @group simpletest
* @see SimpleTestInstallationProfileModuleTestsTestCase
* @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
*/
class OtherInstallationProfileTestsTest extends BrowserTestBase {
@ -28,8 +28,10 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
* The Standard profile contains \Drupal\standard\Tests\StandardTest, which
* should be found.
*
* @var string
*
* @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
* @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest
*/
protected $profile = 'minimal';
@ -58,7 +60,7 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
// 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');
$this->assertText('Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest');
}
}

View file

@ -1,65 +0,0 @@
<?php
namespace Drupal\Tests\simpletest\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
/**
* Tests if we can execute JavaScript in the browser.
*
* @group javascript
*/
class BrowserWithJavascriptTest extends JavascriptTestBase {
public function testJavascript() {
$this->drupalGet('<front>');
$session = $this->getSession();
$session->resizeWindow(400, 300);
$javascript = <<<JS
(function(){
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight|| g.clientHeight;
return x == 400 && y == 300;
}());
JS;
$this->assertJsCondition($javascript);
}
public function testAssertJsCondition() {
$this->drupalGet('<front>');
$session = $this->getSession();
$session->resizeWindow(500, 300);
$javascript = <<<JS
(function(){
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight|| g.clientHeight;
return x == 400 && y == 300;
}());
JS;
// We expected the following assertion to fail because the window has been
// re-sized to have a width of 500 not 400.
$this->setExpectedException(\PHPUnit_Framework_AssertionFailedError::class);
$this->assertJsCondition($javascript, 100);
}
/**
* Tests creating screenshots.
*/
public function testCreateScreenshot() {
$this->drupalGet('<front>');
$this->createScreenshot('public://screenshot.jpg');
$this->assertFileExists('public://screenshot.jpg');
}
}

View file

@ -1,46 +0,0 @@
<?php
namespace Drupal\Tests\simpletest\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
/**
* Tests Drupal settings retrieval in JavascriptTestBase tests.
*
* @group javascript
*/
class JavascriptGetDrupalSettingsTest extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['test_page_test'];
/**
* Tests retrieval of Drupal settings.
*
* @see \Drupal\FunctionalJavascriptTests\JavascriptTestBase::getDrupalSettings()
*/
public function testGetDrupalSettings() {
$this->drupalLogin($this->drupalCreateUser());
$this->drupalGet('test-page');
// Check that we can read the JS settings.
$js_settings = $this->getDrupalSettings();
$this->assertSame('azAZ09();.,\\\/-_{}', $js_settings['test-setting']);
// Dynamically change the setting using Javascript.
$script = <<<EndOfScript
(function () {
drupalSettings['test-setting'] = 'foo';
})();
EndOfScript;
$this->getSession()->evaluateScript($script);
// Check that the setting has been changed.
$js_settings = $this->getDrupalSettings();
$this->assertSame('foo', $js_settings['test-setting']);
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace Drupal\Tests\simpletest\Kernel\Cache\Context;
use Drupal\KernelTests\KernelTestBase;
use Drupal\simpletest\Cache\Context\TestDiscoveryCacheContext;
use Drupal\simpletest\TestDiscovery;
/**
* @group simpletest
*/
class TestDiscoveryCacheContextTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['simpletest'];
/**
* Tests that test context hashes are unique.
*/
public function testContext() {
// Mock test discovery.
$discovery = $this->getMockBuilder(TestDiscovery::class)
->setMethods(['getTestClasses'])
->disableOriginalConstructor()
->getMock();
// Set getTestClasses() to return different results on subsequent calls.
// This emulates changed tests in the filesystem.
$discovery->expects($this->any())
->method('getTestClasses')
->willReturnOnConsecutiveCalls(
['group1' => ['Test']],
['group2' => ['Test2']]
);
// Make our cache context object.
$cache_context = new TestDiscoveryCacheContext($discovery, $this->container->get('private_key'));
// Generate a context hash.
$context_hash = $cache_context->getContext();
// Since the context stores the hash, we have to reset it.
$hash_ref = new \ReflectionProperty($cache_context, 'hash');
$hash_ref->setAccessible(TRUE);
$hash_ref->setValue($cache_context, NULL);
// And then assert that we did not generate the same hash for different
// content.
$this->assertNotSame($context_hash, $cache_context->getContext());
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace Drupal\Tests\simpletest\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Verify deprecation of simpletest.
*
* @group simpletest
* @group legacy
*/
class SimpletestDeprecationTest extends KernelTestBase {
public static $modules = ['simpletest'];
/**
* @expectedDeprecation The simpletest_phpunit_configuration_filepath function is deprecated since version 8.4.x and will be removed in 9.0.0.
* @expectedDeprecation The simpletest_test_get_all function is deprecated in version 8.3.x and will be removed in 9.0.0. Use \Drupal::service('test_discovery')->getTestClasses($extension, $types) instead.
* @expectedDeprecation The simpletest_classloader_register function is deprecated in version 8.3.x and will be removed in 9.0.0. Use \Drupal::service('test_discovery')->registerTestNamespaces() instead.
*/
public function testDeprecatedFunctions() {
$this->assertNotEmpty(simpletest_phpunit_configuration_filepath());
$this->assertNotEmpty(simpletest_test_get_all());
simpletest_classloader_register();
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace Drupal\Tests\simpletest\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* @group simpletest
* @group legacy
*
* @coversDefaultClass \Drupal\simpletest\TestDiscovery
*/
class TestDiscoveryDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['simpletest', 'simpletest_deprecation_test'];
/**
* @expectedDeprecation The deprecated alter hook hook_simpletest_alter() is implemented in these functions: simpletest_deprecation_test_simpletest_alter. Convert your test to a PHPUnit-based one and implement test listeners. See: https://www.drupal.org/node/2939892
* @covers ::getTestClasses
*/
public function testHookSimpletestAlter() {
// The simpletest_test module implements hook_simpletest_alter(), which
// should trigger a deprecation error during getTestClasses().
$this->assertNotEmpty(
$this->container->get('test_discovery')->getTestClasses()
);
}
}

View file

@ -1,49 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\simpletest\Unit\AssertHelperTraitTest.
*/
namespace Drupal\Tests\simpletest\Unit;
use Drupal\Core\Render\Markup;
use Drupal\simpletest\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\simpletest\AssertHelperTrait
* @group simpletest
*/
class AssertHelperTraitTest extends UnitTestCase {
/**
* @covers ::castSafeStrings
* @dataProvider providerCastSafeStrings
*/
public function testCastSafeStrings($expected, $value) {
$class = new AssertHelperTestClass();
$this->assertSame($expected, $class->testMethod($value));
}
public function providerCastSafeStrings() {
$safe_string = Markup::create('test safe string');
return [
['test simple string', 'test simple string'],
[['test simple array', 'test simple array'], ['test simple array', 'test simple array']],
['test safe string', $safe_string],
[['test safe string', 'test safe string'], [$safe_string, $safe_string]],
[['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]],
];
}
}
class AssertHelperTestClass {
use AssertHelperTrait;
public function testMethod($value) {
return $this->castSafeStrings($value);
}
}

View file

@ -2,17 +2,23 @@
namespace Drupal\Tests\simpletest\Unit;
use Drupal\Core\Database\Database;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\File\FileSystemInterface;
use PHPUnit\Framework\TestCase;
/**
* Tests simpletest_run_phpunit_tests() handles PHPunit fatals correctly.
*
* We don't extend Drupal\Tests\UnitTestCase here because its $root property is
* not static and we need it to be static here.
*
* @group simpletest
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class SimpletestPhpunitRunCommandTest extends \PHPUnit_Framework_TestCase {
class SimpletestPhpunitRunCommandTest extends TestCase {
/**
* Path to the app root.
@ -81,6 +87,18 @@ class SimpletestPhpunitRunCommandTest extends \PHPUnit_Framework_TestCase {
* @dataProvider provideStatusCodes
*/
public function testSimpletestPhpUnitRunCommand($status, $label) {
// Add a default database connection in order for
// Database::getConnectionInfoAsUrl() to return valid information.
Database::addConnectionInfo('default', 'default', [
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\Core\Database\Driver\mysql',
]
);
$test_id = basename(tempnam(sys_get_temp_dir(), 'xxx'));
putenv('SimpletestPhpunitRunCommandTestWillDie=' . $status);
$ret = simpletest_run_phpunit_tests($test_id, [SimpletestPhpunitRunCommandTestWillDie::class]);

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\simpletest\Unit\TestInfoParsingTest.
*/
namespace Drupal\Tests\simpletest\Unit;
use Composer\Autoload\ClassLoader;
@ -19,7 +14,7 @@ use org\bovigo\vfs\vfsStream;
* @coversDefaultClass \Drupal\simpletest\TestDiscovery
* @group simpletest
*/
class TestInfoParsingTest extends UnitTestCase {
class TestDiscoveryTest extends UnitTestCase {
/**
* @covers ::getTestInfo
@ -35,13 +30,13 @@ class TestInfoParsingTest extends UnitTestCase {
$tests[] = [
// Expected result.
[
'name' => 'Drupal\Tests\simpletest\Unit\TestInfoParsingTest',
'name' => 'Drupal\Tests\simpletest\Unit\TestDiscoveryTest',
'group' => 'simpletest',
'description' => 'Tests \Drupal\simpletest\TestDiscovery.',
'type' => 'PHPUnit-Unit',
],
// Classname.
'Drupal\Tests\simpletest\Unit\TestInfoParsingTest',
'Drupal\Tests\simpletest\Unit\TestDiscoveryTest',
];
// A core unit test.
@ -286,6 +281,9 @@ EOF;
],
'Kernel' => [
'KernelExampleTest3.php' => str_replace(['FunctionalExampleTest', '@group example'], ['KernelExampleTest3', '@group example2'], $test_file),
'KernelExampleTestBase.php' => str_replace(['FunctionalExampleTest', '@group example'], ['KernelExampleTestBase', '@group example2'], $test_file),
'KernelExampleTrait.php' => str_replace(['FunctionalExampleTest', '@group example'], ['KernelExampleTrait', '@group example2'], $test_file),
'KernelExampleInterface.php' => str_replace(['FunctionalExampleTest', '@group example'], ['KernelExampleInterface', '@group example2'], $test_file),
],
],
],
@ -353,8 +351,7 @@ EOF;
$result = $test_discovery->getTestClasses(NULL, ['PHPUnit-Kernel']);
$this->assertCount(2, $result);
$this->assertEquals([
'example' => [
],
'example' => [],
'example2' => [
'Drupal\Tests\test_module\Kernel\KernelExampleTest3' => [
'name' => 'Drupal\Tests\test_module\Kernel\KernelExampleTest3',
@ -366,26 +363,6 @@ EOF;
], $result);
}
}
class TestTestDiscovery extends TestDiscovery {
/**
* @var \Drupal\Core\Extension\Extension[]
*/
protected $extensions = [];
public function setExtensions(array $extensions) {
$this->extensions = $extensions;
}
/**
* {@inheritdoc}
*/
protected function getExtensions() {
return $this->extensions;
}
/**
* @covers ::getPhpunitTestSuite
* @dataProvider providerTestGetPhpunitTestSuite
@ -411,6 +388,56 @@ class TestTestDiscovery extends TestDiscovery {
return $data;
}
/**
* Ensure that classes are not reflected when the docblock is empty.
*
* @covers ::getTestInfo
*/
public function testGetTestInfoEmptyDocblock() {
// If getTestInfo() performed reflection, it won't be able to find the
// class we asked it to analyze, so it will throw a ReflectionException.
// We want to make sure it didn't do that, because we already did some
// analysis and already have an empty docblock. getTestInfo() will throw
// MissingGroupException because the annotation is empty.
$this->setExpectedException(MissingGroupException::class);
TestDiscovery::getTestInfo('Drupal\Tests\simpletest\ThisTestDoesNotExistTest', '');
}
/**
* Ensure TestDiscovery::scanDirectory() ignores certain abstract file types.
*
* @covers ::scanDirectory
*/
public function testScanDirectoryNoAbstract() {
$this->setupVfsWithTestClasses();
$files = TestDiscovery::scanDirectory('Drupal\\Tests\\test_module\\Kernel\\', vfsStream::url('drupal/modules/test_module/tests/src/Kernel'));
$this->assertNotEmpty($files);
$this->assertArrayNotHasKey('Drupal\Tests\test_module\Kernel\KernelExampleTestBase', $files);
$this->assertArrayNotHasKey('Drupal\Tests\test_module\Kernel\KernelExampleTrait', $files);
$this->assertArrayNotHasKey('Drupal\Tests\test_module\Kernel\KernelExampleInterface', $files);
$this->assertArrayHasKey('Drupal\Tests\test_module\Kernel\KernelExampleTest3', $files);
}
}
class TestTestDiscovery extends TestDiscovery {
/**
* @var \Drupal\Core\Extension\Extension[]
*/
protected $extensions = [];
public function setExtensions(array $extensions) {
$this->extensions = $extensions;
}
/**
* {@inheritdoc}
*/
protected function getExtensions() {
return $this->extensions;
}
}
namespace Drupal\simpletest\Tests;