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

Commit

Permalink
add travis ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingsun committed Jul 5, 2017
1 parent 2046b27 commit 1f05f7c
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 38 deletions.
93 changes: 93 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#
# Travis Setup
#

# faster builds on new travis setup not using sudo
sudo: false

# build only on master branches
# commented as this prevents people from running builds on their forks:
# https://github.com/yiisoft/yii2/commit/bd87be990fa238c6d5e326d0a171f38d02dc253a
#branches:
# only:
# - master
# - 2.1


#
# Test Matrix
#

language: php

env:
global:
- DEFAULT_COMPOSER_FLAGS="--prefer-dist --no-interaction --no-progress --optimize-autoloader"
- TASK_TESTS_PHP=1
- TASK_TESTS_JS=0
- TASK_TESTS_COVERAGE=0

# cache vendor dirs
cache:
directories:
- vendor
- $HOME/.composer/cache
- $HOME/.npm

matrix:
fast_finish: true
include:
# run tests coverage on PHP 7.1
- php: 7.1
env: TASK_TESTS_COVERAGE=1

- php: 7.0
allow_failures:
- php: 7.1

install:
- |
if [[ $TASK_TESTS_COVERAGE != 1 && $TRAVIS_PHP_VERSION != hhv* ]]; then
# disable xdebug for performance reasons when code coverage is not needed. note: xdebug on hhvm is disabled by default
phpenv config-rm xdebug.ini || echo "xdebug is not installed"
fi
# install composer dependencies
- travis_retry composer self-update
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [[ $TRAVIS_PHP_VERSION == "hhvm-3.12" ]]; then
# remove php-cs-fixer from composer dependencies on hhvm-3.12 - php-cs-fixer requires at least hhvm-3.18
composer remove friendsofphp/php-cs-fixer --dev
fi
- travis_retry composer install $DEFAULT_COMPOSER_FLAGS

before_script:
# show some versions and env information
- php --version
- composer --version
- |
if [ $TASK_TESTS_JS == 1 ]; then
node --version
npm --version
fi
# enable code coverage
- |
if [ $TASK_TESTS_COVERAGE == 1 ]; then
PHPUNIT_FLAGS="--coverage-clover=coverage.clover"
fi
script:
# PHP tests
- |
if [ $TASK_TESTS_PHP == 1 ]; then
vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --configuration phpunit.xml.dist
fi
after_script:
- |
if [ $TASK_TESTS_COVERAGE == 1 ]; then
travis_retry wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi
39 changes: 1 addition & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,43 +246,6 @@ class UserType extends GraphQLType
}
```

#### 创建基于yii activerecord查询 ####

像普通的Query创建一个Query文件,只需要将type指向模型文件即可
```php
class UserModelQuery extends GraphQLQuery
{
public function type()
{
return Type::listOf(GraphQL::type(UserModel::class));
}

public function args()
{
return [
'id'=>[
'type'=>Type::id(),
'description'=>'用户的ID'
],
'pageIndex'=>[
'type'=>Type::int(),
'description'=>''
],
'pageSize'=> [
'type'=> Type::int(),
'description'=>'',
],
];
}

public function resolve($root,$args,$context,ResolveInfo $info){
$id = $args['id'];
return UserModel::findAll(['id'=>$id]);
}

}
```

#### 查询实例 ####

```php
Expand Down Expand Up @@ -350,6 +313,6 @@ array definitions
string value
```

### todo
### Future
* ActiveRecord generate tool for generating query and mutation class.
* 对于graphql的一些特殊语法,像参数语法,内置指令语法还未进行测试
21 changes: 21 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
backupGlobals="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii GraphQL Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">framework/</directory>
</whitelist>
<blacklist>
</blacklist>
</filter>
</phpunit>

0 comments on commit 1f05f7c

Please sign in to comment.