Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
W
WP Redis User Session Storage
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WP Plugins
WP Redis User Session Storage
Compare Revisions
master...add/tests
Source
add/tests
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (4)
Begin tests
· e8c6e567
Erick Hitter
authored
Jun 04, 2019
e8c6e567
Installing PECL Redis per
https://serverpilot.io/docs/how-to-install-the-php-redis-extension
· b6261ee0
Erick Hitter
authored
Jun 04, 2019
b6261ee0
Do we have a config to work with?
· b4ae9cef
Erick Hitter
authored
Jun 04, 2019
b4ae9cef
Set a fake config directory to appease the installer
· 9f05c44c
Erick Hitter
authored
Jun 04, 2019
9f05c44c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
21 deletions
+45
-21
.gitlab-ci.yml
.gitlab-ci.yml
+14
-0
README.md
README.md
+1
-1
inc/class-wp-redis-user-session-storage.php
inc/class-wp-redis-user-session-storage.php
+9
-0
tests/test-plugin.php
tests/test-plugin.php
+21
-0
tests/test-sample.php
tests/test-sample.php
+0
-20
No files found.
.gitlab-ci.yml
View file @
9f05c44c
...
...
@@ -2,6 +2,7 @@ variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE
:
wordpress_tests
MYSQL_ROOT_PASSWORD
:
mysql
PECL_REDIS_VERSION
:
'
redis'
WP_VERSION
:
latest
cache
:
...
...
@@ -13,6 +14,10 @@ before_script:
# Set up WordPress tests
-
bash bin/install-wp-tests.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD mysql $WP_VERSION
true
# Install PECL extension we rely on
-
pecl config-set php_ini /tmp/php.ini
-
yes '' | pecl install -f $PECL_REDIS_VERSION
# PHPUnit
-
|
if [[ $(php -v) =~ "PHP 7." ]]; then
...
...
@@ -25,18 +30,23 @@ PHPunit:PHP5.3:MySQL:
stage
:
test
variables
:
WP_VERSION
:
'
5.1'
PECL_REDIS_VERSION
:
'
redis-2.2.8'
image
:
containers.ethitter.com:443/docker/images/php:5.3
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
PHPunit:PHP5.6:MySQL:
stage
:
test
variables
:
PECL_REDIS_VERSION
:
'
redis-2.2.8'
image
:
containers.ethitter.com:443/docker/images/php:5.6
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
...
...
@@ -46,6 +56,7 @@ PHPunit:PHP7.0:MySQL:
image
:
containers.ethitter.com:443/docker/images/php:7.0
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
...
...
@@ -55,6 +66,7 @@ PHPunit:PHP7.1:MySQL:
image
:
containers.ethitter.com:443/docker/images/php:7.1
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
...
...
@@ -64,6 +76,7 @@ PHPunit:PHP7.2:MySQL:
image
:
containers.ethitter.com:443/docker/images/php:7.2
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
...
...
@@ -73,6 +86,7 @@ PHPunit:PHP7.3:MySQL:
image
:
containers.ethitter.com:443/docker/images/php:7.3
services
:
-
mysql:5.6
-
redis:latest
script
:
-
find . -type "f" -iname "*.php" | xargs -L "1" php -l
-
phpunit
...
...
README.md
View file @
9f05c44c
...
...
@@ -16,7 +16,7 @@ Store WordPress user session tokens in Redis rather than the usermeta table.
## Installation ##
1.
Install and configure Redis. There is a good tutorial
[
here
](
http
://www.saltwebsites.com/2012/install-redis-245-service-centos-6
)
.
1.
Install and configure Redis. There is a good tutorial
[
here
](
http
s://serverpilot.io/docs/how-to-install-the-php-redis-extension
)
.
2.
Install the
[
Redis PECL module
](
http://pecl.php.net/package/redis
)
.
3.
Activate the plugin network-wide or by placing it in
`mu-plugins`
.
4.
By default, the script will connect to Redis at 127.0.0.1:6379. See the
*Connecting to Redis*
section for further options.
...
...
inc/class-wp-redis-user-session-storage.php
View file @
9f05c44c
...
...
@@ -269,6 +269,15 @@ class WP_Redis_User_Session_Storage extends WP_Session_Tokens {
protected
function
get_key
()
{
return
$this
->
prefix
.
':'
.
$this
->
user_id
;
}
/**
* Is Redis connected?
*
* @return bool
*/
public
function
redis_connected
()
{
return
$this
->
redis_connected
;
}
}
/**
...
...
tests/test-plugin.php
0 → 100755
View file @
9f05c44c
<?php
/**
* Plugin tests
*
* @package WP_Redis_User_Session_Storage
*/
/**
* Class Test_Plugin.
*/
class
Test_Plugin
extends
WP_UnitTestCase
{
/**
* Check that Redis backend is available.
*/
public
function
test_connection
()
{
$this
->
assertTrue
(
WP_Session_Tokens
::
get_instance
(
0
)
->
redis_connected
(),
'Failed to assert that Redis is available.'
);
}
}
tests/test-sample.php
deleted
100755 → 0
View file @
8c55298d
<?php
/**
* Class SampleTest
*
* @package WP_Redis_User_Session_Storage
*/
/**
* Sample test case.
*/
class
SampleTest
extends
WP_UnitTestCase
{
/**
* A single example test.
*/
public
function
test_sample
()
{
// Replace this with some actual testing code.
$this
->
assertTrue
(
true
);
}
}