Skip to content

Commit ffed89b

Browse files
authored
feat(drupal): drupal-graphql#1299: Drupal 10 Readiness (drupal-graphql#1300)
1 parent dedd45c commit ffed89b

13 files changed

+33
-27
lines changed

assets/explorer/dist/bundle.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/explorer/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Explorer from './Explorer';
1010
*/
1111
Drupal.behaviors.graphQLRenderExplorer = {
1212
attach: (context, settings) => {
13-
const container = jQuery('#graphql-explorer', context).once('graphql-explorer')[0] || undefined;
13+
const container = jQuery(once('graphql-explorer', '#graphql-explorer', context))[0] || undefined;
1414

1515
if (typeof container === 'undefined') {
1616
return;

assets/voyager/dist/bundle.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/voyager/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"lint": "eslint src"
77
},
88
"dependencies": {
9+
"@drupal/once": "^1.0.1",
910
"graphql": "^15.5.1",
1011
"graphql-voyager": "^1.0.0-rc.27",
1112
"react": "^16.3",

assets/voyager/src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import ReactDOM from 'react-dom';
33
import { Voyager } from 'graphql-voyager';
44
import Drupal from 'drupal';
55
import jQuery from 'jquery';
6+
import once from '@drupal/once';
67

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

1415
if (typeof container === 'undefined') {
1516
return;

assets/voyager/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f"
100100
integrity sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA==
101101

102+
"@drupal/once@^1.0.1":
103+
version "1.0.1"
104+
resolved "https://registry.yarnpkg.com/@drupal/once/-/once-1.0.1.tgz#7c1ef480aec6d5fa4b5ae986afa5a607afc38482"
105+
integrity sha512-O8tQmNDBgSm3ADuFZ5OZlGxsrdsc+pEqd1NBoMpSzWwiOnWwC91tqDwnlX+mDh7sBJoJ+4vVwFh0NLUV4LPFvg==
106+
102107
"@eslint/eslintrc@^1.1.0":
103108
version "1.1.0"
104109
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.1.0.tgz#583d12dbec5d4f22f333f9669f7d0b7c7815b4d3"

graphql.libraries.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ explorer:
99
dependencies:
1010
- core/drupal
1111
- core/jquery
12-
- core/jquery.once
12+
- core/once
1313

1414
voyager:
1515
version: VERSION
@@ -23,7 +23,7 @@ voyager:
2323
dependencies:
2424
- core/drupal
2525
- core/jquery
26-
- core/jquery.once
26+
- core/once
2727

2828
persisted_queries:
2929
version: VERSION
@@ -32,4 +32,4 @@ persisted_queries:
3232
dependencies:
3333
- core/drupal
3434
- core/jquery
35-
- core/jquery.once
35+
- core/once

phpstan.neon

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ parameters:
2525
# that.
2626
- "#^Access to an undefined property Drupal\\\\#"
2727
# PHPUnit deprecation warnings in Drupal 9 that we don't care about.
28-
- "#^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder:#"
2928
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
3029
# Drupal allows object property access to custom fields, so we cannot fix
3130
# that.

tests/src/Kernel/Framework/BufferedFieldTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function setUp(): void {
4343
*/
4444
public function testBatchedFields(): void {
4545
$buffer = $this->getMockBuilder(BufferBase::class)
46-
->setMethods(['resolveBufferArray'])
46+
->onlyMethods(['resolveBufferArray'])
4747
->getMock();
4848

4949
$users = [

tests/src/Kernel/Framework/DisabledResultCacheTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testDisabledCache(): void {
4949

5050
$object = $this->getMockBuilder(Server::class)
5151
->disableOriginalConstructor()
52-
->setMethods(['id'])
52+
->onlyMethods(['id'])
5353
->getMock();
5454

5555
$object->expects($this->exactly(2))

tests/src/Kernel/Framework/ResultCacheTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function setUp(): void {
4141
public function testCacheableResult(): void {
4242
$dummy = $this->getMockBuilder(Server::class)
4343
->disableOriginalConstructor()
44-
->setMethods(['id'])
44+
->onlyMethods(['id'])
4545
->getMock();
4646

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

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

8484
$dummy = $this->getMockBuilder(Server::class)
8585
->disableOriginalConstructor()
86-
->setMethods(['id'])
86+
->onlyMethods(['id'])
8787
->getMock();
8888

8989
$dummy->expects($this->exactly(2))
@@ -111,7 +111,7 @@ public function testUncacheableResult(): void {
111111
*/
112112
public function testUncacheableResultAnnotation(): void {
113113
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
114-
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
114+
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
115115
->getMock();
116116

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

129129
$dummy = $this->getMockBuilder(Server::class)
130130
->disableOriginalConstructor()
131-
->setMethods(['id'])
131+
->onlyMethods(['id'])
132132
->getMock();
133133

134134
$dummy->expects($this->exactly(2))
@@ -157,7 +157,7 @@ public function testUncacheableResultAnnotation(): void {
157157
public function testVariables(): void {
158158
$dummy = $this->getMockBuilder(Server::class)
159159
->disableOriginalConstructor()
160-
->setMethods(['id'])
160+
->onlyMethods(['id'])
161161
->getMock();
162162

163163
$dummy->expects($this->exactly(2))
@@ -185,7 +185,7 @@ function () use ($dummy) {
185185
*/
186186
public function testContext(): void {
187187
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
188-
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
188+
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
189189
->getMock();
190190

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

203203
$dummy = $this->getMockBuilder(Server::class)
204204
->disableOriginalConstructor()
205-
->setMethods(['id'])
205+
->onlyMethods(['id'])
206206
->getMock();
207207

208208
$dummy->expects($this->exactly(2))
@@ -261,7 +261,7 @@ public function testContext(): void {
261261
*/
262262
public function testTags(): void {
263263
$cacheable = $this->getMockBuilder(CacheableDependencyInterface::class)
264-
->setMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
264+
->onlyMethods(['getCacheTags', 'getCacheMaxAge', 'getCacheContexts'])
265265
->getMock();
266266

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

279279
$dummy = $this->getMockBuilder(Server::class)
280280
->disableOriginalConstructor()
281-
->setMethods(['id'])
281+
->onlyMethods(['id'])
282282
->getMock();
283283

284284
$dummy->expects($this->exactly(2))

tests/src/Kernel/Framework/TestFrameworkTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testFieldMock(): void {
2626
$this->setUpSchema($schema);
2727

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

3232
$cacheable->expects($this->any())
@@ -92,7 +92,7 @@ public function testMutationMock(): void {
9292
query: Query
9393
mutation: Mutation
9494
}
95-
95+
9696
type Query {
9797
root: Boolean
9898
}
@@ -141,7 +141,7 @@ public function testInterfaceMock(): void {
141141
schema {
142142
query: Query
143143
}
144-
144+
145145
type Query {
146146
root: [Token]
147147
}
@@ -178,7 +178,7 @@ interface Token {
178178
... on Number {
179179
number: value
180180
}
181-
181+
182182
... on Word {
183183
word:value
184184
}
@@ -202,7 +202,7 @@ public function testUnionMock(): void {
202202
schema {
203203
query: Query
204204
}
205-
205+
206206
type Query {
207207
root: [Token]
208208
}

tests/src/Traits/MockingTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void {
127127
/** @var \PHPUnit\Framework\MockObject\MockObject $extensionManager */
128128
$extensionManager = $this->getMockBuilder(SchemaExtensionPluginManager::class)
129129
->disableOriginalConstructor()
130-
->setMethods(['getExtensions'])
130+
->onlyMethods(['getExtensions'])
131131
->getMock();
132132

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

150150
$this->schema->expects(static::any())

0 commit comments

Comments
 (0)