PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / monolog / monolog / tests / Monolog / Handler / RedisPubSubHandlerTest.php

RedisPubSubHandlerTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/monolog/monolog/tests/Monolog/Handler/RedisPubSubHandlerTest.php

77 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /*
6 * This file is part of the Monolog package.
7 *
8 * (c) Jordi Boggiano <[email protected]>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13
14 namespace Monolog\Handler;
15
16 use Monolog\Test\TestCase;
17 use Monolog\Logger;
18 use Monolog\Formatter\LineFormatter;
19
20 class RedisPubSubHandlerTest extends TestCase
21 {
22 public function testConstructorShouldThrowExceptionForInvalidRedis()
23 {
24 $this->expectException(\InvalidArgumentException::class);
25
26 new RedisPubSubHandler(new \stdClass(), 'key');
27 }
28
29 public function testConstructorShouldWorkWithPredis()
30 {
31 $redis = $this->createMock('Predis\Client');
32 $this->assertInstanceof('Monolog\Handler\RedisPubSubHandler', new RedisPubSubHandler($redis, 'key'));
33 }
34
35 public function testConstructorShouldWorkWithRedis()
36 {
37 if (!class_exists('Redis')) {
38 $this->markTestSkipped('The redis ext is required to run this test');
39 }
40
41 $redis = $this->createMock('Redis');
42 $this->assertInstanceof('Monolog\Handler\RedisPubSubHandler', new RedisPubSubHandler($redis, 'key'));
43 }
44
45 public function testPredisHandle()
46 {
47 $redis = $this->prophesize('Predis\Client');
48 $redis->publish('key', 'test')->shouldBeCalled();
49 $redis = $redis->reveal();
50
51 $record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass(), 'foo' => 34]);
52
53 $handler = new RedisPubSubHandler($redis, 'key');
54 $handler->setFormatter(new LineFormatter("%message%"));
55 $handler->handle($record);
56 }
57
58 public function testRedisHandle()
59 {
60 if (!class_exists('Redis')) {
61 $this->markTestSkipped('The redis ext is required to run this test');
62 }
63
64 $redis = $this->createPartialMock('Redis', ['publish']);
65
66 $redis->expects($this->once())
67 ->method('publish')
68 ->with('key', 'test');
69
70 $record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass(), 'foo' => 34]);
71
72 $handler = new RedisPubSubHandler($redis, 'key');
73 $handler->setFormatter(new LineFormatter("%message%"));
74 $handler->handle($record);
75 }
76 }
77