diff --git a/.gitignore b/.gitignore index 939ea3f..08b5659 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /vendor /tests/_log/* /tests/_temp/* -/composer.lock +/composer*.lock !.gitkeep diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ee38d8..d6a8900 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e767f9d --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/composer-nette_2.2.json b/composer-nette_2.2.json new file mode 100644 index 0000000..b7baa75 --- /dev/null +++ b/composer-nette_2.2.json @@ -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" + } + } +} diff --git a/composer.json b/composer.json index ceb8c60..a9f4617 100644 --- a/composer.json +++ b/composer.json @@ -35,11 +35,5 @@ "Tests\\Unit\\": "tests/unit/src", "Tests\\Integration\\": "tests/integration/src" } - }, - "repositories": [ - { - "type": "composer", - "url": "http://packages.m33.cz" - } - ] + } } diff --git a/src/Http/Request.php b/src/Http/Request.php index 3219454..cc18362 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -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) diff --git a/tests.md b/tests.md new file mode 100644 index 0000000..988b157 --- /dev/null +++ b/tests.md @@ -0,0 +1,51 @@ +How to run tests +==== + +``` +# go to the project's root directory, but NOT the tests subdirectory +cd + +# 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 +``` diff --git a/tests/run.sh b/tests/run.sh index 7ce4d8b..14779e0 100644 --- a/tests/run.sh +++ b/tests/run.sh @@ -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