Skip to content

Commit 038dc82

Browse files
authored
Fixing 3.x tests (#933)
* Updating travis configuration. * Test against Drupal 8.8.x * Fixed test that was still expecting inaccessible menu items. * Fixing test trait deprecation warnings. * Upgrade zend-stdlib to fix PHP 7.3 * Adding a proper assertion to InvalidPayloadTest. * Handling path alias entities in Drupal 8.8. * Re-added PHP 7.1 * Re-added PHP 7.0
1 parent 65a6555 commit 038dc82

File tree

5 files changed

+42
-32
lines changed

5 files changed

+42
-32
lines changed

.travis.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,38 @@ language: php
22
sudo: false
33

44
php:
5+
- 7.3
6+
- 7.2
57
- 7.1
6-
- 7
7-
- 5.6
8+
- 7.0
9+
10+
services:
11+
- mysql
812

913
env:
1014
global:
1115
- DRUPAL_BUILD_DIR=$TRAVIS_BUILD_DIR/../drupal
1216
- SIMPLETEST_DB=mysql://root:@127.0.0.1/graphql
1317
- TRAVIS=true
1418
matrix:
15-
- DRUPAL_CORE=8.3.x
16-
- DRUPAL_CORE=8.4.x
17-
- DRUPAL_CORE=8.5.x
1819
- DRUPAL_CORE=8.6.x
20+
- DRUPAL_CORE=8.7.x
21+
- DRUPAL_CORE=8.8.x
1922

2023
matrix:
2124
# Don't wait for the allowed failures to build.
2225
fast_finish: true
2326
include:
24-
- php: 7.1
27+
- php: 7.3
2528
env:
26-
- DRUPAL_CORE=8.6.x
29+
- DRUPAL_CORE=8.7.x
2730
# Only run code coverage on the latest php and drupal versions.
2831
- WITH_PHPDBG_COVERAGE=true
2932
allow_failures:
3033
# Allow the code coverage report to fail.
31-
- php: 7.1
34+
- php: 7.3
3235
env:
33-
- DRUPAL_CORE=8.6.x
36+
- DRUPAL_CORE=8.7.x
3437
# Only run code coverage on the latest php and drupal versions.
3538
- WITH_PHPDBG_COVERAGE=true
3639

@@ -54,14 +57,6 @@ before_install:
5457
else export PHPINI=$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini;
5558
fi
5659

57-
# PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated
58-
# and will be removed in a future version. To avoid this warning set
59-
# 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input
60-
# stream instead.
61-
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]];
62-
then echo always_populate_raw_post_data = -1 >> $PHPINI;
63-
fi;
64-
6560
# Disable the default memory limit.
6661
- echo memory_limit = -1 >> $PHPINI
6762

@@ -93,7 +88,15 @@ install:
9388
# require also triggers a full 'composer install'.
9489
- composer --working-dir=$DRUPAL_BUILD_DIR require webonyx/graphql-php:^0.12.5
9590

96-
- if [[ "$DRUPAL_CORE" != "8.3.x" && "$DRUPAL_CORE" != "8.4.x" ]];
91+
# For Drupal < 8.8 we have to manually upgrade zend-stdlib to avoid PHP 7.3
92+
# incompatibilities.
93+
- if [[ "$DRUPAL_CORE" = "8.6.x" || "$DRUPAL_CORE" = "8.7.x" ]];
94+
then composer --working-dir=$DRUPAL_BUILD_DIR require zendframework/zend-stdlib:3.2.1;
95+
fi
96+
97+
# For Drupal < 8.8 we have to manually upgrade phpunit to avoid PHP 7.3
98+
# incompatibilities.
99+
- if [[ "$DRUPAL_CORE" = "8.6.x" || "$DRUPAL_CORE" = "8.7.x" ]];
97100
then composer --working-dir=$DRUPAL_BUILD_DIR run-script drupal-phpunit-upgrade;
98101
fi
99102

modules/graphql_core/tests/src/Kernel/Blocks/BlockTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace Drupal\Tests\graphql_core\Kernel\Blocks;
44

55
use Drupal\block_content\Entity\BlockContent;
6-
use Drupal\simpletest\BlockCreationTrait;
6+
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
7+
use Drupal\Tests\block\Traits\BlockCreationTrait;
78
use Drupal\Tests\graphql_core\Kernel\GraphQLCoreTestBase;
89

910
/**
@@ -25,6 +26,7 @@ class BlockTest extends GraphQLCoreTestBase {
2526
'filter',
2627
'editor',
2728
'ckeditor',
29+
'path',
2830
'graphql_block_test',
2931
];
3032

@@ -39,6 +41,12 @@ protected function setUp() {
3941
$themeInstaller->install(['stark']);
4042

4143
$this->installEntitySchema('block_content');
44+
try {
45+
$this->installEntitySchema('path_alias');
46+
} catch (PluginNotFoundException $exc) {
47+
// Ignore if the path_alias entity doesn't exist. This means we are
48+
// testing a Drupal version < 8.8 and aliases are not entities yet.
49+
}
4250
$this->installConfig('block_content');
4351
$this->installConfig('graphql_block_test');
4452

modules/graphql_core/tests/src/Kernel/GraphQLContentTestBase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use Drupal\field\Entity\FieldStorageConfig;
77
use Drupal\node\Entity\Node;
88
use Drupal\Tests\graphql_core\Traits\RevisionsTestTrait;
9-
use Drupal\simpletest\ContentTypeCreationTrait;
10-
use Drupal\simpletest\NodeCreationTrait;
11-
use Drupal\simpletest\UserCreationTrait;
9+
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
10+
use Drupal\Tests\node\Traits\NodeCreationTrait;
11+
use Drupal\Tests\user\Traits\UserCreationTrait;
1212

1313
/**
1414
* Base class for node based tests.

modules/graphql_core/tests/src/Kernel/Menu/MenuTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ public function testMenuTree() {
112112
],
113113
],
114114
1 => [
115-
'label' => 'Inaccessible',
116-
'route' => [
117-
'path' => '/',
118-
'routed' => TRUE,
119-
],
120-
'attribute' => NULL,
121-
'links' => [],
122-
],
123-
2 => [
124115
'label' => 'Drupal',
125116
'route' => [
126117
'path' => 'http://www.drupal.org',

tests/src/Kernel/Framework/InvalidPayloadTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
class InvalidPayloadTest extends GraphQLTestBase {
1414

1515
public function testEmptyPayload() {
16-
$this->container->get('http_kernel')->handle(Request::create('/graphql', 'POST', [], [], [], [], '{ invalid'));
16+
/** @var \Symfony\Component\HttpFoundation\Response $result */
17+
$result = $this->container->get('http_kernel')
18+
->handle(Request::create('/graphql', 'POST', [], [], [], [], '{ invalid'));
19+
$this->assertJson($result->getContent(), json_encode([
20+
'errors' => [
21+
'message' => "GraphQL Request must include at least one of those two parameters: \u0022query\u0022 or \u0022queryId\u0022\"",
22+
'category' => "request"
23+
]
24+
]));
1725
}
1826

1927
}

0 commit comments

Comments
 (0)