Skip to content

Commit f2cc23c

Browse files
authored
Merge pull request #4 from zacksleo/feature-travis
Feature travis
2 parents 4723271 + 04f847b commit f2cc23c

10 files changed

+110
-12
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
.styleci.yml export-ignore
77
.travis.yml export-ignore
88
/README.md export-ignore
9-
/README-cn.md export-ignore
9+
/docs export-ignore
10+
.travis.yml export-ignore
11+
.travis.env export-ignore

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ api-test:
148148
- fi
149149
- cp tests/.env .env
150150
- ./yii migrate/up --interactive=0
151-
- php -S localhost:80 --docroot api/tests &>/dev/null&
151+
- php -S localhost:8080 --docroot api/tests &>/dev/null&
152152
- ./vendor/bin/codecept run api -c tests
153153
artifacts:
154154
name: "debug"

.travis.env

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# App Config
2+
APP_ID=DummyId
3+
APP_NAME=DummyAppName
4+
ADMIN_EMAIL=DummyAdminEmail
5+
6+
# Whether to enable debug mode in Yii. If not set this will be 0.
7+
YII_DEBUG=1
8+
9+
# The application mode. If not set, this will be 'prod'
10+
YII_ENV=dev
11+
12+
# The log trace level. If not set, this will be 0
13+
#YII_TRACELEVEL=0
14+
15+
# Make sure that you provide a different unique cookie validation key in production
16+
COOKIE_VALIDATION_KEY="DummyValidationKey"
17+
18+
# DB credentials. Default is to fetch the host form docker vars and use 'web' as db name, username and password
19+
DB_DSN=mysql:host=127.0.0.1;dbname=web
20+
DB_USER=root
21+
DB_PASSWORD=''
22+
DB_TABLE_PREFIX=prefix_
23+
DB_CHARSET=utf8
24+
25+
# Configure a SMTP server here if you want to send emails
26+
SMTP_HOST="smtp.demo.com"
27+
SMTP_USER="[email protected]"
28+
SMTP_PASSWORD="password"

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
language: php
2+
3+
matrix:
4+
fast_finish: true
5+
6+
php:
7+
- 7.1
8+
9+
sudo: false
10+
11+
cache:
12+
directories:
13+
- "$HOME/.composer/cache"
14+
- vendor
15+
16+
services:
17+
- mysql
18+
- redis-server
19+
20+
install:
21+
- travis_retry composer self-update
22+
- travis_retry composer install --prefer-dist --no-interaction
23+
- cp .travis.env tests/.env
24+
- mv .travis.env .env
25+
- mv -f tests/travis.api.suite.yml tests/api.suite.yml
26+
- mv -f tests/travis.unit.suite.yml tests/unit.suite.yml
27+
28+
before_script:
29+
- travis_retry mysql -e 'CREATE DATABASE web;'
30+
- php yii migrate --interactive=0
31+
- php -S localhost:8080 --docroot api/web &>/dev/null&
32+
33+
script:
34+
- ./vendor/bin/codecept run api -c tests --debug
35+
- ./vendor/bin/codecept run unit -c tests --coverage --coverage-xml=coverage.clover
36+
37+
after_script:
38+
- wget https://scrutinizer-ci.com/ocular.phar
39+
- php ocular.phar code-coverage:upload --format=php-clover ./tests/_output/coverage.clover

common/config/test-local.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'username' => $_ENV['DB_USER'],
1212
'password' => $_ENV['DB_PASSWORD'],
1313
'charset' => $_ENV['DB_CHARSET'],
14-
'tablePrefix' => $_ENV['DB_PREFIX'],
14+
'tablePrefix' => $_ENV['DB_TABLE_PREFIX'],
1515
],
1616
],
1717
]

docs/cn/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
#### 3. 运行测试:
142142

143143
+ 首先进入容器 `docker exec -it yii2appadvanced_web_1 /bin/sh`
144-
+ 启动API服务 `php -S localhost:80 --docroot api/tests &>/dev/null&`
144+
+ 启动API服务 `php -S localhost:8080 --docroot api/tests &>/dev/null&`
145145
+ 在项目根目录下, 运行`./vendor/bin/codecept run api -c tests`进行API测试
146146

147147
![](http://ww1.sinaimg.cn/large/675eb504gy1ffykpcylkvj20to09vab6.jpg)

docs/en/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Yii 2 Advanced Application Template with GitLab-CI and api module
2-
3-
[中文文档](README-cn.md)
4-
5-
> The project is used to quickly build API server and background framework
6-
7-
> Built-in continuous integration, automated code review, composer package dependent on automatic build, automated testing, Docker image packaging and publishing
81

92
## Quick Start
103

tests/api.suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ modules:
1212
cleanup: false
1313
reconnect: true
1414
- REST:
15-
url: http://localhost:80/api/v1
15+
url: http://localhost:8080/api/v1
1616
depends: PhpBrowser
1717
part: Json
1818

tests/travis.api.suite.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class_name: ApiTester
2+
bootstrap: false
3+
modules:
4+
enabled:
5+
- Yii2:
6+
configFile: '../common/config/test-local.php'
7+
- Db:
8+
dsn: mysql:host=127.0.0.1;dbname=web
9+
user: root
10+
password:
11+
populate: true
12+
cleanup: false
13+
reconnect: true
14+
- REST:
15+
url: http://localhost:8080/api/v1
16+
depends: PhpBrowser
17+
part: Json
18+

tests/travis.unit.suite.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Codeception Test Suite Configuration
2+
3+
# suite for unit (internal) tests.
4+
class_name: UnitTester
5+
bootstrap: false
6+
modules:
7+
enabled:
8+
- Yii2:
9+
part: [fixtures,orm]
10+
- Db:
11+
dsn: mysql:host=127.0.0.1;dbname=web
12+
user: root
13+
password:
14+
populate: true
15+
cleanup: false
16+
reconnect: true
17+
- Asserts
18+

0 commit comments

Comments
 (0)