...
 
Commits (4)
......@@ -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
......
......@@ -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](https://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.
......
......@@ -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;
}
}
/**
......
<?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.'
);
}
}
<?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 );
}
}