Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3c8e0fe

Browse files
authored
Merge pull request #425 from OndraM/feature/codestyle-scripts
Add composer scripts for simple codestyle check/fix
2 parents 1eed92f + ecc272a commit 3c8e0fe

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ matrix:
4848
- php: 7.0
4949
env: CHECK_CODESTYLE=1
5050
before_script: ~
51-
script:
52-
- ./vendor/bin/php-cs-fixer fix --diff --dry-run
53-
- ./vendor/bin/phpcs --standard=PSR2 ./lib/ ./tests/
51+
script: composer codestyle:check
5452
after_script: ~
5553
after_success: ~
5654

CONTRIBUTING.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,28 @@ To execute all tests simply run:
2929
If you want to execute just the unit tests, run:
3030

3131
./vendor/bin/phpunit --testsuite unit
32+
33+
For the functional tests you must first [download](http://selenium-release.storage.googleapis.com/index.html) and start
34+
the selenium standalone server, start the local PHP server which will serve the test pages and then run the `functional`
35+
test suite:
36+
37+
java -jar selenium-server-standalone-2.53.1.jar -log selenium.log &
38+
php -S localhost:8000 -t tests/functional/web/ &
39+
./vendor/bin/phpunit --testsuite functional
3240

33-
For the functional tests you must first download and start the selenium server, then run the `functional` test suite:
41+
The functional tests will be started in HtmlUnit headless browser by default. If you want to run them in eg. Firefox,
42+
simply set the `BROWSER` environment variable:
3443

35-
java -jar selenium-server-standalone-2.48.2.jar -log selenium.log &
44+
...
45+
export BROWSER_NAME="firefox"
3646
./vendor/bin/phpunit --testsuite functional
3747

3848
### Check coding style
3949

4050
Your code-style should comply with [PSR-2](http://www.php-fig.org/psr/psr-2/). To make sure your code matches this requirement run:
4151

42-
./vendor/bin/php-cs-fixer fix --diff --dry-run
43-
./vendor/bin/phpcs --standard=PSR2 ./lib/ ./tests/
52+
composer codestyle:check
53+
54+
To auto-fix the codestyle simply run:
55+
56+
composer codestyle:fix

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,15 @@
3333
"Facebook\\WebDriver\\": ["tests/unit", "tests/functional"]
3434
},
3535
"classmap": ["tests/functional/"]
36+
},
37+
"scripts": {
38+
"codestyle:check": [
39+
"vendor/bin/php-cs-fixer fix --diff --dry-run",
40+
"vendor/bin/phpcs --standard=PSR2 ./lib/ ./tests/"
41+
],
42+
"codestyle:fix": [
43+
"vendor/bin/php-cs-fixer fix --diff || exit 0",
44+
"vendor/bin/phpcbf --standard=PSR2 ./lib/ ./tests/"
45+
]
3646
}
3747
}

0 commit comments

Comments
 (0)