Skip to content

Commit

Permalink
feat(drupal): #1299: Drupal 10 Readiness (#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
balintpekker authored Sep 23, 2022
1 parent dedd45c commit ffed89b
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion assets/explorer/dist/bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/explorer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Explorer from './Explorer';
*/
Drupal.behaviors.graphQLRenderExplorer = {
attach: (context, settings) => {
const container = jQuery('#graphql-explorer', context).once('graphql-explorer')[0] || undefined;
const container = jQuery(once('graphql-explorer', '#graphql-explorer', context))[0] || undefined;

if (typeof container === 'undefined') {
return;
Expand Down
2 changes: 1 addition & 1 deletion assets/voyager/dist/bundle.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/voyager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"lint": "eslint src"
},
"dependencies": {
"@drupal/once": "^1.0.1",
"graphql": "^15.5.1",
"graphql-voyager": "^1.0.0-rc.27",
"react": "^16.3",
Expand Down
3 changes: 2 additions & 1 deletion assets/voyager/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import ReactDOM from 'react-dom';
import { Voyager } from 'graphql-voyager';
import Drupal from 'drupal';
import jQuery from 'jquery';
import once from '@drupal/once';

/**
* Behavior for rendering the GraphQL Voyager interface.
*/
Drupal.behaviors.graphQLRenderVoyager = {
attach: (context, settings) => {
const container = jQuery('#graphql-voyager', context).once('graphql-voyager')[0] || undefined;
const container = jQuery(once('graphql-voyager', '#graphql-voyager', context))[0] || undefined;

if (typeof container === 'undefined') {
return;
Expand Down
5 changes: 5 additions & 0 deletions assets/voyager/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f"
integrity sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA==

"@drupal/once@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@drupal/once/-/once-1.0.1.tgz#7c1ef480aec6d5fa4b5ae986afa5a607afc38482"
integrity sha512-O8tQmNDBgSm3ADuFZ5OZlGxsrdsc+pEqd1NBoMpSzWwiOnWwC91tqDwnlX+mDh7sBJoJ+4vVwFh0NLUV4LPFvg==

"@eslint/eslintrc@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.1.0.tgz#583d12dbec5d4f22f333f9669f7d0b7c7815b4d3"
Expand Down
6 changes: 3 additions & 3 deletions graphql.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ explorer:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once

voyager:
version: VERSION
Expand All @@ -23,7 +23,7 @@ voyager:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once

persisted_queries:
version: VERSION
Expand All @@ -32,4 +32,4 @@ persisted_queries:
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/once
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ parameters:
# that.
- "#^Access to an undefined property Drupal\\\\#"
# PHPUnit deprecation warnings in Drupal 9 that we don't care about.
- "#^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder:#"
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
# Drupal allows object property access to custom fields, so we cannot fix
# that.
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/Framework/BufferedFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function setUp(): void {
*/
public function testBatchedFields(): void {
$buffer = $this->getMockBuilder(BufferBase::class)
->setMethods(['resolveBufferArray'])
->onlyMethods(['resolveBufferArray'])
->getMock();

$users = [
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/Framework/DisabledResultCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testDisabledCache(): void {

$object = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$object->expects($this->exactly(2))
Expand Down
20 changes: 10 additions & 10 deletions tests/src/Kernel/Framework/ResultCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function setUp(): void {
public function testCacheableResult(): void {
$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->once())
Expand All @@ -66,7 +66,7 @@ function () use ($dummy) {
*/
public function testUncacheableResult(): void {
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->getMock();

$cacheable->expects($this->any())
Expand All @@ -83,7 +83,7 @@ public function testUncacheableResult(): void {

$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->exactly(2))
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testUncacheableResult(): void {
*/
public function testUncacheableResultAnnotation(): void {
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->getMock();

$cacheable->expects($this->any())
Expand All @@ -128,7 +128,7 @@ public function testUncacheableResultAnnotation(): void {

$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->exactly(2))
Expand Down Expand Up @@ -157,7 +157,7 @@ public function testUncacheableResultAnnotation(): void {
public function testVariables(): void {
$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->exactly(2))
Expand Down Expand Up @@ -185,7 +185,7 @@ function () use ($dummy) {
*/
public function testContext(): void {
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->getMock();

$cacheable->expects($this->any())
Expand All @@ -202,7 +202,7 @@ public function testContext(): void {

$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->exactly(2))
Expand Down Expand Up @@ -261,7 +261,7 @@ public function testContext(): void {
*/
public function testTags(): void {
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->getMock();

$cacheable->expects($this->any())
Expand All @@ -278,7 +278,7 @@ public function testTags(): void {

$dummy = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
->setMethods(['id'])
->onlyMethods(['id'])
->getMock();

$dummy->expects($this->exactly(2))
Expand Down
10 changes: 5 additions & 5 deletions tests/src/Kernel/Framework/TestFrameworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testFieldMock(): void {
$this->setUpSchema($schema);

$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
->getMock();

$cacheable->expects($this->any())
Expand Down Expand Up @@ -92,7 +92,7 @@ public function testMutationMock(): void {
query: Query
mutation: Mutation
}
type Query {
root: Boolean
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public function testInterfaceMock(): void {
schema {
query: Query
}
type Query {
root: [Token]
}
Expand Down Expand Up @@ -178,7 +178,7 @@ interface Token {
... on Number {
number: value
}
... on Word {
word:value
}
Expand All @@ -202,7 +202,7 @@ public function testUnionMock(): void {
schema {
query: Query
}
type Query {
root: [Token]
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Traits/MockingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
/** @var \PHPUnit\Framework\MockObject\MockObject $extensionManager */
$extensionManager = $this->getMockBuilder(SchemaExtensionPluginManager::class)
->disableOriginalConstructor()
->setMethods(['getExtensions'])
->onlyMethods(['getExtensions'])
->getMock();

$extensionManager->expects(static::any())
Expand All @@ -144,7 +144,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
$extensionManager,
['development' => FALSE],
])
->setMethods(['getSchemaDefinition', 'getResolverRegistry'])
->onlyMethods(['getSchemaDefinition', 'getResolverRegistry'])
->getMockForAbstractClass();

$this->schema->expects(static::any())
Expand Down

0 comments on commit ffed89b

Please sign in to comment.