Skip to content

Commit

Permalink
Testing: Add compatibility to drupal 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis committed Sep 7, 2023
1 parent 7efdf50 commit f628407
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BreadcrumbsTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$breadcrumbManager = $this->prophesize('Drupal\Core\Breadcrumb\BreadcrumbManager');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BundleLessEntityTest extends GraphQLContentTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
FieldStorageConfig::create([
'field_name' => 'field_test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EntityByIdTest extends GraphQLContentTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $languageStorage */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EntityFieldValueTest extends GraphQLContentTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function userPermissions() {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->mockInputType('node_input', [
'name' => 'NodeInput',
Expand All @@ -41,6 +41,9 @@ protected function setUp() {
]);
}

/**
*
*/
protected function mockMutationFactory($definition, $result = NULL, $builder = NULL) {
$mutation = $this->getMockBuilder([
'createNode' => CreateEntityBase::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EntityQueryTest extends GraphQLContentTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->createContentType(['type' => 'a']);
$this->createContentType(['type' => 'b']);
Expand Down Expand Up @@ -50,7 +50,7 @@ public function testEntityQuery() {
$c->save();
$d->save();

// TODO: Check cache metadata.
// @todo Check cache metadata.
$metadata = $this->defaultCacheMetaData();
$metadata->addCacheContexts(['user.node_grants:view']);
$metadata->addCacheTags([
Expand Down Expand Up @@ -122,11 +122,11 @@ public function testFilterSecurity() {
$metadata->addCacheTags(['graphql', 'user_list']);
$this->assertResults('query { userQuery (filter: { conditions: [ { field: "pass", value: "foo" } ] }) { count } }', [], [
'userQuery' => [
// TODO: With proper access checking for filters this value should
// become "2" and the entity query field can be marked as secure
// @todo With proper access checking for filters this value should
// become "2" and the entity query field can be marked as secure
// again.
'count' => 0,
]
],
], $metadata);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function userPermissions() {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->installConfig(['node', 'filter', 'text']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GraphQLCoreTestBase extends GraphQLTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
// User entity schema is required for the currentUserContext field.
$this->installEntitySchema('user');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ImageFieldTest extends GraphQLContentTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installConfig('image');
$this->installSchema('file', 'file_usage');
Expand All @@ -44,7 +44,6 @@ public function testImageField() {

$a->save();


$style = ImageStyle::load('thumbnail');

$dimensions = [
Expand All @@ -58,7 +57,7 @@ public function testImageField() {
$metadata->addCacheTags([
'file:1',
'node:1',
// TODO: Check metatags. Is the config metatag required?
// @todo Check metatags. Is the config metatag required?
'config:image.style.thumbnail',
]);

Expand All @@ -78,7 +77,8 @@ public function testImageField() {
'width' => $dimensions['width'],
'height' => $dimensions['height'],
],
]],
],
],
],
],
], $metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LanguageTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->installConfig(['language']);
Expand Down Expand Up @@ -51,8 +51,7 @@ protected function setUp() {
*/
public function testLanguageId() {
$metadata = $this->defaultCacheMetaData();
// TODO: Should this also contain the language config cache metadata?
// @todo Should this also contain the language config cache metadata?
$this->assertResults($this->getQueryFromFile('languages.gql'), [], [
'languages' => [
0 => [
Expand Down Expand Up @@ -104,7 +103,7 @@ public function testLanguageSwitchLinks() {
'config:language.entity.en',
'config:language.entity.es',
'config:language.entity.fr',
'config:language.entity.pt-br'
'config:language.entity.pt-br',
]);

$this->assertResults($this->getQueryFromFile('language_switch_links.gql'), [], [
Expand Down Expand Up @@ -154,4 +153,5 @@ public function testLanguageSwitchLinks() {
],
], $metadata);
}

}
3 changes: 2 additions & 1 deletion modules/graphql_core/tests/src/Kernel/Menu/MenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MenuTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('menu_link_content');
$this->installConfig('menu_link_content');
Expand Down Expand Up @@ -126,4 +126,5 @@ public function testMenuTree() {
$metadata
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ExternalRequestTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('user');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InternalRequestTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('user');
}
Expand Down
4 changes: 2 additions & 2 deletions modules/graphql_core/tests/src/Kernel/Routing/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Drupal\Tests\graphql_core\Kernel\Routing;

use Drupal\Core\GeneratedUrl;
use Drupal\path_alias\AliasManagerInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\path_alias\AliasManagerInterface;
use Drupal\Tests\graphql_core\Kernel\GraphQLCoreTestBase;
use Prophecy\Argument;

Expand All @@ -22,7 +22,7 @@ class RouteTest extends GraphQLCoreTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$aliasManager = $this->prophesize(AliasManagerInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/Framework/LanguageContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LanguageContextTest extends GraphQLTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->mockType('node', ['name' => 'Node']);
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/Framework/PermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
use PhpParser\Node\Arg;
use Prophecy\Argument;

/**
Expand All @@ -24,7 +23,7 @@ protected function userPermissions() {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->mockField('root', [
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Kernel/Framework/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
use GraphQL\Server\OperationParams;
use Prophecy\Argument;

/**
Expand All @@ -17,7 +16,7 @@ class ResultTest extends GraphQLTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->mockField('root', [
'name' => 'root',
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Framework/SecureFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ protected function userPermissions() {
// Don't grant the user field security bypass for this test case.
return [
'execute graphql requests',
//'bypass graphql field security',
// 'bypass graphql field security',
];
}

/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->mockField('secure', [
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/GraphQLFileTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class GraphQLFileTestBase extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installConfig('system');
$this->installConfig('graphql');
Expand Down
5 changes: 2 additions & 3 deletions tests/src/Kernel/GraphQLTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\graphql\Traits\ProphesizePermissionsTrait;
use Drupal\Tests\graphql\Traits\EnableCliCacheTrait;
use Drupal\Tests\graphql\Traits\HttpRequestTrait;
use Drupal\Tests\graphql\Traits\IntrospectionTestTrait;
use Drupal\Tests\graphql\Traits\MockSchemaTrait;
use Drupal\Tests\graphql\Traits\MockGraphQLPluginTrait;
use Drupal\Tests\graphql\Traits\ProphesizePermissionsTrait;
use Drupal\Tests\graphql\Traits\QueryFileTrait;
use Drupal\Tests\graphql\Traits\QueryResultAssertionTrait;

Expand Down Expand Up @@ -96,7 +95,7 @@ public function register(ContainerBuilder $container) {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->injectTypeSystemPluginManagers($this->container);

Expand Down
5 changes: 4 additions & 1 deletion tests/src/Unit/StringFormattingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ public function testPropCaseFormatting($input, $expected) {
$this->assertSame(lcfirst($expected), call_user_func_array([StringHelper::class, 'propCase'], $input));
}

/**
*
*/
public function providerTestStringFormatting() {
return [
[['simple-name'], 'SimpleName'],
[['123-name-with*^&!@some-SPECIAL-chars'], '_123NameWithSomeSPECIALChars'],
[['simple', 'name-of-string', 'components'], 'SimpleNameOfStringComponents'],
[['123', 'array', '%^!@&#*', 'of', 'STRING', '(*&', 'components', 'with', 'SPEcial', 'chars'], '_123ArrayOfSTRINGComponentsWithSPEcialChars']
[['123', 'array', '%^!@&#*', 'of', 'STRING', '(*&', 'components', 'with', 'SPEcial', 'chars'], '_123ArrayOfSTRINGComponentsWithSPEcialChars'],
];
}

Expand Down

0 comments on commit f628407

Please sign in to comment.