Unverified Commit 8418bb7f authored by Leksat's avatar Leksat Committed by GitHub
Browse files

Drupal 9 compatibility for 3.x (#1102)

* Update core_version_requirement for Drupal 8.8+ and 9+

'core: 8.x' not needed for 8.8+
'core_version_requirement' not needed for test modules

https://www.drupal.org/node/3070687

Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>

* Test D9.0 on Travis CI

* Replace deprecated drupal_set_message() with messenger->addMessage()
Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>

* Replace deprecated file_directory_temp() with getTempDirectory()
Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>

* Replace deprecated PHPUnit_Framework_MockObject_MockObject with PHPUnit\Framework\MockObject\MockObject
Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>

* Replace deprecated RouteEnhancerInterface with EnhancerInterface
Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>

* Remove deprecated PHPUnit_Framework_Error_Warning

* Replace 'core: 8.x' with 'core_version_requirement: ^8.8 || ^9'

* Replace deprecated entity.manager with entity_type.manager

* Must enable the path_alias module in tests

* Replace deprecated url() with createFileUrl(FALSE)

* Assert menu is an object, rather than assert it is true

* chore: adjust things mentioned in #1067



* chore: adjust info.yml files for test modules

* chore: trigger travis build

* chore: keep composer at version 1
Co-authored-by: default avatarHugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: DamienMcKenna's avatarDamien McKenna <damien@mc-kenna.com>
parent 94cbcd42
......@@ -16,8 +16,9 @@ env:
- SIMPLETEST_DB=mysql://root:@127.0.0.1/graphql
- TRAVIS=true
matrix:
- DRUPAL_CORE=8.8.x
- DRUPAL_CORE=9.0.x
- DRUPAL_CORE=8.9.x
- DRUPAL_CORE=8.8.x
matrix:
# Don't wait for the allowed failures to build.
......@@ -28,6 +29,17 @@ matrix:
- DRUPAL_CORE=8.8.x
# Only run code coverage on the latest php and drupal versions.
- WITH_PHPDBG_COVERAGE=true
# Drupal 9 requires PHP 7.3 or higher
exclude:
- php: 7.0
env:
- DRUPAL_CORE=9.0.x
- php: 7.1
env:
- DRUPAL_CORE=9.0.x
- php: 7.2
env:
- DRUPAL_CORE=9.0.x
allow_failures:
# Allow the code coverage report to fail.
- php: 7.3
......@@ -62,8 +74,9 @@ before_install:
# Disable the default memory limit.
- echo memory_limit = -1 >> $PHPINI
# Update composer.
- composer self-update
# Update composer. But keep it at version 1 for compatibility with older
# Drupal versions.
- composer self-update --1
install:
# Create the database.
......
......@@ -3,4 +3,4 @@ type: module
description: 'Base module for integrating GraphQL with Drupal.'
package: GraphQL
configure: graphql.config_page
core: 8.x
core_version_requirement: ^8.8 || ^9
......@@ -2,6 +2,6 @@ name: GraphQL Core
type: module
description: 'Provides type system plugins and derivers on behalf of core modules.'
package: GraphQL
core: 8.x
core_version_requirement: ^8.8 || ^9
dependencies:
- graphql
\ No newline at end of file
- graphql:graphql
name: 'GraphQL Test: Blocks'
type: module
core: 8.x
package: Testing
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- block
- block_content
- ckeditor
- editor
- field
- filter
- system
- text
- drupal:block
- drupal:block_content
- drupal:ckeditor
- drupal:editor
- drupal:field
- drupal:filter
- drupal:system
- drupal:text
name: GraphQL Breadcrumbs test
type: module
description: 'Test for breadcrumbs.'
package: GraphQL
core: 8.x
package: Testing
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql_breadcrumbs
- graphql:graphql_core
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Context Test
description: Test contexts in graphql schema.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql_core
- graphql:graphql_core
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Requests Test
description: Dummy callbacks for internal request testing.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql_core
- graphql:graphql_core
name: 'GraphQL Tests: Menu'
type: module
core: 8.x
package: Testing
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- system
- drupal:system
......@@ -32,7 +32,7 @@ class EntityByIdTest extends GraphQLContentTestBase {
parent::setUp();
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $languageStorage */
$languageStorage = $this->container->get('entity.manager')->getStorage('configurable_language');
$languageStorage = $this->container->get('entity_type.manager')->getStorage('configurable_language');
$language = $languageStorage->create([
'id' => $this->chineseSimplifiedLangcode,
......
......@@ -14,6 +14,7 @@ class GraphQLCoreTestBase extends GraphQLTestBase {
*/
public static $modules = [
'graphql_core',
'path_alias',
'user',
];
......
......@@ -70,7 +70,7 @@ class ImageFieldTest extends GraphQLContentTestBase {
'image' => [[
'alt' => $a->image->alt,
'title' => $a->image->title,
'entity' => ['url' => $a->image->entity->url()],
'entity' => ['url' => $a->image->entity->createFileUrl(FALSE)],
'width' => $a->image[0]->width,
'height' => $a->image[0]->height,
'thumbnailImage' => [
......
......@@ -55,7 +55,7 @@ class MenuTest extends GraphQLCoreTestBase {
/** @var \Drupal\Core\Menu\MenuTreeStorageInterface $menuStorage */
$menuStorage = $this->container->get('entity_type.manager')->getStorage('menu');
$menu = $menuStorage->load('test');
$this->assertTrue($menu);
$this->assertIsObject($menu);
/** @var \Drupal\Core\Menu\MenuLinkTreeInterface $menuTree */
$menuTree = $this->container->get('menu.link_tree');
......
......@@ -73,7 +73,7 @@ class EntityQueryMapImportForm extends EntityForm {
$entity->set('map', array_flip((array) json_decode($json)));
$entity->save();
drupal_set_message($this->t('Saved the query map version %id.', [
$this->messenger()->addMessage($this->t('Saved the query map version %id.', [
'%id' => $entity->id(),
]));
......
......@@ -3,26 +3,24 @@
namespace Drupal\graphql\Routing;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface;
use Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface;
use Drupal\Core\Routing\EnhancerInterface;
use Drupal\graphql\Utility\JsonHelper;
use GraphQL\Server\Helper;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
class QueryRouteEnhancer implements RouteEnhancerInterface {
/**
* {@inheritdoc}
*/
public function applies(Route $route) {
return $route->hasDefault('_graphql');
}
class QueryRouteEnhancer implements EnhancerInterface {
/**
* {@inheritdoc}
*/
public function enhance(array $defaults, Request $request) {
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
if (!$route->hasDefault('_graphql')) {
return $defaults;
}
$helper = new Helper();
$method = $request->getMethod();
$body = $this->extractBody($request);
......
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Enumeration Test
description: Test enumeration plugins.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql
- graphql:graphql
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Override Test
description: Test plugin overrides in graphql schema.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql_plugin_test
- graphql:graphql_plugin_test
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Plugin Test
description: Test plugin based graphql schema.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql
- graphql:graphql
......@@ -2,7 +2,7 @@ type: module
name: GraphQL Test
description: Provides a default schema plugin for testing.
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
hidden: TRUE
dependencies:
- graphql
- graphql:graphql
......@@ -18,7 +18,8 @@ class UploadMutationTest extends GraphQLTestBase {
*/
public function testFileUpload() {
// Create dummy file, since symfony will test if it exists..
$file = file_directory_temp() . '/graphql_upload_test.txt';
$file = \Drupal::service('file_system')
->getTempDirectory() . '/graphql_upload_test.txt';
touch($file);
// Mock a mutation that accepts the upload input and just returns
......
......@@ -14,8 +14,6 @@ use Drupal\Tests\graphql\Traits\MockSchemaTrait;
use Drupal\Tests\graphql\Traits\MockGraphQLPluginTrait;
use Drupal\Tests\graphql\Traits\QueryFileTrait;
use Drupal\Tests\graphql\Traits\QueryResultAssertionTrait;
use PHPUnit_Framework_Error_Notice;
use PHPUnit_Framework_Error_Warning;
/**
* Base class for GraphQL tests.
......@@ -102,8 +100,6 @@ abstract class GraphQLTestBase extends KernelTestBase {
parent::setUp();
$this->injectTypeSystemPluginManagers($this->container);
PHPUnit_Framework_Error_Warning::$enabled = FALSE;
$this->injectAccount();
$this->installConfig('system');
$this->installConfig('graphql');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment