This commit is contained in:
2020-07-13 17:09:59 +02:00
parent 03559a7b76
commit 3a082e23cc
492 changed files with 4129 additions and 982 deletions
@@ -20,6 +20,7 @@ class PluginTest extends TestCase {
// Assert all values are accepted through constructor and default value is
// used for non existent but defined property.
$plugin = new PluginStub([
1 => 'oak',
'foo' => 'bar',
'biz' => [
'baz' => 'boom',
@@ -32,6 +33,7 @@ class PluginTest extends TestCase {
// This property wasn't in our definition but is defined as a property on
// our plugin class.
'defaultProperty' => 'testvalue',
1 => 'oak',
'foo' => 'bar',
'biz' => [
'baz' => 'boom',
@@ -103,6 +103,7 @@ class ScaffoldUpgradeTest extends TestCase {
* Path to location to create git repository.
* @param string $version
* Version to tag the repository with.
*
* @return string
* Path to temporary git repository.
*/
@@ -20,6 +20,19 @@ class ComposerIntegrationTest extends UnitTestCase {
$content_hash = self::getContentHash(file_get_contents($this->root . '/composer.json'));
$lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
$this->assertSame($content_hash, $lock['content-hash']);
// @see \Composer\Repository\PathRepository::initialize()
$core_lock_file_hash = '';
$options = [];
foreach ($lock['packages'] as $package) {
if ($package['name'] === 'drupal/core') {
$core_lock_file_hash = $package['dist']['reference'];
$options = $package['transport-options'] ?? [];
break;
}
}
$core_content_hash = sha1(file_get_contents($this->root . '/core/composer.json') . serialize($options));
$this->assertSame($core_content_hash, $core_lock_file_hash);
}
/**
@@ -113,11 +113,20 @@ class BatchBuilderTest extends UnitTestCase {
* @covers ::setFile
*/
public function testSetFile() {
$batch = (new BatchBuilder())
->setFile('filename.php')
->toArray();
$filename = dirname(__DIR__, 6) . '/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc';
$this->assertIsNotCallable('_batch_test_callback_1');
$this->assertIsNotCallable('_batch_test_finished_1');
$this->assertEquals('filename.php', $batch['file']);
$batch = (new BatchBuilder())
->setFile($filename)
->setFinishCallback('_batch_test_finished_1')
->addOperation('_batch_test_callback_1', [])
->toArray();
$this->assertEquals($filename, $batch['file']);
$this->assertEquals([['_batch_test_callback_1', []]], $batch['operations']);
$this->assertEquals('_batch_test_finished_1', $batch['finished']);
$this->assertIsCallable('_batch_test_callback_1');
$this->assertIsCallable('_batch_test_finished_1');
}
/**
@@ -97,6 +97,7 @@ class BackendCompilerPassTest extends UnitTestCase {
* bag so the setParameter() call effects the parent container as well.
*
* @param $service
*
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
*/
protected function getSqliteContainer($service) {
@@ -115,6 +116,7 @@ class BackendCompilerPassTest extends UnitTestCase {
* bag so the setParameter() call effects the parent container as well.
*
* @param $service
*
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
*/
protected function getMysqlContainer($service) {
@@ -112,6 +112,7 @@ class EntityAccessCheckTest extends UnitTestCase {
*
* @param object $object
* Any object, including prophesized mocks based on interfaces.
*
* @return \Drupal\Core\Routing\RouteMatchInterface
* A prophesized RouteMatchInterface.
*/
@@ -25,7 +25,7 @@ class RssResponseRelativeUrlFilterTest extends UnitTestCase {
<title>Drupal.org</title>
<link>https://www.drupal.org</link>
<description>Come for the software, stay for the community
D rupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
Drupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
<language>en</language>
<item>
<title>Drupal 8 turns one!</title>
@@ -44,7 +44,7 @@ RSS;
<title>Drupal.org</title>
<link>https://www.drupal.org</link>
<description>Come for the software, stay for the community
D rupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
Drupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
<language>en</language>
<item>
<title>Drupal 8 turns one!</title>
@@ -66,7 +66,7 @@ RSS;
<title>Drupal.org</title>
<link>https://www.drupal.org</link>
<description>Come for the software, stay for the community
D rupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
Drupal is an open source content management platform powering millions of websites and applications. Its built, used, and supported by an active and diverse community of people around the world.</description>
<language>en</language>
<item>
<title>Drupal 8 turns one!</title>
@@ -832,12 +832,30 @@ class FormBuilderTest extends FormTestBase {
$expected_form = $form_id();
$form_arg = $this->getMockForm($form_id, $expected_form);
// Set up some request data so we can be sure it is removed when a token is
// invalid.
$this->request->request->set('foo', 'bar');
$_POST['foo'] = 'bar';
$form_state = new FormState();
$input['form_id'] = $form_id;
$input['form_token'] = $form_token;
$input['test'] = 'example-value';
$form_state->setUserInput($input);
$this->simulateFormSubmission($form_id, $form_arg, $form_state, FALSE);
$form = $this->simulateFormSubmission($form_id, $form_arg, $form_state, FALSE);
$this->assertSame($expected, $form_state->hasInvalidToken());
if ($expected) {
$this->assertEmpty($form['test']['#value']);
$this->assertEmpty($form_state->getValue('test'));
$this->assertEmpty($_POST);
$this->assertEmpty(iterator_to_array($this->request->request->getIterator()));
}
else {
$this->assertEquals('example-value', $form['test']['#value']);
$this->assertEquals('example-value', $form_state->getValue('test'));
$this->assertEquals('bar', $_POST['foo']);
$this->assertEquals('bar', $this->request->request->get('foo'));
}
}
public function providerTestInvalidToken() {
@@ -173,7 +173,7 @@ abstract class FormTestBase extends UnitTestCase {
->getMock();
$this->account = $this->createMock('Drupal\Core\Session\AccountInterface');
$this->themeManager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
$this->request = new Request();
$this->request = Request::createFromGlobals();
$this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->requestStack = new RequestStack();
$this->requestStack->push($this->request);
@@ -131,7 +131,7 @@ class FormValidatorTest extends UnitTestCase {
->getMock();
$form_state->expects($this->once())
->method('setErrorByName')
->with('form_token', 'The form has become outdated. Copy any unsaved work in the form below and then <a href="/test/example?foo=bar">reload this page</a>.');
->with('form_token', 'The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page.');
$form_state->setValue('form_token', 'some_random_token');
$form_validator->validateForm('test_form_id', $form, $form_state);
$this->assertTrue($form_state->isValidationComplete());
@@ -13,6 +13,7 @@ class TestDerivativeDiscoveryWithObject implements DeriverInterface {
* {@inheritdoc}
* @param string $derivative_id
* @param array $base_plugin_definition
*
* @return array
*/
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
@@ -23,6 +24,7 @@ class TestDerivativeDiscoveryWithObject implements DeriverInterface {
/**
* {@inheritdoc}
* @param array $base_plugin_definition
*
* @return array
*/
public function getDerivativeDefinitions($base_plugin_definition) {
@@ -22,6 +22,7 @@ abstract class RouteMatchTestBase extends UnitTestCase {
* Parameters array
* @param $raw_parameters
* Raw parameters array
*
* @return \Drupal\Core\Routing\RouteMatchInterface
*/
abstract protected function getRouteMatch($name, Route $route, array $parameters, array $raw_parameters);
@@ -99,6 +99,7 @@ class UnroutedUrlAssemblerTest extends UnitTestCase {
'override-query' => ['https://example.com/test?foo=1#bar', ['query' => ['foo' => 2]], 'https://example.com/test?foo=2#bar'],
'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?foo=1&bar=2#bar'],
'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?foo=1&bar%5Bbaz%5D=foo#bar'],
'override-deep-query-merge-int-ket' => ['https://example.com/test?120=1', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?120=1&bar%5Bbaz%5D=foo'],
'override-fragment' => ['https://example.com/test?foo=1#bar', ['fragment' => 'baz'], 'https://example.com/test?foo=1#baz'],
['//www.drupal.org', [], '//www.drupal.org'],
];
@@ -30,6 +30,7 @@ trait EntityViewTrait {
* the current content language.
* @param bool $reset
* (optional) Whether to clear the cache for this entity.
*
* @return array
*
* @see \Drupal\Core\Render\RendererInterface::render()