Skip to content
This repository was archived by the owner on Apr 27, 2022. It is now read-only.

Commit 1f05f7c

Browse files
committed
add travis ci
1 parent 2046b27 commit 1f05f7c

File tree

3 files changed

+115
-38
lines changed

3 files changed

+115
-38
lines changed

.travis.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# Travis Setup
3+
#
4+
5+
# faster builds on new travis setup not using sudo
6+
sudo: false
7+
8+
# build only on master branches
9+
# commented as this prevents people from running builds on their forks:
10+
# https://github.com/yiisoft/yii2/commit/bd87be990fa238c6d5e326d0a171f38d02dc253a
11+
#branches:
12+
# only:
13+
# - master
14+
# - 2.1
15+
16+
17+
#
18+
# Test Matrix
19+
#
20+
21+
language: php
22+
23+
env:
24+
global:
25+
- DEFAULT_COMPOSER_FLAGS="--prefer-dist --no-interaction --no-progress --optimize-autoloader"
26+
- TASK_TESTS_PHP=1
27+
- TASK_TESTS_JS=0
28+
- TASK_TESTS_COVERAGE=0
29+
30+
# cache vendor dirs
31+
cache:
32+
directories:
33+
- vendor
34+
- $HOME/.composer/cache
35+
- $HOME/.npm
36+
37+
matrix:
38+
fast_finish: true
39+
include:
40+
# run tests coverage on PHP 7.1
41+
- php: 7.1
42+
env: TASK_TESTS_COVERAGE=1
43+
44+
- php: 7.0
45+
allow_failures:
46+
- php: 7.1
47+
48+
install:
49+
- |
50+
if [[ $TASK_TESTS_COVERAGE != 1 && $TRAVIS_PHP_VERSION != hhv* ]]; then
51+
# disable xdebug for performance reasons when code coverage is not needed. note: xdebug on hhvm is disabled by default
52+
phpenv config-rm xdebug.ini || echo "xdebug is not installed"
53+
fi
54+
55+
# install composer dependencies
56+
- travis_retry composer self-update
57+
- export PATH="$HOME/.composer/vendor/bin:$PATH"
58+
- |
59+
if [[ $TRAVIS_PHP_VERSION == "hhvm-3.12" ]]; then
60+
# remove php-cs-fixer from composer dependencies on hhvm-3.12 - php-cs-fixer requires at least hhvm-3.18
61+
composer remove friendsofphp/php-cs-fixer --dev
62+
fi
63+
- travis_retry composer install $DEFAULT_COMPOSER_FLAGS
64+
65+
before_script:
66+
# show some versions and env information
67+
- php --version
68+
- composer --version
69+
- |
70+
if [ $TASK_TESTS_JS == 1 ]; then
71+
node --version
72+
npm --version
73+
fi
74+
# enable code coverage
75+
- |
76+
if [ $TASK_TESTS_COVERAGE == 1 ]; then
77+
PHPUNIT_FLAGS="--coverage-clover=coverage.clover"
78+
fi
79+
80+
81+
script:
82+
# PHP tests
83+
- |
84+
if [ $TASK_TESTS_PHP == 1 ]; then
85+
vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --configuration phpunit.xml.dist
86+
fi
87+
88+
after_script:
89+
- |
90+
if [ $TASK_TESTS_COVERAGE == 1 ]; then
91+
travis_retry wget https://scrutinizer-ci.com/ocular.phar
92+
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
93+
fi

README.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -246,43 +246,6 @@ class UserType extends GraphQLType
246246
}
247247
```
248248

249-
#### 创建基于yii activerecord查询 ####
250-
251-
像普通的Query创建一个Query文件,只需要将type指向模型文件即可
252-
```php
253-
class UserModelQuery extends GraphQLQuery
254-
{
255-
public function type()
256-
{
257-
return Type::listOf(GraphQL::type(UserModel::class));
258-
}
259-
260-
public function args()
261-
{
262-
return [
263-
'id'=>[
264-
'type'=>Type::id(),
265-
'description'=>'用户的ID'
266-
],
267-
'pageIndex'=>[
268-
'type'=>Type::int(),
269-
'description'=>''
270-
],
271-
'pageSize'=> [
272-
'type'=> Type::int(),
273-
'description'=>'',
274-
],
275-
];
276-
}
277-
278-
public function resolve($root,$args,$context,ResolveInfo $info){
279-
$id = $args['id'];
280-
return UserModel::findAll(['id'=>$id]);
281-
}
282-
283-
}
284-
```
285-
286249
#### 查询实例 ####
287250

288251
```php
@@ -350,6 +313,6 @@ array definitions
350313
string value
351314
```
352315

353-
### todo
316+
### Future
354317
* ActiveRecord generate tool for generating query and mutation class.
355318
* 对于graphql的一些特殊语法,像参数语法,内置指令语法还未进行测试

phpunit.xml.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit bootstrap="./tests/bootstrap.php"
3+
backupGlobals="true"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
stopOnFailure="false">
9+
<testsuites>
10+
<testsuite name="Yii GraphQL Test Suite">
11+
<directory>./tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
<filter>
15+
<whitelist>
16+
<directory suffix=".php">framework/</directory>
17+
</whitelist>
18+
<blacklist>
19+
</blacklist>
20+
</filter>
21+
</phpunit>

0 commit comments

Comments
 (0)