Skip to content

Commit 2a6c2ec

Browse files
committed
Adding test setup.
1 parent 6a2829c commit 2a6c2ec

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

.scrutinizer.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
filter:
2+
excluded_paths:
3+
- 'tests/*'
4+
5+
checks:
6+
php: true

.travis.yml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
language: php
2+
sudo: false
3+
4+
php:
5+
- 5.5
6+
- 5.6
7+
- 7
8+
9+
env:
10+
global:
11+
- DRUPAL_GRAPHQL=8.x-3.x
12+
- DRUPAL_BUILD_DIR=$TRAVIS_BUILD_DIR/../drupal
13+
- SIMPLETEST_DB=mysql://root:@127.0.0.1/graphql
14+
- TRAVIS=true
15+
matrix:
16+
- DRUPAL_CORE=8.2.x
17+
- DRUPAL_CORE=8.3.x
18+
- DRUPAL_CORE=8.4.x
19+
20+
matrix:
21+
# Don't wait for the allowed failures to build.
22+
fast_finish: true
23+
include:
24+
- php: 7
25+
env:
26+
- DRUPAL_CORE=8.4.x
27+
# Only run code coverage on the latest php and drupal versions.
28+
- WITH_PHPDBG_COVERAGE=true
29+
allow_failures:
30+
# Allow the code coverage report to fail.
31+
- php: 7
32+
env:
33+
- DRUPAL_CORE=8.4.x
34+
# Only run code coverage on the latest php and drupal versions.
35+
- WITH_PHPDBG_COVERAGE=true
36+
37+
mysql:
38+
database: graphql
39+
username: root
40+
encoding: utf8
41+
42+
# Cache composer downloads.
43+
cache:
44+
directories:
45+
- $HOME/.composer
46+
47+
before_install:
48+
# Disable xdebug.
49+
- phpenv config-rm xdebug.ini
50+
51+
# Determine the php settings file location.
52+
- if [[ $TRAVIS_PHP_VERSION = hhvm* ]];
53+
then export PHPINI=/etc/hhvm/php.ini;
54+
else export PHPINI=$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini;
55+
fi
56+
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+
65+
# Disable the default memory limit.
66+
- echo memory_limit = -1 >> $PHPINI
67+
68+
# Update composer.
69+
- composer self-update
70+
71+
install:
72+
# Create the database.
73+
- mysql -e 'create database graphql'
74+
75+
# Download Drupal 8 core from the Github mirror because it is faster.
76+
- git clone --branch $DRUPAL_CORE --depth 1 https://github.com/drupal/drupal.git $DRUPAL_BUILD_DIR
77+
- git clone --branch $DRUPAL_GRAPHQL --depth 1 https://github.com/fubhy/graphql-drupal.git $DRUPAL_BUILD_DIR/modules/graphql
78+
79+
# Reference the module in the build site.
80+
- ln -s $TRAVIS_BUILD_DIR $DRUPAL_BUILD_DIR/modules/graphql_json
81+
82+
# When running with phpdbg we need to replace all code occurrences that check
83+
# for 'cli' with 'phpdbg'. Some files might be write protected, hence the
84+
# fallback.
85+
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
86+
then grep -rl 'cli' $DRUPAL_BUILD_DIR/core $DRUPAL_BUILD_DIR/modules | xargs sed -i "s/'cli'/'phpdbg'/g" || true;
87+
fi
88+
89+
# Bring in the module dependencies without requiring a merge plugin. The
90+
# require also triggers a full 'composer install'.
91+
- composer --working-dir=$DRUPAL_BUILD_DIR require youshido/graphql:~1.5
92+
93+
script:
94+
# Run the unit tests using phpdbg if the environment variable is 'true'.
95+
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
96+
then phpdbg -qrr $DRUPAL_BUILD_DIR/vendor/bin/phpunit --configuration $DRUPAL_BUILD_DIR/core/phpunit.xml.dist --coverage-clover $TRAVIS_BUILD_DIR/coverage.xml $TRAVIS_BUILD_DIR;
97+
fi
98+
99+
# Run the unit tests with standard php otherwise.
100+
- if [[ "$WITH_PHPDBG_COVERAGE" != "true" ]];
101+
then $DRUPAL_BUILD_DIR/vendor/bin/phpunit --configuration $DRUPAL_BUILD_DIR/core/phpunit.xml.dist $TRAVIS_BUILD_DIR;
102+
fi
103+
104+
after_success:
105+
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
106+
then bash <(curl -s https://codecov.io/bash);
107+
fi

phpcs.xml.dist

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="graphql">
3+
<description>Default PHP CodeSniffer configuration for GraphQL.</description>
4+
<file>.</file>
5+
6+
<arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
7+
8+
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
9+
<!-- Annotations must use the same property names as in the configuration. -->
10+
<exclude-pattern>src/Annotation</exclude-pattern>
11+
<exclude-pattern>src/Core/Annotation</exclude-pattern>
12+
</rule>
13+
14+
<!-- We always want short array syntax only. -->
15+
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
16+
</ruleset>

0 commit comments

Comments
 (0)