From 7e34eefefccced0814d9fb42962741b20ea98e93 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 30 Jun 2017 17:52:39 +0800 Subject: [PATCH] add redis testing. Signed-off-by: Bo-Yi Wu --- .drone.yml | 1 + .env.example | 4 +-- composer.json | 3 ++- composer.lock | 52 +++++++++++++++++++++++++++++++++++++- phpunit.xml | 2 +- tests/Feature/UserTest.php | 22 +++++++++++++--- 6 files changed, 76 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index a290cc2..e5c5b0a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,6 +20,7 @@ pipeline: commands: - php -v - composer -V + - cp .env.example .env - composer install --prefer-dist - ./vendor/bin/phpunit diff --git a/.env.example b/.env.example index 668c06f..cce942e 100644 --- a/.env.example +++ b/.env.example @@ -14,10 +14,10 @@ DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file -SESSION_DRIVER=file +SESSION_DRIVER=redis QUEUE_DRIVER=sync -REDIS_HOST=127.0.0.1 +REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 diff --git a/composer.json b/composer.json index 0d920cd..abb28ae 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "require": { "php": ">=5.6.4", "laravel/framework": "5.4.*", - "laravel/tinker": "~1.0" + "laravel/tinker": "~1.0", + "predis/predis": "^1.1" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 6e6f578..361185b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "96098e473b028cdb2529580554a1ae3e", + "content-hash": "0b52c14e250aa32e05b69b2daf66787f", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -784,6 +784,56 @@ ], "time": "2017-03-13T16:27:32+00:00" }, + { + "name": "predis/predis", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/nrk/predis.git", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "ext-curl": "Allows access to Webdis when paired with phpiredis", + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + }, + "type": "library", + "autoload": { + "psr-4": { + "Predis\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "description": "Flexible and feature-complete Redis client for PHP and HHVM", + "homepage": "http://github.com/nrk/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ], + "time": "2016-06-16T16:22:20+00:00" + }, { "name": "psr/log", "version": "1.0.2", diff --git a/phpunit.xml b/phpunit.xml index a2c496e..b588418 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -25,7 +25,7 @@ - + diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 9ec8912..921a056 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -3,9 +3,6 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest extends TestCase { @@ -18,4 +15,23 @@ class UserTest extends TestCase { $this->assertTrue(true); } + + /** + * A basic test example. + * + * @return void + */ + public function testRedis() + { + // Retrieve a piece of data from the session... + $value = session('key'); + + // Specifying a default value... + $value = session('key', 'default'); + $this->assertEquals('default', session('key', 'default')); + + // Store a piece of data in the session... + session(['key' => 'value']); + $this->assertEquals('value', session('key', 'default')); + } }