Skip to content

Commit 59624ed

Browse files
authored
Updates the CI
* adds Travis, Codacy * updates unit tests * updates README
1 parent 4963f8c commit 59624ed

File tree

9 files changed

+87
-42
lines changed

9 files changed

+87
-42
lines changed

.gitattributes

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*.php diff=php
22

3-
/Tests export-ignore
4-
/phpunit.* export-ignore
5-
/*.yml export-ignore
3+
/build export-ignore
4+
/Tests export-ignore
5+
/vendor export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.travis.yml export-ignore
9+
/composer.lock export-ignore
10+
/phpunit.xml export-ignore

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ build
22
vendor
33
.DS_Store
44
.idea
5-
composer.lock
6-
phpunit.phar
7-
*.yml
5+
composer.lock

.travis.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
language: php
2+
3+
sudo: false
4+
5+
notifications:
6+
email: false
7+
8+
cache:
9+
directories:
10+
- $HOME/.composer/cache
11+
12+
services:
13+
- memcached
14+
- redis-server
15+
16+
addons:
17+
hosts:
18+
- redis
19+
- memcached
20+
21+
php:
22+
- 7.2
23+
- 7.3
24+
- nightly
25+
26+
matrix:
27+
fast_finish: true
28+
allow_failures:
29+
- php: nightly
30+
31+
before_install:
32+
- echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
33+
- echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
34+
35+
install:
36+
- composer update -o --no-interaction --ignore-platform-reqs
37+
38+
before_script:
39+
- redis-cli ping
40+
41+
script:
42+
- vendor/bin/phpunit --coverage-clover build/coverage/clover.xml
43+
44+
after_success:
45+
- travis_retry php vendor/bin/codacycoverage clover build/coverage/clover.xml

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Koded Session
22
=============
33

44
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1.4-8892BF.svg)](https://php.net/)
5-
[![Build Status](https://scrutinizer-ci.com/g/kodedphp/session/badges/build.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/session/build-status/master)
6-
[![Code Coverage](https://scrutinizer-ci.com/g/kodedphp/session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/session/?branch=master)
7-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kodedphp/session/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/session/?branch=master)
85
[![Latest Stable Version](https://img.shields.io/packagist/v/koded/session.svg)](https://packagist.org/packages/koded/session)
6+
[![Build Status](https://travis-ci.org/kodedphp/session.svg?branch=master)](https://travis-ci.org/kodedphp/session)
7+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/358e1c798c0c4af8bec25a0adb2671e2)](https://www.codacy.com/app/kodeart/session)
8+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/358e1c798c0c4af8bec25a0adb2671e2)](https://www.codacy.com/app/kodeart/session)
99
[![Software license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
1010

1111

@@ -75,7 +75,7 @@ handler which is the PHP's default session mechanism.
7575
However, the `files` handler might not be desirable if your application
7676
runs in Docker, Kubernetes, distributed environment, etc.
7777

78-
The best choice for PHP sessions is Redis in almost all situations.
78+
> The best choice for PHP sessions is Redis in almost all situations.
7979
8080
WARNING: Memcached may drop the session data, because it's nature. Use it with caution!
8181

@@ -102,10 +102,10 @@ Redis handler
102102
```
103103

104104
A typical Redis settings:
105-
- 1 server
106-
- application + redis on the same machine
107-
- Redis (127.0.0.1:6379)
108-
- no auth (Redis is not available from outside)
105+
- 1 server
106+
- application + redis on the same machine
107+
- Redis (127.0.0.1:6379)
108+
- no auth (Redis is not available from outside)
109109

110110
```php
111111
[
@@ -150,9 +150,9 @@ Memcached handler
150150
```
151151

152152
A typical Memcached settings:
153-
- 1 server
154-
- application + memcached on the same machine
155-
- Memcached (127.0.0.1:11211)
153+
- 1 server
154+
- application + memcached on the same machine
155+
- Memcached (127.0.0.1:11211)
156156

157157
```php
158158
[

Tests/FunctionsTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,23 @@ public function test_should_register_session_cookie()
4444

4545
session_register_custom_handler($config);
4646

47-
$this->assertEquals([
48-
'lifetime' => 120,
49-
'path' => '/tmp',
50-
'domain' => '',
51-
'secure' => true,
52-
'httponly' => true,
53-
'samesite' => '',
54-
], session_get_cookie_params());
47+
if (version_compare(PHP_MINOR_VERSION, '3', '<')) {
48+
$this->assertEquals([
49+
'lifetime' => 120,
50+
'path' => '/tmp',
51+
'domain' => '',
52+
'secure' => true,
53+
'httponly' => true,
54+
], session_get_cookie_params());
55+
} else {
56+
$this->assertEquals([
57+
'lifetime' => 120,
58+
'path' => '/tmp',
59+
'domain' => '',
60+
'secure' => true,
61+
'httponly' => true,
62+
'samesite' => '',
63+
], session_get_cookie_params());
64+
}
5565
}
5666
}

Tests/Handler/MemcachedHandlerTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ protected function setUp()
1717
$this->markTestSkipped('Memcached extension is not loaded');
1818
}
1919

20-
if (defined('CI')) {
21-
$this->markTestSkipped('Memcached tests are temporarily skipped');
22-
}
23-
2420
$config = (new Config)->import([
2521
'session' => [
2622
'name' => 'test',

Tests/Handler/RedisHandlerTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ protected function setUp()
2727
'cache_limiter' => '',
2828
'gc_maxlifetime' => 60,
2929

30-
'host' => getenv('REDIS_SERVER_HOST'),
30+
'host' => 'redis'
3131
]
3232
]);
3333

34-
if (defined('CI')) {
35-
$config->set('host', '127.0.0.1');
36-
}
37-
3834
$settings = session_register_custom_handler($config);
3935
session_start($settings->sessionParameters());
4036

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.3.5",
19+
"php": "~7.3",
2020
"psr/http-server-middleware": "~1",
2121
"koded/cache-simple": "dev-2.0-dev",
2222
"koded/http": "dev-master",
@@ -43,7 +43,8 @@
4343
}
4444
},
4545
"require-dev": {
46-
"phpunit/phpunit": "~7"
46+
"phpunit/phpunit": "~7",
47+
"codacy/coverage": "dev-master"
4748
},
4849
"minimum-stability": "dev",
4950
"extra": {

phpunit.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
<ini name="date.timezone" value="UTC"/>
2929
<ini name="session.cookie_lifetime" value="42"/>
3030

31-
<env name="REDIS_SERVER_HOST" value="redis"/>
32-
3331
<server name="HTTP_USER_AGENT" value="Koded/Session"/>
3432
</php>
35-
36-
<logging>
37-
<log type="coverage-clover" target="build/logs/clover.xml"/>
38-
</logging>
3933
</phpunit>

0 commit comments

Comments
 (0)