Skip to content

Commit

Permalink
Automatize tests running
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Sep 24, 2015
1 parent 0c0350e commit 039e159
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/vendor
/tests/_log/*
/tests/_temp/*
/composer.lock
/composer*.lock

!.gitkeep
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
sniffer:
script:
- composer install
- composer update --no-interaction --prefer-source
- ./vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests

latest:
script:
- composer install
- composer update --no-interaction --prefer-source
- ./vendor/bin/codecept build
- ./vendor/bin/codecept run
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: php

env:
matrix:
- NETTE=nette-2.3
- NETTE=nette-2.2 COMPOSER=composer-nette_2.2.json

php:
- 5.5
- 5.6
- 7.0
- hhvm

before_install:
- composer self-update

install:
- composer update --no-interaction --prefer-source

before_script:
- vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
- vendor/bin/codecept build

script: vendor/bin/codecept run
28 changes: 28 additions & 0 deletions composer-nette_2.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"require": {
"php": ">=5.4.0",
"arachne/bootstrap": "~0.1",
"codeception/codeception": "~2.1",
"nette/bootstrap": "~2.2.0",
"nette/di": "~2.2.0",
"nette/http": "~2.2.0"
},
"require-dev": {
"php": ">=5.5.0",
"arachne/coding-style": "~0.3",
"enumag/application": "~0.2",
"nette/nette": "~2.2",
"squizlabs/php_codesniffer": "~2.0"
},
"autoload": {
"psr-4": {
"Arachne\\Codeception\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Unit\\": "tests/unit/src",
"Tests\\Integration\\": "tests/integration/src"
}
}
}
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,5 @@
"Tests\\Unit\\": "tests/unit/src",
"Tests\\Integration\\": "tests/integration/src"
}
},
"repositories": [
{
"type": "composer",
"url": "http://packages.m33.cz"
}
]
}
}
4 changes: 4 additions & 0 deletions src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public function __construct(RequestFactory $factory)
public function reset()
{
$this->request = $this->factory->createHttpRequest();
$url = $this->request->getUrl();
if (!$url->getPort()) {
$url->setPort(80); // Fix canonicalization in Nette 2.2.
}
}

public function getCookie($key, $default = null)
Expand Down
51 changes: 51 additions & 0 deletions tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
How to run tests
====

```
# go to the project's root directory, but NOT the tests subdirectory
cd <project_dir>
# install dependencies
composer update
# run the coding style checker and all tests
sh ./tests/run.sh
# fix coding style problems automatically
sh ./tests/fix.sh
```

Advanced usage
----

You can use these commands to do more specific tasks.

```
# generate necessary files to run the tests
./vendor/bin/codecept build
# run the unit suite
./vendor/bin/codecept run unit
# run the integration suite
./vendor/bin/codecept run integration
# run specific test
./vendor/bin/codecept tests/unit/src/FooTest.php
```

Testing with Nette 2.2
----

If you want to run the tests with Nette 2.2 use these commands to install the dependencies. Then run the tests normally.

```
# tell composer to use different json file
set COMPOSER=composer-nette_2.2.json
# install dependencies
composer update
# reset the environment variable to normal
set COMPOSER=composer.json
```
2 changes: 1 addition & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
./vendor/bin/codecept build
./vendor/bin/codecept run --coverage-html
./vendor/bin/codecept run

0 comments on commit 039e159

Please sign in to comment.