Skip to content

Commit 039e159

Browse files
committed
Automatize tests running
1 parent 0c0350e commit 039e159

File tree

8 files changed

+112
-11
lines changed

8 files changed

+112
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/vendor
22
/tests/_log/*
33
/tests/_temp/*
4-
/composer.lock
4+
/composer*.lock
55

66
!.gitkeep

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
sniffer:
22
script:
3-
- composer install
3+
- composer update --no-interaction --prefer-source
44
- ./vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
55

66
latest:
77
script:
8-
- composer install
8+
- composer update --no-interaction --prefer-source
99
- ./vendor/bin/codecept build
1010
- ./vendor/bin/codecept run

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: php
2+
3+
env:
4+
matrix:
5+
- NETTE=nette-2.3
6+
- NETTE=nette-2.2 COMPOSER=composer-nette_2.2.json
7+
8+
php:
9+
- 5.5
10+
- 5.6
11+
- 7.0
12+
- hhvm
13+
14+
before_install:
15+
- composer self-update
16+
17+
install:
18+
- composer update --no-interaction --prefer-source
19+
20+
before_script:
21+
- vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
22+
- vendor/bin/codecept build
23+
24+
script: vendor/bin/codecept run

composer-nette_2.2.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"require": {
3+
"php": ">=5.4.0",
4+
"arachne/bootstrap": "~0.1",
5+
"codeception/codeception": "~2.1",
6+
"nette/bootstrap": "~2.2.0",
7+
"nette/di": "~2.2.0",
8+
"nette/http": "~2.2.0"
9+
},
10+
"require-dev": {
11+
"php": ">=5.5.0",
12+
"arachne/coding-style": "~0.3",
13+
"enumag/application": "~0.2",
14+
"nette/nette": "~2.2",
15+
"squizlabs/php_codesniffer": "~2.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Arachne\\Codeception\\": "src"
20+
}
21+
},
22+
"autoload-dev": {
23+
"psr-4": {
24+
"Tests\\Unit\\": "tests/unit/src",
25+
"Tests\\Integration\\": "tests/integration/src"
26+
}
27+
}
28+
}

composer.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,5 @@
3535
"Tests\\Unit\\": "tests/unit/src",
3636
"Tests\\Integration\\": "tests/integration/src"
3737
}
38-
},
39-
"repositories": [
40-
{
41-
"type": "composer",
42-
"url": "http://packages.m33.cz"
43-
}
44-
]
38+
}
4539
}

src/Http/Request.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public function __construct(RequestFactory $factory)
3030
public function reset()
3131
{
3232
$this->request = $this->factory->createHttpRequest();
33+
$url = $this->request->getUrl();
34+
if (!$url->getPort()) {
35+
$url->setPort(80); // Fix canonicalization in Nette 2.2.
36+
}
3337
}
3438

3539
public function getCookie($key, $default = null)

tests.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
How to run tests
2+
====
3+
4+
```
5+
# go to the project's root directory, but NOT the tests subdirectory
6+
cd <project_dir>
7+
8+
# install dependencies
9+
composer update
10+
11+
# run the coding style checker and all tests
12+
sh ./tests/run.sh
13+
14+
# fix coding style problems automatically
15+
sh ./tests/fix.sh
16+
```
17+
18+
Advanced usage
19+
----
20+
21+
You can use these commands to do more specific tasks.
22+
23+
```
24+
# generate necessary files to run the tests
25+
./vendor/bin/codecept build
26+
27+
# run the unit suite
28+
./vendor/bin/codecept run unit
29+
30+
# run the integration suite
31+
./vendor/bin/codecept run integration
32+
33+
# run specific test
34+
./vendor/bin/codecept tests/unit/src/FooTest.php
35+
```
36+
37+
Testing with Nette 2.2
38+
----
39+
40+
If you want to run the tests with Nette 2.2 use these commands to install the dependencies. Then run the tests normally.
41+
42+
```
43+
# tell composer to use different json file
44+
set COMPOSER=composer-nette_2.2.json
45+
46+
# install dependencies
47+
composer update
48+
49+
# reset the environment variable to normal
50+
set COMPOSER=composer.json
51+
```

tests/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
./vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
22
./vendor/bin/codecept build
3-
./vendor/bin/codecept run --coverage-html
3+
./vendor/bin/codecept run

0 commit comments

Comments
 (0)