Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lansoweb committed Jul 15, 2019
1 parent 5a41f3c commit 6382ca9
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 149 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":937:{a:2:{s:7:"defects";a:6:{s:61:"LosMiddlewareTest\RateLimit\RateLimitTest::testNeedIpOuApiKey";i:4;s:66:"LosMiddlewareTest\RateLimit\RateLimitTest::testAddHeadersForApiKey";i:4;s:62:"LosMiddlewareTest\RateLimit\RateLimitTest::testAddHeadersForIp";i:4;s:64:"LosMiddlewareTest\RateLimit\RateLimitTest::testDecreaseRemaining";i:4;s:58:"LosMiddlewareTest\RateLimit\RateLimitTest::testGenerate429";i:3;s:52:"LosMiddlewareTest\RateLimit\RateLimitTest::testReset";i:3;}s:5:"times";a:6:{s:61:"LosMiddlewareTest\RateLimit\RateLimitTest::testNeedIpOuApiKey";d:0.039;s:66:"LosMiddlewareTest\RateLimit\RateLimitTest::testAddHeadersForApiKey";d:0.018;s:62:"LosMiddlewareTest\RateLimit\RateLimitTest::testAddHeadersForIp";d:0.017;s:64:"LosMiddlewareTest\RateLimit\RateLimitTest::testDecreaseRemaining";d:0.018;s:58:"LosMiddlewareTest\RateLimit\RateLimitTest::testGenerate429";d:0.022;s:52:"LosMiddlewareTest\RateLimit\RateLimitTest::testReset";d:0.02;}}}
70 changes: 52 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,65 @@
sudo: false

language: php

cache:
directories:
- $HOME/.composer/cache

before_install:
- composer self-update


env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="php-coveralls/php-coveralls"

matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
env:
- DEPS=locked
- php: 7.1
env:
- DEPS=latest
- php: 7.2
env:
- DEPS=lowest
- php: 7.2
env:
- EXECUTE_CS_CHECK=true
- php: 7
- php: hhvm
allow_failures:
- php: hhvm
- DEPS=locked
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.2
env:
- DEPS=latest
- php: 7.3
env:
- DEPS=lowest
- php: 7.3
env:
- DEPS=locked
- php: 7.3
env:
- DEPS=latest

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs --prefer-source
- composer info -i
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update --with-dependencies $COMPOSER_ARGS $LEGACY_DEPS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- stty cols 120 && composer show

script:
- (phpunit -c phpunit.xml)
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- php vendor/bin/coveralls -v
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

notifications:
email: false
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
}
},
"type" : "library",
"config": {
"sort-packages": true
},
"support" : {
"email" : "[email protected]",
"source" : "https://github.com/LansoWeb/LosRateLimit",
Expand All @@ -47,6 +50,9 @@
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"phpstan": "phpstan analyse -l max -c phpstan.neon src"
"phpstan": "phpstan analyse -l max -c phpstan.neon src",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "php-coveralls -v"
}
}
26 changes: 9 additions & 17 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
syntaxCheck="true"
backupGlobals="true"
backupStaticAttributes="false">

<testsuites>
<testsuite name="LosMiddleware\RateLimit Tests">
<directory>./test</directory>
<testsuite name="Base Test Suite">
<directory suffix="Test.php">./test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<php>
<ini name="apc.enable_cli" value="1"/>
</php>

<logging>
<log type="coverage-php" target="build/logs/coverage.php" />
<log type="coverage-xml" target="build/coverage" />
<log type="coverage-html" target="build/logs/report/" charset="UTF-8" yui="true" highlight="true"
<log type="coverage-php" target="./build/logs/coverage.php" />
<log type="coverage-xml" target="./build/coverage" />
<log type="coverage-html" target="./build/logs/report/"
lowUpperBound="50" highLowerBound="90" showUncoveredFiles="true" />
<log type="testdox-html" target="build/logs/testdox.html" />
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-crap4j" target="build/logs/crap4j.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
<log type="testdox-html" target="./build/logs/testdox.html" />
<log type="coverage-clover" target="./build/logs/clover.xml"/>
<log type="coverage-crap4j" target="./build/logs/crap4j.xml"/>
<log type="junit" target="./build/logs/junit.xml" />
</logging>
</phpunit>
Loading

0 comments on commit 6382ca9

Please sign in to comment.