update
This commit is contained in:
@@ -46,7 +46,9 @@ class DeleteMultipleFormTest extends BrowserTestBase {
|
||||
'id' => 'default',
|
||||
'label' => 'Default',
|
||||
])->save();
|
||||
$this->account = $this->drupalCreateUser(['administer entity_test content']);
|
||||
$this->account = $this->drupalCreateUser([
|
||||
'administer entity_test content',
|
||||
]);
|
||||
$this->drupalLogin($this->account);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -128,6 +128,7 @@ class DistributionProfileTranslationQueryTest extends InstallerTestBase {
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
|
||||
@@ -119,6 +119,7 @@ class DistributionProfileTranslationTest extends InstallerTestBase {
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ class InstallerTranslationMultipleLanguageTest extends InstallerTestBase {
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
|
||||
@@ -72,6 +72,7 @@ class InstallerTranslationQueryTest extends InstallerTestBase {
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
|
||||
@@ -134,6 +134,7 @@ class InstallerTranslationTest extends InstallerTestBase {
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,11 @@ class CaseInsensitivePathTest extends BrowserTestBase {
|
||||
$this->assertSession()->pageTextMatches('/Log in/');
|
||||
|
||||
// Tests paths defined by routes from the Views module.
|
||||
$admin = $this->drupalCreateUser(['access administration pages', 'administer nodes', 'access content overview']);
|
||||
$admin = $this->drupalCreateUser([
|
||||
'access administration pages',
|
||||
'administer nodes',
|
||||
'access content overview',
|
||||
]);
|
||||
$this->drupalLogin($admin);
|
||||
|
||||
$this->drupalGet('admin/content');
|
||||
|
||||
+5
-1
@@ -39,7 +39,11 @@ class RouteCachingNonPathLanguageNegotiationTest extends BrowserTestBase {
|
||||
parent::setUp();
|
||||
|
||||
// Create and log in user.
|
||||
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages', 'access administration pages']);
|
||||
$this->adminUser = $this->drupalCreateUser([
|
||||
'administer blocks',
|
||||
'administer languages',
|
||||
'access administration pages',
|
||||
]);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Add language.
|
||||
|
||||
@@ -31,12 +31,14 @@ class EndOfTransactionQueriesTest extends KernelTestBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// This can only be checked after installing Drupal as it requires functions
|
||||
// from bootstrap.inc.
|
||||
if (!class_exists($this->getDatabaseConnectionInfo()['default']['namespace'] . '\Connection')) {
|
||||
$this->markTestSkipped(sprintf('No logging override exists for the %s database driver. Create it, subclass this test class and override ::getDatabaseConnectionInfo().', $this->getDatabaseConnectionInfo()['default']['driver']));
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', 'sequences');
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('user');
|
||||
|
||||
@@ -98,11 +98,11 @@ class DirectoryTest extends FileTestBase {
|
||||
|
||||
// Make directory read only.
|
||||
@$file_system->chmod($directory, 0444);
|
||||
$this->assertFalse($file_system->prepareDirectory($directory, 0), 'Error reported for a non-writeable directory.', 'File');
|
||||
$this->assertFalse($file_system->prepareDirectory($directory, 0), 'Error reported for a non-writable directory.', 'File');
|
||||
|
||||
// Test directory permission modification.
|
||||
$this->setSetting('file_chmod_directory', 0777);
|
||||
$this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::MODIFY_PERMISSIONS), 'No error reported when making directory writeable.', 'File');
|
||||
$this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::MODIFY_PERMISSIONS), 'No error reported when making directory writable.', 'File');
|
||||
}
|
||||
|
||||
// Test that the directory has the correct permissions.
|
||||
|
||||
@@ -153,6 +153,7 @@ abstract class FileTestBase extends KernelTestBase {
|
||||
* @param $path
|
||||
* Optional string with a directory path. If none is provided, a random
|
||||
* name in the site's files directory will be used.
|
||||
*
|
||||
* @return
|
||||
* The path to the directory.
|
||||
*/
|
||||
@@ -178,6 +179,7 @@ abstract class FileTestBase extends KernelTestBase {
|
||||
* @param $scheme
|
||||
* Optional string indicating the stream scheme to use. Drupal core includes
|
||||
* public, private, and temporary. The public wrapper is the default.
|
||||
*
|
||||
* @return
|
||||
* File URI.
|
||||
*/
|
||||
|
||||
@@ -66,16 +66,16 @@ class NameMungingTest extends FileTestBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* White listed extensions are ignored by file_munge_filename().
|
||||
* Tests that allowed extensions are ignored by file_munge_filename().
|
||||
*/
|
||||
public function testMungeIgnoreWhitelisted() {
|
||||
// Declare our extension as whitelisted. The declared extensions should
|
||||
// be case insensitive so test using one with a different case.
|
||||
public function testMungeIgnoreAllowedExtensions() {
|
||||
// Declare that our extension is allowed. The declared extensions should be
|
||||
// case insensitive, so test using one with a different case.
|
||||
$munged_name = file_munge_filename($this->nameWithUcExt, $this->badExtension);
|
||||
$this->assertSame($munged_name, $this->nameWithUcExt, new FormattableMarkup('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', ['%munged' => $munged_name, '%original' => $this->nameWithUcExt]));
|
||||
$this->assertSame($munged_name, $this->nameWithUcExt);
|
||||
// The allowed extensions should also be normalized.
|
||||
$munged_name = file_munge_filename($this->name, strtoupper($this->badExtension));
|
||||
$this->assertSame($munged_name, $this->name, new FormattableMarkup('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', ['%munged' => $munged_name, '%original' => $this->name]));
|
||||
$this->assertSame($munged_name, $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-9
@@ -44,20 +44,20 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||
// Verify that an item can be stored with setWithExpire().
|
||||
// Use a random expiration in each test.
|
||||
$stores[0]->setWithExpire('foo', $this->objects[0], rand(500, 100000));
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[0], $stores[0]->get('foo'));
|
||||
// Verify that the other collection is not affected.
|
||||
$this->assertNull($stores[1]->get('foo'));
|
||||
|
||||
// Verify that an item can be updated with setWithExpire().
|
||||
$stores[0]->setWithExpire('foo', $this->objects[1], rand(500, 100000));
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||
// Verify that the other collection is still not affected.
|
||||
$this->assertNull($stores[1]->get('foo'));
|
||||
|
||||
// Verify that the expirable data key is unique.
|
||||
$stores[1]->setWithExpire('foo', $this->objects[2], rand(500, 100000));
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||
|
||||
// Verify that multiple items can be stored with setMultipleWithExpire().
|
||||
$values = [
|
||||
@@ -67,11 +67,11 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||
$stores[0]->setMultipleWithExpire($values, rand(500, 100000));
|
||||
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
||||
foreach ($values as $j => $value) {
|
||||
$this->assertIdenticalObject($value, $result[$j]);
|
||||
$this->assertEquals($value, $result[$j]);
|
||||
}
|
||||
|
||||
// Verify that the other collection was not affected.
|
||||
$this->assertIdenticalObject($stores[1]->get('foo'), $this->objects[2]);
|
||||
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||
$this->assertNull($stores[1]->get('bar'));
|
||||
|
||||
// Verify that all items in a collection can be retrieved.
|
||||
@@ -93,7 +93,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||
$this->assertNull($stores[0]->get('bar'));
|
||||
$this->assertEmpty($stores[0]->getMultiple(['foo', 'bar']));
|
||||
// Verify that the item in the other collection still exists.
|
||||
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
|
||||
$this->assertEquals($this->objects[5], $stores[1]->get('foo'));
|
||||
|
||||
// Test that setWithExpireIfNotExists() succeeds only the first time.
|
||||
$key = $this->randomMachineName();
|
||||
@@ -101,7 +101,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||
// setWithExpireIfNotExists() should be TRUE the first time (when $i is
|
||||
// 0) and FALSE the second time (when $i is 1).
|
||||
$this->assertEqual(!$i, $stores[0]->setWithExpireIfNotExists($key, $this->objects[$i], rand(500, 100000)));
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||
// Verify that the other collection is not affected.
|
||||
$this->assertNull($stores[1]->get($key));
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||
$stores[0]->delete($key);
|
||||
$stores[0]->setWithExpireIfNotExists($key, $this->objects[1], rand(500, 100000));
|
||||
// This time it should succeed.
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||
// Verify that the other collection is still not affected.
|
||||
$this->assertNull($stores[1]->get($key));
|
||||
|
||||
|
||||
@@ -54,21 +54,21 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
// Verify that an item can be stored.
|
||||
$stores[0]->set('foo', $this->objects[0]);
|
||||
$this->assertTrue($stores[0]->has('foo'));
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[0], $stores[0]->get('foo'));
|
||||
// Verify that the other collection is not affected.
|
||||
$this->assertFalse($stores[1]->has('foo'));
|
||||
$this->assertNull($stores[1]->get('foo'));
|
||||
|
||||
// Verify that an item can be updated.
|
||||
$stores[0]->set('foo', $this->objects[1]);
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||
// Verify that the other collection is still not affected.
|
||||
$this->assertNull($stores[1]->get('foo'));
|
||||
|
||||
// Verify that a collection/name pair is unique.
|
||||
$stores[1]->set('foo', $this->objects[2]);
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||
|
||||
// Verify that an item can be deleted.
|
||||
$stores[0]->delete('foo');
|
||||
@@ -77,7 +77,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
|
||||
// Verify that the other collection is not affected.
|
||||
$this->assertTrue($stores[1]->has('foo'));
|
||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
||||
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||
$stores[1]->delete('foo');
|
||||
$this->assertNull($stores[1]->get('foo'));
|
||||
|
||||
@@ -91,7 +91,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
// Verify that multiple items can be retrieved.
|
||||
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
||||
foreach ($values as $j => $value) {
|
||||
$this->assertIdenticalObject($value, $result[$j]);
|
||||
$this->assertEquals($value, $result[$j]);
|
||||
}
|
||||
|
||||
// Verify that the other collection was not affected.
|
||||
@@ -119,7 +119,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
// Verify that deleting no items does not cause an error.
|
||||
$stores[0]->deleteMultiple([]);
|
||||
// Verify that the item in the other collection still exists.
|
||||
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
|
||||
$this->assertEquals($this->objects[5], $stores[1]->get('foo'));
|
||||
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
// setIfNotExists() should be TRUE the first time (when $i is 0) and
|
||||
// FALSE the second time (when $i is 1).
|
||||
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||
// Verify that the other collection is not affected.
|
||||
$this->assertNull($stores[1]->get($key));
|
||||
}
|
||||
@@ -172,7 +172,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||
$stores[0]->delete($key);
|
||||
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
||||
// This time it should succeed.
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||
// Verify that the other collection is still not affected.
|
||||
$this->assertNull($stores[1]->get($key));
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ class ExceptionHandlingTest extends KernelTestBase {
|
||||
* Sets the given path to use as the 404 page and triggers a 404.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return \Drupal\Core\Render\HtmlResponse
|
||||
*
|
||||
* @see \Drupal\system\Tests\Routing\ExceptionHandlingTest::testExceptionResponseGeneratedForOriginalRequest()
|
||||
|
||||
@@ -87,24 +87,24 @@ class TempStoreDatabaseTest extends KernelTestBase {
|
||||
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
||||
$metadata = $stores[0]->getMetadata($key);
|
||||
$this->assertEqual($users[0], $metadata->getOwnerId());
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||
// Another user should get the same result.
|
||||
$metadata = $stores[1]->getMetadata($key);
|
||||
$this->assertEqual($users[0], $metadata->getOwnerId());
|
||||
$this->assertIdenticalObject($this->objects[0], $stores[1]->get($key));
|
||||
$this->assertEquals($this->objects[0], $stores[1]->get($key));
|
||||
}
|
||||
|
||||
// Remove the item and try to set it again.
|
||||
$stores[0]->delete($key);
|
||||
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
||||
// This time it should succeed.
|
||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||
|
||||
// This user can update the object.
|
||||
$stores[0]->set($key, $this->objects[2]);
|
||||
$this->assertIdenticalObject($this->objects[2], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[2], $stores[0]->get($key));
|
||||
// The object is the same when another user loads it.
|
||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get($key));
|
||||
$this->assertEquals($this->objects[2], $stores[1]->get($key));
|
||||
|
||||
// This user should be allowed to get, update, delete.
|
||||
$this->assertInstanceOf(\stdClass::class, $stores[0]->getIfOwner($key));
|
||||
@@ -113,8 +113,8 @@ class TempStoreDatabaseTest extends KernelTestBase {
|
||||
|
||||
// Another user can update the object and become the owner.
|
||||
$stores[1]->set($key, $this->objects[3]);
|
||||
$this->assertIdenticalObject($this->objects[3], $stores[0]->get($key));
|
||||
$this->assertIdenticalObject($this->objects[3], $stores[1]->get($key));
|
||||
$this->assertEquals($this->objects[3], $stores[0]->get($key));
|
||||
$this->assertEquals($this->objects[3], $stores[1]->get($key));
|
||||
$metadata = $stores[1]->getMetadata($key);
|
||||
$this->assertEqual($users[1], $metadata->getOwnerId());
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ trait FileSystemModuleDiscoveryDataProviderTrait {
|
||||
* An array of module names to test.
|
||||
*/
|
||||
public function coreModuleListDataProvider() {
|
||||
$module_dirs = array_keys(iterator_to_array(new \FilesystemIterator(__DIR__ . '/../../../modules/')));
|
||||
$module_names = array_map(function ($path) {
|
||||
return str_replace(__DIR__ . '/../../../modules/', '', $path);
|
||||
$prefix = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'modules';
|
||||
$module_dirs = array_keys(iterator_to_array(new \FilesystemIterator($prefix)));
|
||||
$module_names = array_map(function ($path) use ($prefix) {
|
||||
return str_replace($prefix . DIRECTORY_SEPARATOR, '', $path);
|
||||
}, $module_dirs);
|
||||
$modules_keyed = array_combine($module_names, $module_names);
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
+1
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -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.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -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. It’s 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. It’s 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. It’s 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. It’s 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. It’s 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. It’s 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());
|
||||
|
||||
+2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user