Version Description
- 2019-04-15
Download this release
Release Info
Developer | codeinwp |
Plugin | Revive Old Posts – Auto Post to Social Media |
Version | 8.2.4 |
Comparing to | |
See all releases |
Code changes from version 8.2.3 to 8.2.4
- CHANGELOG.md +4 -0
- includes/admin/abstract/class-rop-services-abstract.php +1 -0
- includes/admin/class-rop-admin.php +3 -1
- includes/admin/class-rop-pointers.php +3 -1
- includes/class-rop.php +1 -1
- readme.md +5 -0
- readme.txt +5 -0
- themeisle-hash.json +1 -1
- tweet-old-post.php +2 -2
- vendor/abraham/twitteroauth/composer.json +0 -34
- vendor/abraham/twitteroauth/phpunit.xml +0 -11
- vendor/abraham/twitteroauth/tests/AbstractSignatureMethodTest.php +0 -51
- vendor/abraham/twitteroauth/tests/ConsumerTest.php +0 -17
- vendor/abraham/twitteroauth/tests/HmacSha1Test.php +0 -35
- vendor/abraham/twitteroauth/tests/TokenTest.php +0 -27
- vendor/abraham/twitteroauth/tests/TwitterOAuthTest.php +0 -297
- vendor/abraham/twitteroauth/tests/Util/JsonDecoderTest.php +0 -50
- vendor/abraham/twitteroauth/tests/bootstrap.php +0 -4
- vendor/abraham/twitteroauth/tests/kitten.jpg +0 -0
- vendor/abraham/twitteroauth/tests/sample_env +0 -13
- vendor/abraham/twitteroauth/tests/scripts/cacert.sh +0 -17
- vendor/abraham/twitteroauth/tests/vars.php +0 -10
- vendor/abraham/twitteroauth/tests/video.mp4 +0 -0
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +5 -5
- vendor/facebook/graph-sdk/composer.json +0 -42
- vendor/monolog/monolog/composer.json +0 -66
- vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php +0 -31
- vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php +0 -158
- vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php +0 -79
- vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php +0 -55
- vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php +0 -62
- vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php +0 -258
- vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php +0 -219
- vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php +0 -222
- vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php +0 -40
- vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php +0 -333
- vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php +0 -262
- vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php +0 -481
- vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php +0 -110
- vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php +0 -142
- vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php +0 -115
- vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php +0 -80
- vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php +0 -136
- vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php +0 -130
- vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php +0 -158
- vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php +0 -156
- vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php +0 -31
- vendor/monolog/monolog/tests/Monolog/Handler/DeduplicationHandlerTest.php +0 -165
- vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php +0 -52
- vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php +0 -82
- vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php +0 -239
- vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php +0 -66
- vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php +0 -170
- vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php +0 -279
- vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php +0 -96
- vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php +0 -85
- vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php +0 -88
- vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php +0 -95
- vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php +0 -117
- vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php +0 -25
- vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php +0 -112
- vendor/monolog/monolog/tests/Monolog/Handler/HandlerWrapperTest.php +0 -130
- vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php +0 -279
- vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php +0 -80
- vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php +0 -84
- vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php +0 -75
- vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php +0 -27
- vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php +0 -65
- vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php +0 -111
- vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php +0 -200
- vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php +0 -33
- vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php +0 -273
- vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php +0 -50
- vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php +0 -141
- vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php +0 -255
- vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php +0 -127
- vendor/monolog/monolog/tests/Monolog/Handler/RollbarHandlerTest.php +0 -84
- vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php +0 -245
- vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php +0 -33
- vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php +0 -395
- vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php +0 -155
- vendor/monolog/monolog/tests/Monolog/Handler/SlackWebhookHandlerTest.php +0 -107
- vendor/monolog/monolog/tests/Monolog/Handler/SlackbotHandlerTest.php +0 -47
- vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php +0 -335
- vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php +0 -184
- vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php +0 -113
- vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php +0 -44
- vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php +0 -76
- vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php +0 -116
- vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php +0 -64
- vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php +0 -144
- vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php +0 -69
- vendor/monolog/monolog/tests/Monolog/LoggerTest.php +0 -690
- vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php +0 -29
- vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php +0 -123
- vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php +0 -42
- vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php +0 -42
- vendor/monolog/monolog/tests/Monolog/Processor/MercurialProcessorTest.php +0 -41
- vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php +0 -30
- vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php +0 -43
- vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php +0 -49
- vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php +0 -33
- vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php +0 -113
- vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php +0 -47
- vendor/monolog/monolog/tests/Monolog/RegistryTest.php +0 -153
- vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php +0 -287
- vendor/monolog/monolog/tests/Monolog/TestCase.php +0 -58
- vendor/psr/log/composer.json +0 -26
CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
2 |
### v8.2.3 - 2019-04-10
|
3 |
**Changes:**
|
4 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
1 |
|
2 |
+
### v8.2.4 - 2019-04-15
|
3 |
+
**Changes:**
|
4 |
+
* Fix: Minor bugs
|
5 |
+
|
6 |
### v8.2.3 - 2019-04-10
|
7 |
**Changes:**
|
8 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
includes/admin/abstract/class-rop-services-abstract.php
CHANGED
@@ -490,6 +490,7 @@ abstract class Rop_Services_Abstract {
|
|
490 |
'Desktop applications only support the oauth_callback value' => 'https://is.gd/fix_oauth_callback_value',
|
491 |
'User is over daily status update limit' => 'https://is.gd/fix_over_daily_limit',
|
492 |
'Invalid media_id: Some' => 'https://is.gd/fix_invalid_media',
|
|
|
493 |
|
494 |
// LinkedIn errors
|
495 |
''submitted-url' can not be empty' => 'https://is.gd/fix_link_issue',
|
490 |
'Desktop applications only support the oauth_callback value' => 'https://is.gd/fix_oauth_callback_value',
|
491 |
'User is over daily status update limit' => 'https://is.gd/fix_over_daily_limit',
|
492 |
'Invalid media_id: Some' => 'https://is.gd/fix_invalid_media',
|
493 |
+
'Callback URL not approved for this client application' => 'https://is.gd/fix_oauth_callback_value',
|
494 |
|
495 |
// LinkedIn errors
|
496 |
''submitted-url' can not be empty' => 'https://is.gd/fix_link_issue',
|
includes/admin/class-rop-admin.php
CHANGED
@@ -688,6 +688,8 @@ class Rop_Admin {
|
|
688 |
return;
|
689 |
}
|
690 |
|
|
|
|
|
691 |
$services_model = new Rop_Services_Model();
|
692 |
|
693 |
$services = $services_model->get_authenticated_services();
|
@@ -700,7 +702,7 @@ class Rop_Admin {
|
|
700 |
}
|
701 |
}
|
702 |
|
703 |
-
if (
|
704 |
return;
|
705 |
}
|
706 |
|
688 |
return;
|
689 |
}
|
690 |
|
691 |
+
$show_notice = false;
|
692 |
+
|
693 |
$services_model = new Rop_Services_Model();
|
694 |
|
695 |
$services = $services_model->get_authenticated_services();
|
702 |
}
|
703 |
}
|
704 |
|
705 |
+
if ( $show_notice == false ) {
|
706 |
return;
|
707 |
}
|
708 |
|
includes/admin/class-rop-pointers.php
CHANGED
@@ -376,7 +376,9 @@ class Rop_Pointers {
|
|
376 |
*/
|
377 |
public function rop_enqueue_pointers() {
|
378 |
|
379 |
-
|
|
|
|
|
380 |
return;
|
381 |
}
|
382 |
|
376 |
*/
|
377 |
public function rop_enqueue_pointers() {
|
378 |
|
379 |
+
$screen = get_current_screen();
|
380 |
+
|
381 |
+
if ( empty( $screen ) ) {
|
382 |
return;
|
383 |
}
|
384 |
|
includes/class-rop.php
CHANGED
@@ -68,7 +68,7 @@ class Rop {
|
|
68 |
public function __construct() {
|
69 |
|
70 |
$this->plugin_name = 'rop';
|
71 |
-
$this->version = '8.2.
|
72 |
|
73 |
$this->load_dependencies();
|
74 |
$this->set_locale();
|
68 |
public function __construct() {
|
69 |
|
70 |
$this->plugin_name = 'rop';
|
71 |
+
$this->version = '8.2.4';
|
72 |
|
73 |
$this->load_dependencies();
|
74 |
$this->set_locale();
|
readme.md
CHANGED
@@ -134,6 +134,11 @@ http://revive.social/plugins/revive-old-post
|
|
134 |
|
135 |
|
136 |
## Changelog ##
|
|
|
|
|
|
|
|
|
|
|
137 |
### 8.2.3 - 2019-04-10 ###
|
138 |
|
139 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
134 |
|
135 |
|
136 |
## Changelog ##
|
137 |
+
### 8.2.4 - 2019-04-15 ###
|
138 |
+
|
139 |
+
* Fix: Minor bugs
|
140 |
+
|
141 |
+
|
142 |
### 8.2.3 - 2019-04-10 ###
|
143 |
|
144 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
readme.txt
CHANGED
@@ -134,6 +134,11 @@ http://revive.social/plugins/revive-old-post
|
|
134 |
|
135 |
|
136 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
137 |
= 8.2.3 - 2019-04-10 =
|
138 |
|
139 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
134 |
|
135 |
|
136 |
== Changelog ==
|
137 |
+
= 8.2.4 - 2019-04-15 =
|
138 |
+
|
139 |
+
* Fix: Minor bugs
|
140 |
+
|
141 |
+
|
142 |
= 8.2.3 - 2019-04-10 =
|
143 |
|
144 |
* New: Filter introduced for Post Title & Content separator (check revive.social docs)
|
themeisle-hash.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"class-rop-autoloader.php":"7bfbb1554230d0ace777adb2e42bebeb","index.php":"39ab8276fb0e4bd3fcab3270822c5977","tweet-old-post.php":"
|
1 |
+
{"class-rop-autoloader.php":"7bfbb1554230d0ace777adb2e42bebeb","index.php":"39ab8276fb0e4bd3fcab3270822c5977","tweet-old-post.php":"65d39a7cba7eded4172f2f89e42b9ad6","uninstall.php":"5c68258039522cc06b0cf2108e735c4f"}
|
tweet-old-post.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: Revive Old Posts
|
17 |
* Plugin URI: https://revive.social/
|
18 |
* Description: WordPress plugin that helps you to keeps your old posts alive by sharing them and driving more traffic to them from twitter/facebook or linkedin. It also helps you to promote your content. You can set time and no of posts to share to drive more traffic.For questions, comments, or feature requests, <a href="http://revive.social/support/?utm_source=plugindesc&utm_medium=announce&utm_campaign=top">contact </a> us!
|
19 |
-
* Version: 8.2.
|
20 |
* Author: revive.social
|
21 |
* Author URI: https://revive.social/
|
22 |
* Requires at least: 3.5
|
@@ -98,7 +98,7 @@ function run_rop() {
|
|
98 |
}
|
99 |
|
100 |
define( 'ROP_PRO_URL', 'http://revive.social/plugins/revive-old-post/' );
|
101 |
-
define( 'ROP_LITE_VERSION', '8.2.
|
102 |
define( 'ROP_LITE_BASE_FILE', __FILE__ );
|
103 |
define( 'ROP_DEBUG', false );
|
104 |
define( 'ROP_LITE_PATH', plugin_dir_path( __FILE__ ) );
|
16 |
* Plugin Name: Revive Old Posts
|
17 |
* Plugin URI: https://revive.social/
|
18 |
* Description: WordPress plugin that helps you to keeps your old posts alive by sharing them and driving more traffic to them from twitter/facebook or linkedin. It also helps you to promote your content. You can set time and no of posts to share to drive more traffic.For questions, comments, or feature requests, <a href="http://revive.social/support/?utm_source=plugindesc&utm_medium=announce&utm_campaign=top">contact </a> us!
|
19 |
+
* Version: 8.2.4
|
20 |
* Author: revive.social
|
21 |
* Author URI: https://revive.social/
|
22 |
* Requires at least: 3.5
|
98 |
}
|
99 |
|
100 |
define( 'ROP_PRO_URL', 'http://revive.social/plugins/revive-old-post/' );
|
101 |
+
define( 'ROP_LITE_VERSION', '8.2.4' );
|
102 |
define( 'ROP_LITE_BASE_FILE', __FILE__ );
|
103 |
define( 'ROP_DEBUG', false );
|
104 |
define( 'ROP_LITE_PATH', plugin_dir_path( __FILE__ ) );
|
vendor/abraham/twitteroauth/composer.json
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "abraham/twitteroauth",
|
3 |
-
"type": "library",
|
4 |
-
"description": "The most popular PHP library for use with the Twitter OAuth REST API.",
|
5 |
-
"keywords": ["twitter", "api", "oauth", "rest", "social", "twitter api", "twitter oauth"],
|
6 |
-
"license": "MIT",
|
7 |
-
"homepage": "https://twitteroauth.com",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Abraham Williams",
|
11 |
-
"email": "abraham@abrah.am",
|
12 |
-
"homepage": "https://abrah.am",
|
13 |
-
"role": "Developer"
|
14 |
-
}
|
15 |
-
],
|
16 |
-
"support": {
|
17 |
-
"source": "https://github.com/abraham/twitteroauth",
|
18 |
-
"issues": "https://github.com/abraham/twitteroauth/issues"
|
19 |
-
},
|
20 |
-
"require": {
|
21 |
-
"php": "^5.6 || ^7.0 || ^7.1 || ^7.2",
|
22 |
-
"ext-curl": "*"
|
23 |
-
},
|
24 |
-
"require-dev": {
|
25 |
-
"phpunit/phpunit": "~5.7",
|
26 |
-
"squizlabs/php_codesniffer": "~3.0",
|
27 |
-
"phpmd/phpmd": "~2.6"
|
28 |
-
},
|
29 |
-
"autoload": {
|
30 |
-
"psr-4": {
|
31 |
-
"Abraham\\TwitterOAuth\\": "src"
|
32 |
-
}
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/phpunit.xml
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<phpunit
|
3 |
-
colors="true"
|
4 |
-
bootstrap="tests/bootstrap.php">
|
5 |
-
|
6 |
-
<testsuites>
|
7 |
-
<testsuite name="TwitterOAuth Test Suite">
|
8 |
-
<directory>./tests/</directory>
|
9 |
-
</testsuite>
|
10 |
-
</testsuites>
|
11 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/AbstractSignatureMethodTest.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Abraham\TwitterOAuth\Tests;
|
4 |
-
|
5 |
-
use Abraham\TwitterOAuth\SignatureMethod;
|
6 |
-
|
7 |
-
abstract class AbstractSignatureMethodTest extends \PHPUnit_Framework_TestCase
|
8 |
-
{
|
9 |
-
protected $name;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @return SignatureMethod
|
13 |
-
*/
|
14 |
-
abstract public function getClass();
|
15 |
-
|
16 |
-
abstract protected function signatureDataProvider();
|
17 |
-
|
18 |
-
public function testGetName()
|
19 |
-
{
|
20 |
-
$this->assertEquals($this->name, $this->getClass()->getName());
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @dataProvider signatureDataProvider
|
25 |
-
*/
|
26 |
-
public function testBuildSignature($expected, $request, $consumer, $token)
|
27 |
-
{
|
28 |
-
$this->assertEquals($expected, $this->getClass()->buildSignature($request, $consumer, $token));
|
29 |
-
}
|
30 |
-
|
31 |
-
protected function getRequest()
|
32 |
-
{
|
33 |
-
return $this->getMockBuilder('Abraham\TwitterOAuth\Request')
|
34 |
-
->disableOriginalConstructor()
|
35 |
-
->getMock();
|
36 |
-
}
|
37 |
-
|
38 |
-
protected function getConsumer($key = null, $secret = null, $callbackUrl = null)
|
39 |
-
{
|
40 |
-
return $this->getMockBuilder('Abraham\TwitterOAuth\Consumer')
|
41 |
-
->setConstructorArgs([$key, $secret, $callbackUrl])
|
42 |
-
->getMock();
|
43 |
-
}
|
44 |
-
|
45 |
-
protected function getToken($key = null, $secret = null)
|
46 |
-
{
|
47 |
-
return $this->getMockBuilder('Abraham\TwitterOAuth\Token')
|
48 |
-
->setConstructorArgs([$key, $secret])
|
49 |
-
->getMock();
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/ConsumerTest.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Abraham\TwitterOAuth\Tests;
|
4 |
-
|
5 |
-
use Abraham\TwitterOAuth\Consumer;
|
6 |
-
|
7 |
-
class ConsumerTest extends \PHPUnit_Framework_TestCase
|
8 |
-
{
|
9 |
-
public function testToString()
|
10 |
-
{
|
11 |
-
$key = uniqid();
|
12 |
-
$secret = uniqid();
|
13 |
-
$consumer = new Consumer($key, $secret);
|
14 |
-
|
15 |
-
$this->assertEquals("Consumer[key=$key,secret=$secret]", $consumer->__toString());
|
16 |
-
}
|
17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/HmacSha1Test.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Abraham\TwitterOAuth\Tests;
|
4 |
-
|
5 |
-
use Abraham\TwitterOAuth\HmacSha1;
|
6 |
-
|
7 |
-
class HmacSha1Test extends AbstractSignatureMethodTest
|
8 |
-
{
|
9 |
-
protected $name = 'HMAC-SHA1';
|
10 |
-
|
11 |
-
public function getClass()
|
12 |
-
{
|
13 |
-
return new HmacSha1();
|
14 |
-
}
|
15 |
-
|
16 |
-
public function signatureDataProvider()
|
17 |
-
{
|
18 |
-
return [
|
19 |
-
['5CoEcoq7XoKFjwYCieQvuzadeUA=', $this->getRequest(), $this->getConsumer(), $this->getToken()],
|
20 |
-
[
|
21 |
-
'EBw0gHngam3BTx8kfPfNNSyKem4=',
|
22 |
-
$this->getRequest(),
|
23 |
-
$this->getConsumer('key', 'secret'),
|
24 |
-
$this->getToken()
|
25 |
-
],
|
26 |
-
[
|
27 |
-
'kDsHFZzws2a5M6cAQjfpdNBo+v8=',
|
28 |
-
$this->getRequest(),
|
29 |
-
$this->getConsumer('key', 'secret'),
|
30 |
-
$this->getToken('key', 'secret')
|
31 |
-
],
|
32 |
-
['EBw0gHngam3BTx8kfPfNNSyKem4=', $this->getRequest(), $this->getConsumer('key', 'secret'), null],
|
33 |
-
];
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/TokenTest.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Abraham\TwitterOAuth\Tests;
|
4 |
-
|
5 |
-
use Abraham\TwitterOAuth\Token;
|
6 |
-
|
7 |
-
class TokenTest extends \PHPUnit_Framework_TestCase
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* @dataProvider tokenProvider
|
11 |
-
*/
|
12 |
-
public function testToString($expected, $key, $secret)
|
13 |
-
{
|
14 |
-
$token = new Token($key, $secret);
|
15 |
-
|
16 |
-
$this->assertEquals($expected, $token->__toString());
|
17 |
-
}
|
18 |
-
|
19 |
-
public function tokenProvider()
|
20 |
-
{
|
21 |
-
return [
|
22 |
-
['oauth_token=key&oauth_token_secret=secret', 'key', 'secret'],
|
23 |
-
['oauth_token=key%2Bkey&oauth_token_secret=secret', 'key+key', 'secret'],
|
24 |
-
['oauth_token=key~key&oauth_token_secret=secret', 'key~key', 'secret'],
|
25 |
-
];
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/TwitterOAuthTest.php
DELETED
@@ -1,297 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WARNING: Running these tests will post and delete through the actual Twitter account.
|
4 |
-
*/
|
5 |
-
namespace Abraham\TwitterOAuth\Test;
|
6 |
-
|
7 |
-
use Abraham\TwitterOAuth\TwitterOAuth;
|
8 |
-
|
9 |
-
class TwitterOAuthTest extends \PHPUnit_Framework_TestCase
|
10 |
-
{
|
11 |
-
/** @var TwitterOAuth */
|
12 |
-
protected $twitter;
|
13 |
-
|
14 |
-
protected function setUp()
|
15 |
-
{
|
16 |
-
$this->twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
|
17 |
-
$this->userId = explode('-', ACCESS_TOKEN)[0];
|
18 |
-
}
|
19 |
-
|
20 |
-
public function testBuildClient()
|
21 |
-
{
|
22 |
-
$this->assertObjectHasAttribute('consumer', $this->twitter);
|
23 |
-
$this->assertObjectHasAttribute('token', $this->twitter);
|
24 |
-
}
|
25 |
-
|
26 |
-
public function testSetOauthToken()
|
27 |
-
{
|
28 |
-
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
29 |
-
$twitter->setOauthToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
|
30 |
-
$this->assertObjectHasAttribute('consumer', $twitter);
|
31 |
-
$this->assertObjectHasAttribute('token', $twitter);
|
32 |
-
$twitter->get('friendships/show', ['target_screen_name' => 'twitterapi']);
|
33 |
-
$this->assertEquals(200, $twitter->getLastHttpCode());
|
34 |
-
}
|
35 |
-
|
36 |
-
public function testOauth2Token()
|
37 |
-
{
|
38 |
-
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
39 |
-
$result = $twitter->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
|
40 |
-
$this->assertEquals(200, $twitter->getLastHttpCode());
|
41 |
-
$this->assertObjectHasAttribute('token_type', $result);
|
42 |
-
$this->assertObjectHasAttribute('access_token', $result);
|
43 |
-
$this->assertEquals('bearer', $result->token_type);
|
44 |
-
return $result;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @depends testOauth2Token
|
49 |
-
*/
|
50 |
-
public function testBearerToken($accessToken)
|
51 |
-
{
|
52 |
-
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, null, $accessToken->access_token);
|
53 |
-
$result = $twitter->get('statuses/user_timeline', ['screen_name' => 'twitterapi']);
|
54 |
-
if ($twitter->getLastHttpCode() !== 200) {
|
55 |
-
$this->assertEquals('foo', substr($accessToken->access_token, 0, 75));
|
56 |
-
$this->assertEquals('foo', print_r($result, true));
|
57 |
-
}
|
58 |
-
$this->assertEquals(200, $twitter->getLastHttpCode());
|
59 |
-
return $accessToken;
|
60 |
-
}
|
61 |
-
|
62 |
-
// This causes issues for parallel run tests.
|
63 |
-
// /**
|
64 |
-
// * @depends testBearerToken
|
65 |
-
// */
|
66 |
-
// public function testOauth2TokenInvalidate($accessToken)
|
67 |
-
// {
|
68 |
-
// $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
69 |
-
// // HACK: access_token is already urlencoded but gets urlencoded again breaking the invalidate request.
|
70 |
-
// $result = $twitter->oauth2(
|
71 |
-
// 'oauth2/invalidate_token',
|
72 |
-
// array('access_token' => urldecode($accessToken->access_token))
|
73 |
-
// );
|
74 |
-
// $this->assertEquals(200, $twitter->getLastHttpCode());
|
75 |
-
// $this->assertObjectHasAttribute('access_token', $result);
|
76 |
-
// return $result;
|
77 |
-
// }
|
78 |
-
|
79 |
-
public function testOauthRequestToken()
|
80 |
-
{
|
81 |
-
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
82 |
-
$result = $twitter->oauth('oauth/request_token', ['oauth_callback' => OAUTH_CALLBACK]);
|
83 |
-
$this->assertEquals(200, $twitter->getLastHttpCode());
|
84 |
-
$this->assertArrayHasKey('oauth_token', $result);
|
85 |
-
$this->assertArrayHasKey('oauth_token_secret', $result);
|
86 |
-
$this->assertArrayHasKey('oauth_callback_confirmed', $result);
|
87 |
-
$this->assertEquals('true', $result['oauth_callback_confirmed']);
|
88 |
-
return $result;
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* @expectedException \Abraham\TwitterOAuth\TwitterOAuthException
|
93 |
-
* @expectedExceptionMessage Could not authenticate you
|
94 |
-
*/
|
95 |
-
public function testOauthRequestTokenException()
|
96 |
-
{
|
97 |
-
$twitter = new TwitterOAuth('CONSUMER_KEY', 'CONSUMER_SECRET');
|
98 |
-
$result = $twitter->oauth('oauth/request_token', ['oauth_callback' => OAUTH_CALLBACK]);
|
99 |
-
return $result;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* @expectedException \Abraham\TwitterOAuth\TwitterOAuthException
|
104 |
-
* @expectedExceptionMessage Invalid oauth_verifier parameter
|
105 |
-
* @depends testOauthRequestToken
|
106 |
-
*/
|
107 |
-
public function testOauthAccessTokenTokenException(array $requestToken)
|
108 |
-
{
|
109 |
-
// Can't test this without a browser logging into Twitter so check for the correct error instead.
|
110 |
-
$twitter = new TwitterOAuth(
|
111 |
-
CONSUMER_KEY,
|
112 |
-
CONSUMER_SECRET,
|
113 |
-
$requestToken['oauth_token'],
|
114 |
-
$requestToken['oauth_token_secret']
|
115 |
-
);
|
116 |
-
$twitter->oauth("oauth/access_token", ["oauth_verifier" => "fake_oauth_verifier"]);
|
117 |
-
}
|
118 |
-
|
119 |
-
public function testUrl()
|
120 |
-
{
|
121 |
-
$url = $this->twitter->url('oauth/authorize', ['foo' => 'bar', 'baz' => 'qux']);
|
122 |
-
$this->assertEquals('https://api.twitter.com/oauth/authorize?foo=bar&baz=qux', $url);
|
123 |
-
}
|
124 |
-
|
125 |
-
public function testGetAccountVerifyCredentials()
|
126 |
-
{
|
127 |
-
$user = $this->twitter->get('account/verify_credentials', [
|
128 |
-
'include_entities' => false,
|
129 |
-
'include_email' => true
|
130 |
-
]);
|
131 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
132 |
-
$this->assertObjectHasAttribute('email', $user);
|
133 |
-
}
|
134 |
-
|
135 |
-
// BUG: testing is too unreliable for now
|
136 |
-
// public function testSetProxy()
|
137 |
-
// {
|
138 |
-
// $this->twitter->setProxy(array(
|
139 |
-
// 'CURLOPT_PROXY' => PROXY,
|
140 |
-
// 'CURLOPT_PROXYUSERPWD' => PROXYUSERPWD,
|
141 |
-
// 'CURLOPT_PROXYPORT' => PROXYPORT,
|
142 |
-
// ));
|
143 |
-
// $this->twitter->setTimeouts(60, 60);
|
144 |
-
// $result = $this->twitter->get('account/verify_credentials');
|
145 |
-
// $this->assertEquals(200, $this->twitter->getLastHttpCode());
|
146 |
-
// $this->assertObjectHasAttribute('id', $result);
|
147 |
-
// }
|
148 |
-
|
149 |
-
public function testGetStatusesMentionsTimeline()
|
150 |
-
{
|
151 |
-
$this->twitter->get('statuses/mentions_timeline');
|
152 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
153 |
-
}
|
154 |
-
|
155 |
-
public function testGetSearchTweets()
|
156 |
-
{
|
157 |
-
$result = $this->twitter->get('search/tweets', ['q' => 'twitter']);
|
158 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
159 |
-
return $result->statuses;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @depends testGetSearchTweets
|
164 |
-
*/
|
165 |
-
public function testGetSearchTweetsWithMaxId($statuses)
|
166 |
-
{
|
167 |
-
$maxId = array_pop($statuses)->id_str;
|
168 |
-
$this->twitter->get('search/tweets', ['q' => 'twitter', 'max_id' => $maxId]);
|
169 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
170 |
-
}
|
171 |
-
|
172 |
-
public function testPostFavoritesCreate()
|
173 |
-
{
|
174 |
-
$result = $this->twitter->post('favorites/create', ['id' => '6242973112']);
|
175 |
-
if ($this->twitter->getLastHttpCode() == 403) {
|
176 |
-
// Status already favorited
|
177 |
-
$this->assertEquals(139, $result->errors[0]->code);
|
178 |
-
} else {
|
179 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* @depends testPostFavoritesCreate
|
185 |
-
*/
|
186 |
-
public function testPostFavoritesDestroy()
|
187 |
-
{
|
188 |
-
$this->twitter->post('favorites/destroy', ['id' => '6242973112']);
|
189 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
190 |
-
}
|
191 |
-
|
192 |
-
public function testPostDirectMessagesEventsNew()
|
193 |
-
{
|
194 |
-
$data = [
|
195 |
-
'event' => [
|
196 |
-
'type' => 'message_create',
|
197 |
-
'message_create' => [
|
198 |
-
'target' => [
|
199 |
-
'recipient_id' => $this->userId
|
200 |
-
],
|
201 |
-
'message_data' => [
|
202 |
-
'text' => 'Hello World!'
|
203 |
-
]
|
204 |
-
]
|
205 |
-
]
|
206 |
-
];
|
207 |
-
$result = $this->twitter->post('direct_messages/events/new', $data, true);
|
208 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
209 |
-
return $result;
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* @depends testPostDirectMessagesEventsNew
|
214 |
-
*/
|
215 |
-
public function testDeleteDirectMessagesEventsDestroy($message)
|
216 |
-
{
|
217 |
-
$this->twitter->delete('direct_messages/events/destroy', ['id' => $message->event->id]);
|
218 |
-
$this->assertEquals(204, $this->twitter->getLastHttpCode());
|
219 |
-
}
|
220 |
-
|
221 |
-
public function testPostStatusesUpdateWithMedia()
|
222 |
-
{
|
223 |
-
$this->twitter->setTimeouts(60, 30);
|
224 |
-
// Image source https://www.flickr.com/photos/titrans/8548825587/
|
225 |
-
$file_path = __DIR__ . '/kitten.jpg';
|
226 |
-
$result = $this->twitter->upload('media/upload', ['media' => $file_path]);
|
227 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
228 |
-
$this->assertObjectHasAttribute('media_id_string', $result);
|
229 |
-
$parameters = ['status' => 'Hello World ' . time(), 'media_ids' => $result->media_id_string];
|
230 |
-
$result = $this->twitter->post('statuses/update', $parameters);
|
231 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
232 |
-
if ($this->twitter->getLastHttpCode() == 200) {
|
233 |
-
$result = $this->twitter->post('statuses/destroy/' . $result->id_str);
|
234 |
-
}
|
235 |
-
return $result;
|
236 |
-
}
|
237 |
-
|
238 |
-
public function testPostStatusUpdateWithInvalidMediaThrowsException()
|
239 |
-
{
|
240 |
-
$this->expectException(\InvalidArgumentException::class);
|
241 |
-
$file_path = __DIR__ . '/12345678900987654321.jpg';
|
242 |
-
$this->assertFalse(\is_readable($file_path));
|
243 |
-
$result = $this->twitter->upload('media/upload', ['media' => $file_path]);
|
244 |
-
}
|
245 |
-
|
246 |
-
public function testPostStatusesUpdateWithMediaChunked()
|
247 |
-
{
|
248 |
-
$this->twitter->setTimeouts(60, 30);
|
249 |
-
// Video source http://www.sample-videos.com/
|
250 |
-
$file_path = __DIR__ . '/video.mp4';
|
251 |
-
$result = $this->twitter->upload('media/upload', ['media' => $file_path, 'media_type' => 'video/mp4'], true);
|
252 |
-
$this->assertEquals(201, $this->twitter->getLastHttpCode());
|
253 |
-
$this->assertObjectHasAttribute('media_id_string', $result);
|
254 |
-
$parameters = ['status' => 'Hello World ' . time(), 'media_ids' => $result->media_id_string];
|
255 |
-
$result = $this->twitter->post('statuses/update', $parameters);
|
256 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
257 |
-
if ($this->twitter->getLastHttpCode() == 200) {
|
258 |
-
$result = $this->twitter->post('statuses/destroy/' . $result->id_str);
|
259 |
-
}
|
260 |
-
return $result;
|
261 |
-
}
|
262 |
-
|
263 |
-
public function testPostStatusesUpdateUtf8()
|
264 |
-
{
|
265 |
-
$result = $this->twitter->post('statuses/update', ['status' => 'xこんにちは世界 ' . time()]);
|
266 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
267 |
-
return $result;
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* @depends testPostStatusesUpdateUtf8
|
272 |
-
*/
|
273 |
-
public function testPostStatusesDestroy($status)
|
274 |
-
{
|
275 |
-
$this->twitter->post('statuses/destroy/' . $status->id_str);
|
276 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
277 |
-
}
|
278 |
-
|
279 |
-
public function testLastResult()
|
280 |
-
{
|
281 |
-
$this->twitter->get('search/tweets', ['q' => 'twitter']);
|
282 |
-
$this->assertEquals('search/tweets', $this->twitter->getLastApiPath());
|
283 |
-
$this->assertEquals(200, $this->twitter->getLastHttpCode());
|
284 |
-
$this->assertObjectHasAttribute('statuses', $this->twitter->getLastBody());
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* @depends testLastResult
|
289 |
-
*/
|
290 |
-
public function testResetLastResponse()
|
291 |
-
{
|
292 |
-
$this->twitter->resetLastResponse();
|
293 |
-
$this->assertEquals('', $this->twitter->getLastApiPath());
|
294 |
-
$this->assertEquals(0, $this->twitter->getLastHttpCode());
|
295 |
-
$this->assertEquals([], $this->twitter->getLastBody());
|
296 |
-
}
|
297 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/Util/JsonDecoderTest.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Abraham\TwitterOAuth\Tests;
|
4 |
-
|
5 |
-
use Abraham\TwitterOAuth\Util\JsonDecoder;
|
6 |
-
|
7 |
-
class JsonDecoderTest extends \PHPUnit_Framework_TestCase
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* @dataProvider jsonProvider
|
11 |
-
*/
|
12 |
-
public function testDecode($input, $asArray, $expected)
|
13 |
-
{
|
14 |
-
$this->assertEquals($expected, JsonDecoder::decode($input, $asArray));
|
15 |
-
}
|
16 |
-
|
17 |
-
public function jsonProvider()
|
18 |
-
{
|
19 |
-
return [
|
20 |
-
['[]', true, []],
|
21 |
-
['[1,2,3]', true, [1, 2, 3]],
|
22 |
-
['[{"id": 556179961825226750}]', true, [['id' => 556179961825226750]]],
|
23 |
-
['[]', false, []],
|
24 |
-
['[1,2,3]', false, [1, 2, 3]],
|
25 |
-
[
|
26 |
-
'[{"id": 556179961825226750}]',
|
27 |
-
false,
|
28 |
-
[
|
29 |
-
$this->getClass(function ($object) {
|
30 |
-
$object->id = 556179961825226750;
|
31 |
-
return $object;
|
32 |
-
})
|
33 |
-
]
|
34 |
-
],
|
35 |
-
|
36 |
-
];
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @param callable $callable
|
41 |
-
*
|
42 |
-
* @return stdClass
|
43 |
-
*/
|
44 |
-
private function getClass(\Closure $callable)
|
45 |
-
{
|
46 |
-
$object = new \stdClass();
|
47 |
-
|
48 |
-
return $callable($object);
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/bootstrap.php
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require __DIR__ . '/../vendor/autoload.php';
|
4 |
-
require 'vars.php';
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/kitten.jpg
DELETED
Binary file
|
vendor/abraham/twitteroauth/tests/sample_env
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
# WARNING: Running the tests will perform live actions as the Twitter account.
|
2 |
-
# Set all values, move to `env`, run `source tests/env` and `phpunit` to start testing.
|
3 |
-
|
4 |
-
# To run the tests you must register Twitter application at https://app.twitter.com/.
|
5 |
-
export TEST_CONSUMER_KEY=
|
6 |
-
export TEST_CONSUMER_SECRET=
|
7 |
-
export TEST_ACCESS_TOKEN=
|
8 |
-
export TEST_ACCESS_TOKEN_SECRET=
|
9 |
-
export TEST_OAUTH_CALLBACK=
|
10 |
-
# You can find proxies for testing at http://proxylist.hidemyass.com/.
|
11 |
-
export TEST_CURLOPT_PROXY=
|
12 |
-
export TEST_CURLOPT_PROXYUSERPWD=
|
13 |
-
export TEST_CURLOPT_PROXYPORT=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/scripts/cacert.sh
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
CURRENT_COMMAND="$(curl -s "https://curl.haxx.se/ca/cacert.pem.sha256")"
|
4 |
-
CURRENT_PARTS=($CURRENT_COMMAND)
|
5 |
-
CURRENT_SHA="${CURRENT_PARTS[0]}"
|
6 |
-
|
7 |
-
FILE_COMMAND="$(openssl sha -sha256 src/cacert.pem)"
|
8 |
-
FILE_PARTS=($FILE_COMMAND)
|
9 |
-
FILE_SHA="${FILE_PARTS[1]}"
|
10 |
-
|
11 |
-
if [ "$FILE_SHA" = "$CURRENT_SHA" ]; then
|
12 |
-
echo "cacert.pem is current"
|
13 |
-
exit 0
|
14 |
-
fi
|
15 |
-
|
16 |
-
echo "cacert.pem needs to be updated."
|
17 |
-
exit 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/vars.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
define('CONSUMER_KEY', getenv('TEST_CONSUMER_KEY'));
|
4 |
-
define('CONSUMER_SECRET', getenv('TEST_CONSUMER_SECRET'));
|
5 |
-
define('ACCESS_TOKEN', getenv('TEST_ACCESS_TOKEN'));
|
6 |
-
define('ACCESS_TOKEN_SECRET', getenv('TEST_ACCESS_TOKEN_SECRET'));
|
7 |
-
define('OAUTH_CALLBACK', getenv('TEST_OAUTH_CALLBACK'));
|
8 |
-
define('PROXY', getenv('TEST_CURLOPT_PROXY'));
|
9 |
-
define('PROXYUSERPWD', getenv('TEST_CURLOPT_PROXYUSERPWD'));
|
10 |
-
define('PROXYPORT', getenv('TEST_CURLOPT_PROXYPORT'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/abraham/twitteroauth/tests/video.mp4
DELETED
Binary file
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit471fee80aedc6ff1f09ed501be9d4e6b::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInite35032fbb4485eaaabd5e24b6e41609f
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
@@ -42,14 +42,14 @@ class ComposerAutoloaderInite35032fbb4485eaaabd5e24b6e41609f
|
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
-
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
function
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit471fee80aedc6ff1f09ed501be9d4e6b
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit471fee80aedc6ff1f09ed501be9d4e6b', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit471fee80aedc6ff1f09ed501be9d4e6b', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
42 |
|
43 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
44 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
45 |
+
composerRequire471fee80aedc6ff1f09ed501be9d4e6b($fileIdentifier, $file);
|
46 |
}
|
47 |
|
48 |
return $loader;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
function composerRequire471fee80aedc6ff1f09ed501be9d4e6b($fileIdentifier, $file)
|
53 |
{
|
54 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
55 |
require $file;
|
vendor/facebook/graph-sdk/composer.json
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "facebook/graph-sdk",
|
3 |
-
"description": "Facebook SDK for PHP",
|
4 |
-
"keywords": ["facebook", "sdk"],
|
5 |
-
"type": "library",
|
6 |
-
"homepage": "https://github.com/facebook/php-graph-sdk",
|
7 |
-
"license": "Facebook Platform",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Facebook",
|
11 |
-
"homepage": "https://github.com/facebook/php-graph-sdk/contributors"
|
12 |
-
}
|
13 |
-
],
|
14 |
-
"require": {
|
15 |
-
"php": "^5.4|^7.0"
|
16 |
-
},
|
17 |
-
"require-dev": {
|
18 |
-
"phpunit/phpunit": "~4.0",
|
19 |
-
"mockery/mockery": "~0.8",
|
20 |
-
"guzzlehttp/guzzle": "~5.0"
|
21 |
-
},
|
22 |
-
"suggest": {
|
23 |
-
"paragonie/random_compat": "Provides a better CSPRNG option in PHP 5",
|
24 |
-
"guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client"
|
25 |
-
},
|
26 |
-
"autoload": {
|
27 |
-
"psr-4": {
|
28 |
-
"Facebook\\": "src/Facebook/"
|
29 |
-
},
|
30 |
-
"files": ["src/Facebook/polyfills.php"]
|
31 |
-
},
|
32 |
-
"autoload-dev": {
|
33 |
-
"psr-4": {
|
34 |
-
"Facebook\\Tests\\": "tests/"
|
35 |
-
}
|
36 |
-
},
|
37 |
-
"extra": {
|
38 |
-
"branch-alias": {
|
39 |
-
"dev-master": "5.x-dev"
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/composer.json
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "monolog/monolog",
|
3 |
-
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
|
4 |
-
"keywords": ["log", "logging", "psr-3"],
|
5 |
-
"homepage": "http://github.com/Seldaek/monolog",
|
6 |
-
"type": "library",
|
7 |
-
"license": "MIT",
|
8 |
-
"authors": [
|
9 |
-
{
|
10 |
-
"name": "Jordi Boggiano",
|
11 |
-
"email": "j.boggiano@seld.be",
|
12 |
-
"homepage": "http://seld.be"
|
13 |
-
}
|
14 |
-
],
|
15 |
-
"require": {
|
16 |
-
"php": ">=5.3.0",
|
17 |
-
"psr/log": "~1.0"
|
18 |
-
},
|
19 |
-
"require-dev": {
|
20 |
-
"phpunit/phpunit": "~4.5",
|
21 |
-
"graylog2/gelf-php": "~1.0",
|
22 |
-
"sentry/sentry": "^0.13",
|
23 |
-
"ruflin/elastica": ">=0.90 <3.0",
|
24 |
-
"doctrine/couchdb": "~1.0@dev",
|
25 |
-
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
26 |
-
"php-amqplib/php-amqplib": "~2.4",
|
27 |
-
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
28 |
-
"php-console/php-console": "^3.1.3",
|
29 |
-
"phpunit/phpunit-mock-objects": "2.3.0",
|
30 |
-
"jakub-onderka/php-parallel-lint": "0.9"
|
31 |
-
},
|
32 |
-
"_": "phpunit/phpunit-mock-objects required in 2.3.0 due to https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223 - needs hhvm 3.8+ on travis",
|
33 |
-
"suggest": {
|
34 |
-
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
35 |
-
"sentry/sentry": "Allow sending log messages to a Sentry server",
|
36 |
-
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
37 |
-
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
|
38 |
-
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
39 |
-
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
40 |
-
"ext-mongo": "Allow sending log messages to a MongoDB server",
|
41 |
-
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
|
42 |
-
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
43 |
-
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
44 |
-
"php-console/php-console": "Allow sending log messages to Google Chrome"
|
45 |
-
},
|
46 |
-
"autoload": {
|
47 |
-
"psr-4": {"Monolog\\": "src/Monolog"}
|
48 |
-
},
|
49 |
-
"autoload-dev": {
|
50 |
-
"psr-4": {"Monolog\\": "tests/Monolog"}
|
51 |
-
},
|
52 |
-
"provide": {
|
53 |
-
"psr/log-implementation": "1.0.0"
|
54 |
-
},
|
55 |
-
"extra": {
|
56 |
-
"branch-alias": {
|
57 |
-
"dev-master": "2.0.x-dev"
|
58 |
-
}
|
59 |
-
},
|
60 |
-
"scripts": {
|
61 |
-
"test": [
|
62 |
-
"parallel-lint . --exclude vendor",
|
63 |
-
"phpunit"
|
64 |
-
]
|
65 |
-
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Monolog\Handler\TestHandler;
|
15 |
-
|
16 |
-
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function testHandleError()
|
19 |
-
{
|
20 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
21 |
-
$errHandler = new ErrorHandler($logger);
|
22 |
-
|
23 |
-
$errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
|
24 |
-
trigger_error('Foo', E_USER_ERROR);
|
25 |
-
$this->assertCount(1, $handler->getRecords());
|
26 |
-
$this->assertTrue($handler->hasErrorRecords());
|
27 |
-
trigger_error('Foo', E_USER_NOTICE);
|
28 |
-
$this->assertCount(2, $handler->getRecords());
|
29 |
-
$this->assertTrue($handler->hasEmergencyRecords());
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
DELETED
@@ -1,158 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
20 |
-
*/
|
21 |
-
public function testDefaultFormat()
|
22 |
-
{
|
23 |
-
$formatter = new ChromePHPFormatter();
|
24 |
-
$record = array(
|
25 |
-
'level' => Logger::ERROR,
|
26 |
-
'level_name' => 'ERROR',
|
27 |
-
'channel' => 'meh',
|
28 |
-
'context' => array('from' => 'logger'),
|
29 |
-
'datetime' => new \DateTime("@0"),
|
30 |
-
'extra' => array('ip' => '127.0.0.1'),
|
31 |
-
'message' => 'log',
|
32 |
-
);
|
33 |
-
|
34 |
-
$message = $formatter->format($record);
|
35 |
-
|
36 |
-
$this->assertEquals(
|
37 |
-
array(
|
38 |
-
'meh',
|
39 |
-
array(
|
40 |
-
'message' => 'log',
|
41 |
-
'context' => array('from' => 'logger'),
|
42 |
-
'extra' => array('ip' => '127.0.0.1'),
|
43 |
-
),
|
44 |
-
'unknown',
|
45 |
-
'error',
|
46 |
-
),
|
47 |
-
$message
|
48 |
-
);
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
53 |
-
*/
|
54 |
-
public function testFormatWithFileAndLine()
|
55 |
-
{
|
56 |
-
$formatter = new ChromePHPFormatter();
|
57 |
-
$record = array(
|
58 |
-
'level' => Logger::CRITICAL,
|
59 |
-
'level_name' => 'CRITICAL',
|
60 |
-
'channel' => 'meh',
|
61 |
-
'context' => array('from' => 'logger'),
|
62 |
-
'datetime' => new \DateTime("@0"),
|
63 |
-
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
64 |
-
'message' => 'log',
|
65 |
-
);
|
66 |
-
|
67 |
-
$message = $formatter->format($record);
|
68 |
-
|
69 |
-
$this->assertEquals(
|
70 |
-
array(
|
71 |
-
'meh',
|
72 |
-
array(
|
73 |
-
'message' => 'log',
|
74 |
-
'context' => array('from' => 'logger'),
|
75 |
-
'extra' => array('ip' => '127.0.0.1'),
|
76 |
-
),
|
77 |
-
'test : 14',
|
78 |
-
'error',
|
79 |
-
),
|
80 |
-
$message
|
81 |
-
);
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
86 |
-
*/
|
87 |
-
public function testFormatWithoutContext()
|
88 |
-
{
|
89 |
-
$formatter = new ChromePHPFormatter();
|
90 |
-
$record = array(
|
91 |
-
'level' => Logger::DEBUG,
|
92 |
-
'level_name' => 'DEBUG',
|
93 |
-
'channel' => 'meh',
|
94 |
-
'context' => array(),
|
95 |
-
'datetime' => new \DateTime("@0"),
|
96 |
-
'extra' => array(),
|
97 |
-
'message' => 'log',
|
98 |
-
);
|
99 |
-
|
100 |
-
$message = $formatter->format($record);
|
101 |
-
|
102 |
-
$this->assertEquals(
|
103 |
-
array(
|
104 |
-
'meh',
|
105 |
-
'log',
|
106 |
-
'unknown',
|
107 |
-
'log',
|
108 |
-
),
|
109 |
-
$message
|
110 |
-
);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @covers Monolog\Formatter\ChromePHPFormatter::formatBatch
|
115 |
-
*/
|
116 |
-
public function testBatchFormatThrowException()
|
117 |
-
{
|
118 |
-
$formatter = new ChromePHPFormatter();
|
119 |
-
$records = array(
|
120 |
-
array(
|
121 |
-
'level' => Logger::INFO,
|
122 |
-
'level_name' => 'INFO',
|
123 |
-
'channel' => 'meh',
|
124 |
-
'context' => array(),
|
125 |
-
'datetime' => new \DateTime("@0"),
|
126 |
-
'extra' => array(),
|
127 |
-
'message' => 'log',
|
128 |
-
),
|
129 |
-
array(
|
130 |
-
'level' => Logger::WARNING,
|
131 |
-
'level_name' => 'WARNING',
|
132 |
-
'channel' => 'foo',
|
133 |
-
'context' => array(),
|
134 |
-
'datetime' => new \DateTime("@0"),
|
135 |
-
'extra' => array(),
|
136 |
-
'message' => 'log2',
|
137 |
-
),
|
138 |
-
);
|
139 |
-
|
140 |
-
$this->assertEquals(
|
141 |
-
array(
|
142 |
-
array(
|
143 |
-
'meh',
|
144 |
-
'log',
|
145 |
-
'unknown',
|
146 |
-
'info',
|
147 |
-
),
|
148 |
-
array(
|
149 |
-
'foo',
|
150 |
-
'log2',
|
151 |
-
'unknown',
|
152 |
-
'warn',
|
153 |
-
),
|
154 |
-
),
|
155 |
-
$formatter->formatBatch($records)
|
156 |
-
);
|
157 |
-
}
|
158 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function setUp()
|
19 |
-
{
|
20 |
-
if (!class_exists("Elastica\Document")) {
|
21 |
-
$this->markTestSkipped("ruflin/elastica not installed");
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @covers Monolog\Formatter\ElasticaFormatter::__construct
|
27 |
-
* @covers Monolog\Formatter\ElasticaFormatter::format
|
28 |
-
* @covers Monolog\Formatter\ElasticaFormatter::getDocument
|
29 |
-
*/
|
30 |
-
public function testFormat()
|
31 |
-
{
|
32 |
-
// test log message
|
33 |
-
$msg = array(
|
34 |
-
'level' => Logger::ERROR,
|
35 |
-
'level_name' => 'ERROR',
|
36 |
-
'channel' => 'meh',
|
37 |
-
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
38 |
-
'datetime' => new \DateTime("@0"),
|
39 |
-
'extra' => array(),
|
40 |
-
'message' => 'log',
|
41 |
-
);
|
42 |
-
|
43 |
-
// expected values
|
44 |
-
$expected = $msg;
|
45 |
-
$expected['datetime'] = '1970-01-01T00:00:00.000000+00:00';
|
46 |
-
$expected['context'] = array(
|
47 |
-
'class' => '[object] (stdClass: {})',
|
48 |
-
'foo' => 7,
|
49 |
-
0 => 'bar',
|
50 |
-
);
|
51 |
-
|
52 |
-
// format log message
|
53 |
-
$formatter = new ElasticaFormatter('my_index', 'doc_type');
|
54 |
-
$doc = $formatter->format($msg);
|
55 |
-
$this->assertInstanceOf('Elastica\Document', $doc);
|
56 |
-
|
57 |
-
// Document parameters
|
58 |
-
$params = $doc->getParams();
|
59 |
-
$this->assertEquals('my_index', $params['_index']);
|
60 |
-
$this->assertEquals('doc_type', $params['_type']);
|
61 |
-
|
62 |
-
// Document data values
|
63 |
-
$data = $doc->getData();
|
64 |
-
foreach (array_keys($expected) as $key) {
|
65 |
-
$this->assertEquals($expected[$key], $data[$key]);
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @covers Monolog\Formatter\ElasticaFormatter::getIndex
|
71 |
-
* @covers Monolog\Formatter\ElasticaFormatter::getType
|
72 |
-
*/
|
73 |
-
public function testGetters()
|
74 |
-
{
|
75 |
-
$formatter = new ElasticaFormatter('my_index', 'doc_type');
|
76 |
-
$this->assertEquals('my_index', $formatter->getIndex());
|
77 |
-
$this->assertEquals('doc_type', $formatter->getType());
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class FlowdockFormatterTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Formatter\FlowdockFormatter::format
|
21 |
-
*/
|
22 |
-
public function testFormat()
|
23 |
-
{
|
24 |
-
$formatter = new FlowdockFormatter('test_source', 'source@test.com');
|
25 |
-
$record = $this->getRecord();
|
26 |
-
|
27 |
-
$expected = array(
|
28 |
-
'source' => 'test_source',
|
29 |
-
'from_address' => 'source@test.com',
|
30 |
-
'subject' => 'in test_source: WARNING - test',
|
31 |
-
'content' => 'test',
|
32 |
-
'tags' => array('#logs', '#warning', '#test'),
|
33 |
-
'project' => 'test_source',
|
34 |
-
);
|
35 |
-
$formatted = $formatter->format($record);
|
36 |
-
|
37 |
-
$this->assertEquals($expected, $formatted['flowdock']);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @ covers Monolog\Formatter\FlowdockFormatter::formatBatch
|
42 |
-
*/
|
43 |
-
public function testFormatBatch()
|
44 |
-
{
|
45 |
-
$formatter = new FlowdockFormatter('test_source', 'source@test.com');
|
46 |
-
$records = array(
|
47 |
-
$this->getRecord(Logger::WARNING),
|
48 |
-
$this->getRecord(Logger::DEBUG),
|
49 |
-
);
|
50 |
-
$formatted = $formatter->formatBatch($records);
|
51 |
-
|
52 |
-
$this->assertArrayHasKey('flowdock', $formatted[0]);
|
53 |
-
$this->assertArrayHasKey('flowdock', $formatted[1]);
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class FluentdFormatterTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Formatter\FluentdFormatter::__construct
|
21 |
-
* @covers Monolog\Formatter\FluentdFormatter::isUsingLevelsInTag
|
22 |
-
*/
|
23 |
-
public function testConstruct()
|
24 |
-
{
|
25 |
-
$formatter = new FluentdFormatter();
|
26 |
-
$this->assertEquals(false, $formatter->isUsingLevelsInTag());
|
27 |
-
$formatter = new FluentdFormatter(false);
|
28 |
-
$this->assertEquals(false, $formatter->isUsingLevelsInTag());
|
29 |
-
$formatter = new FluentdFormatter(true);
|
30 |
-
$this->assertEquals(true, $formatter->isUsingLevelsInTag());
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @covers Monolog\Formatter\FluentdFormatter::format
|
35 |
-
*/
|
36 |
-
public function testFormat()
|
37 |
-
{
|
38 |
-
$record = $this->getRecord(Logger::WARNING);
|
39 |
-
$record['datetime'] = new \DateTime("@0");
|
40 |
-
|
41 |
-
$formatter = new FluentdFormatter();
|
42 |
-
$this->assertEquals(
|
43 |
-
'["test",0,{"message":"test","context":[],"extra":[],"level":300,"level_name":"WARNING"}]',
|
44 |
-
$formatter->format($record)
|
45 |
-
);
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @covers Monolog\Formatter\FluentdFormatter::format
|
50 |
-
*/
|
51 |
-
public function testFormatWithTag()
|
52 |
-
{
|
53 |
-
$record = $this->getRecord(Logger::ERROR);
|
54 |
-
$record['datetime'] = new \DateTime("@0");
|
55 |
-
|
56 |
-
$formatter = new FluentdFormatter(true);
|
57 |
-
$this->assertEquals(
|
58 |
-
'["test.error",0,{"message":"test","context":[],"extra":[]}]',
|
59 |
-
$formatter->format($record)
|
60 |
-
);
|
61 |
-
}
|
62 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
DELETED
@@ -1,258 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function setUp()
|
19 |
-
{
|
20 |
-
if (!class_exists('\Gelf\Message')) {
|
21 |
-
$this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed");
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
27 |
-
*/
|
28 |
-
public function testDefaultFormatter()
|
29 |
-
{
|
30 |
-
$formatter = new GelfMessageFormatter();
|
31 |
-
$record = array(
|
32 |
-
'level' => Logger::ERROR,
|
33 |
-
'level_name' => 'ERROR',
|
34 |
-
'channel' => 'meh',
|
35 |
-
'context' => array(),
|
36 |
-
'datetime' => new \DateTime("@0"),
|
37 |
-
'extra' => array(),
|
38 |
-
'message' => 'log',
|
39 |
-
);
|
40 |
-
|
41 |
-
$message = $formatter->format($record);
|
42 |
-
|
43 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
44 |
-
$this->assertEquals(0, $message->getTimestamp());
|
45 |
-
$this->assertEquals('log', $message->getShortMessage());
|
46 |
-
$this->assertEquals('meh', $message->getFacility());
|
47 |
-
$this->assertEquals(null, $message->getLine());
|
48 |
-
$this->assertEquals(null, $message->getFile());
|
49 |
-
$this->assertEquals($this->isLegacy() ? 3 : 'error', $message->getLevel());
|
50 |
-
$this->assertNotEmpty($message->getHost());
|
51 |
-
|
52 |
-
$formatter = new GelfMessageFormatter('mysystem');
|
53 |
-
|
54 |
-
$message = $formatter->format($record);
|
55 |
-
|
56 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
57 |
-
$this->assertEquals('mysystem', $message->getHost());
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
62 |
-
*/
|
63 |
-
public function testFormatWithFileAndLine()
|
64 |
-
{
|
65 |
-
$formatter = new GelfMessageFormatter();
|
66 |
-
$record = array(
|
67 |
-
'level' => Logger::ERROR,
|
68 |
-
'level_name' => 'ERROR',
|
69 |
-
'channel' => 'meh',
|
70 |
-
'context' => array('from' => 'logger'),
|
71 |
-
'datetime' => new \DateTime("@0"),
|
72 |
-
'extra' => array('file' => 'test', 'line' => 14),
|
73 |
-
'message' => 'log',
|
74 |
-
);
|
75 |
-
|
76 |
-
$message = $formatter->format($record);
|
77 |
-
|
78 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
79 |
-
$this->assertEquals('test', $message->getFile());
|
80 |
-
$this->assertEquals(14, $message->getLine());
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
85 |
-
* @expectedException InvalidArgumentException
|
86 |
-
*/
|
87 |
-
public function testFormatInvalidFails()
|
88 |
-
{
|
89 |
-
$formatter = new GelfMessageFormatter();
|
90 |
-
$record = array(
|
91 |
-
'level' => Logger::ERROR,
|
92 |
-
'level_name' => 'ERROR',
|
93 |
-
);
|
94 |
-
|
95 |
-
$formatter->format($record);
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
100 |
-
*/
|
101 |
-
public function testFormatWithContext()
|
102 |
-
{
|
103 |
-
$formatter = new GelfMessageFormatter();
|
104 |
-
$record = array(
|
105 |
-
'level' => Logger::ERROR,
|
106 |
-
'level_name' => 'ERROR',
|
107 |
-
'channel' => 'meh',
|
108 |
-
'context' => array('from' => 'logger'),
|
109 |
-
'datetime' => new \DateTime("@0"),
|
110 |
-
'extra' => array('key' => 'pair'),
|
111 |
-
'message' => 'log',
|
112 |
-
);
|
113 |
-
|
114 |
-
$message = $formatter->format($record);
|
115 |
-
|
116 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
117 |
-
|
118 |
-
$message_array = $message->toArray();
|
119 |
-
|
120 |
-
$this->assertArrayHasKey('_ctxt_from', $message_array);
|
121 |
-
$this->assertEquals('logger', $message_array['_ctxt_from']);
|
122 |
-
|
123 |
-
// Test with extraPrefix
|
124 |
-
$formatter = new GelfMessageFormatter(null, null, 'CTX');
|
125 |
-
$message = $formatter->format($record);
|
126 |
-
|
127 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
128 |
-
|
129 |
-
$message_array = $message->toArray();
|
130 |
-
|
131 |
-
$this->assertArrayHasKey('_CTXfrom', $message_array);
|
132 |
-
$this->assertEquals('logger', $message_array['_CTXfrom']);
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
137 |
-
*/
|
138 |
-
public function testFormatWithContextContainingException()
|
139 |
-
{
|
140 |
-
$formatter = new GelfMessageFormatter();
|
141 |
-
$record = array(
|
142 |
-
'level' => Logger::ERROR,
|
143 |
-
'level_name' => 'ERROR',
|
144 |
-
'channel' => 'meh',
|
145 |
-
'context' => array('from' => 'logger', 'exception' => array(
|
146 |
-
'class' => '\Exception',
|
147 |
-
'file' => '/some/file/in/dir.php:56',
|
148 |
-
'trace' => array('/some/file/1.php:23', '/some/file/2.php:3'),
|
149 |
-
)),
|
150 |
-
'datetime' => new \DateTime("@0"),
|
151 |
-
'extra' => array(),
|
152 |
-
'message' => 'log',
|
153 |
-
);
|
154 |
-
|
155 |
-
$message = $formatter->format($record);
|
156 |
-
|
157 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
158 |
-
|
159 |
-
$this->assertEquals("/some/file/in/dir.php", $message->getFile());
|
160 |
-
$this->assertEquals("56", $message->getLine());
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
165 |
-
*/
|
166 |
-
public function testFormatWithExtra()
|
167 |
-
{
|
168 |
-
$formatter = new GelfMessageFormatter();
|
169 |
-
$record = array(
|
170 |
-
'level' => Logger::ERROR,
|
171 |
-
'level_name' => 'ERROR',
|
172 |
-
'channel' => 'meh',
|
173 |
-
'context' => array('from' => 'logger'),
|
174 |
-
'datetime' => new \DateTime("@0"),
|
175 |
-
'extra' => array('key' => 'pair'),
|
176 |
-
'message' => 'log',
|
177 |
-
);
|
178 |
-
|
179 |
-
$message = $formatter->format($record);
|
180 |
-
|
181 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
182 |
-
|
183 |
-
$message_array = $message->toArray();
|
184 |
-
|
185 |
-
$this->assertArrayHasKey('_key', $message_array);
|
186 |
-
$this->assertEquals('pair', $message_array['_key']);
|
187 |
-
|
188 |
-
// Test with extraPrefix
|
189 |
-
$formatter = new GelfMessageFormatter(null, 'EXT');
|
190 |
-
$message = $formatter->format($record);
|
191 |
-
|
192 |
-
$this->assertInstanceOf('Gelf\Message', $message);
|
193 |
-
|
194 |
-
$message_array = $message->toArray();
|
195 |
-
|
196 |
-
$this->assertArrayHasKey('_EXTkey', $message_array);
|
197 |
-
$this->assertEquals('pair', $message_array['_EXTkey']);
|
198 |
-
}
|
199 |
-
|
200 |
-
public function testFormatWithLargeData()
|
201 |
-
{
|
202 |
-
$formatter = new GelfMessageFormatter();
|
203 |
-
$record = array(
|
204 |
-
'level' => Logger::ERROR,
|
205 |
-
'level_name' => 'ERROR',
|
206 |
-
'channel' => 'meh',
|
207 |
-
'context' => array('exception' => str_repeat(' ', 32767)),
|
208 |
-
'datetime' => new \DateTime("@0"),
|
209 |
-
'extra' => array('key' => str_repeat(' ', 32767)),
|
210 |
-
'message' => 'log'
|
211 |
-
);
|
212 |
-
$message = $formatter->format($record);
|
213 |
-
$messageArray = $message->toArray();
|
214 |
-
|
215 |
-
// 200 for padding + metadata
|
216 |
-
$length = 200;
|
217 |
-
|
218 |
-
foreach ($messageArray as $key => $value) {
|
219 |
-
if (!in_array($key, array('level', 'timestamp'))) {
|
220 |
-
$length += strlen($value);
|
221 |
-
}
|
222 |
-
}
|
223 |
-
|
224 |
-
$this->assertLessThanOrEqual(65792, $length, 'The message length is no longer than the maximum allowed length');
|
225 |
-
}
|
226 |
-
|
227 |
-
public function testFormatWithUnlimitedLength()
|
228 |
-
{
|
229 |
-
$formatter = new GelfMessageFormatter('LONG_SYSTEM_NAME', null, 'ctxt_', PHP_INT_MAX);
|
230 |
-
$record = array(
|
231 |
-
'level' => Logger::ERROR,
|
232 |
-
'level_name' => 'ERROR',
|
233 |
-
'channel' => 'meh',
|
234 |
-
'context' => array('exception' => str_repeat(' ', 32767 * 2)),
|
235 |
-
'datetime' => new \DateTime("@0"),
|
236 |
-
'extra' => array('key' => str_repeat(' ', 32767 * 2)),
|
237 |
-
'message' => 'log'
|
238 |
-
);
|
239 |
-
$message = $formatter->format($record);
|
240 |
-
$messageArray = $message->toArray();
|
241 |
-
|
242 |
-
// 200 for padding + metadata
|
243 |
-
$length = 200;
|
244 |
-
|
245 |
-
foreach ($messageArray as $key => $value) {
|
246 |
-
if (!in_array($key, array('level', 'timestamp'))) {
|
247 |
-
$length += strlen($value);
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
$this->assertGreaterThanOrEqual(131289, $length, 'The message should not be truncated');
|
252 |
-
}
|
253 |
-
|
254 |
-
private function isLegacy()
|
255 |
-
{
|
256 |
-
return interface_exists('\Gelf\IMessagePublisher');
|
257 |
-
}
|
258 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
DELETED
@@ -1,219 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class JsonFormatterTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Formatter\JsonFormatter::__construct
|
21 |
-
* @covers Monolog\Formatter\JsonFormatter::getBatchMode
|
22 |
-
* @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines
|
23 |
-
*/
|
24 |
-
public function testConstruct()
|
25 |
-
{
|
26 |
-
$formatter = new JsonFormatter();
|
27 |
-
$this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
|
28 |
-
$this->assertEquals(true, $formatter->isAppendingNewlines());
|
29 |
-
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false);
|
30 |
-
$this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
|
31 |
-
$this->assertEquals(false, $formatter->isAppendingNewlines());
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @covers Monolog\Formatter\JsonFormatter::format
|
36 |
-
*/
|
37 |
-
public function testFormat()
|
38 |
-
{
|
39 |
-
$formatter = new JsonFormatter();
|
40 |
-
$record = $this->getRecord();
|
41 |
-
$this->assertEquals(json_encode($record)."\n", $formatter->format($record));
|
42 |
-
|
43 |
-
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
|
44 |
-
$record = $this->getRecord();
|
45 |
-
$this->assertEquals(json_encode($record), $formatter->format($record));
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @covers Monolog\Formatter\JsonFormatter::formatBatch
|
50 |
-
* @covers Monolog\Formatter\JsonFormatter::formatBatchJson
|
51 |
-
*/
|
52 |
-
public function testFormatBatch()
|
53 |
-
{
|
54 |
-
$formatter = new JsonFormatter();
|
55 |
-
$records = array(
|
56 |
-
$this->getRecord(Logger::WARNING),
|
57 |
-
$this->getRecord(Logger::DEBUG),
|
58 |
-
);
|
59 |
-
$this->assertEquals(json_encode($records), $formatter->formatBatch($records));
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @covers Monolog\Formatter\JsonFormatter::formatBatch
|
64 |
-
* @covers Monolog\Formatter\JsonFormatter::formatBatchNewlines
|
65 |
-
*/
|
66 |
-
public function testFormatBatchNewlines()
|
67 |
-
{
|
68 |
-
$formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES);
|
69 |
-
$records = $expected = array(
|
70 |
-
$this->getRecord(Logger::WARNING),
|
71 |
-
$this->getRecord(Logger::DEBUG),
|
72 |
-
);
|
73 |
-
array_walk($expected, function (&$value, $key) {
|
74 |
-
$value = json_encode($value);
|
75 |
-
});
|
76 |
-
$this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records));
|
77 |
-
}
|
78 |
-
|
79 |
-
public function testDefFormatWithException()
|
80 |
-
{
|
81 |
-
$formatter = new JsonFormatter();
|
82 |
-
$exception = new \RuntimeException('Foo');
|
83 |
-
$formattedException = $this->formatException($exception);
|
84 |
-
|
85 |
-
$message = $this->formatRecordWithExceptionInContext($formatter, $exception);
|
86 |
-
|
87 |
-
$this->assertContextContainsFormattedException($formattedException, $message);
|
88 |
-
}
|
89 |
-
|
90 |
-
public function testDefFormatWithPreviousException()
|
91 |
-
{
|
92 |
-
$formatter = new JsonFormatter();
|
93 |
-
$exception = new \RuntimeException('Foo', 0, new \LogicException('Wut?'));
|
94 |
-
$formattedPrevException = $this->formatException($exception->getPrevious());
|
95 |
-
$formattedException = $this->formatException($exception, $formattedPrevException);
|
96 |
-
|
97 |
-
$message = $this->formatRecordWithExceptionInContext($formatter, $exception);
|
98 |
-
|
99 |
-
$this->assertContextContainsFormattedException($formattedException, $message);
|
100 |
-
}
|
101 |
-
|
102 |
-
public function testDefFormatWithThrowable()
|
103 |
-
{
|
104 |
-
if (!class_exists('Error') || !is_subclass_of('Error', 'Throwable')) {
|
105 |
-
$this->markTestSkipped('Requires PHP >=7');
|
106 |
-
}
|
107 |
-
|
108 |
-
$formatter = new JsonFormatter();
|
109 |
-
$throwable = new \Error('Foo');
|
110 |
-
$formattedThrowable = $this->formatException($throwable);
|
111 |
-
|
112 |
-
$message = $this->formatRecordWithExceptionInContext($formatter, $throwable);
|
113 |
-
|
114 |
-
$this->assertContextContainsFormattedException($formattedThrowable, $message);
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @param string $expected
|
119 |
-
* @param string $actual
|
120 |
-
*
|
121 |
-
* @internal param string $exception
|
122 |
-
*/
|
123 |
-
private function assertContextContainsFormattedException($expected, $actual)
|
124 |
-
{
|
125 |
-
$this->assertEquals(
|
126 |
-
'{"level_name":"CRITICAL","channel":"core","context":{"exception":'.$expected.'},"datetime":null,"extra":[],"message":"foobar"}'."\n",
|
127 |
-
$actual
|
128 |
-
);
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* @param JsonFormatter $formatter
|
133 |
-
* @param \Exception|\Throwable $exception
|
134 |
-
*
|
135 |
-
* @return string
|
136 |
-
*/
|
137 |
-
private function formatRecordWithExceptionInContext(JsonFormatter $formatter, $exception)
|
138 |
-
{
|
139 |
-
$message = $formatter->format(array(
|
140 |
-
'level_name' => 'CRITICAL',
|
141 |
-
'channel' => 'core',
|
142 |
-
'context' => array('exception' => $exception),
|
143 |
-
'datetime' => null,
|
144 |
-
'extra' => array(),
|
145 |
-
'message' => 'foobar',
|
146 |
-
));
|
147 |
-
return $message;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @param \Exception|\Throwable $exception
|
152 |
-
*
|
153 |
-
* @return string
|
154 |
-
*/
|
155 |
-
private function formatExceptionFilePathWithLine($exception)
|
156 |
-
{
|
157 |
-
$options = 0;
|
158 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
159 |
-
$options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
160 |
-
}
|
161 |
-
$path = substr(json_encode($exception->getFile(), $options), 1, -1);
|
162 |
-
return $path . ':' . $exception->getLine();
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* @param \Exception|\Throwable $exception
|
167 |
-
*
|
168 |
-
* @param null|string $previous
|
169 |
-
*
|
170 |
-
* @return string
|
171 |
-
*/
|
172 |
-
private function formatException($exception, $previous = null)
|
173 |
-
{
|
174 |
-
$formattedException =
|
175 |
-
'{"class":"' . get_class($exception) .
|
176 |
-
'","message":"' . $exception->getMessage() .
|
177 |
-
'","code":' . $exception->getCode() .
|
178 |
-
',"file":"' . $this->formatExceptionFilePathWithLine($exception) .
|
179 |
-
($previous ? '","previous":' . $previous : '"') .
|
180 |
-
'}';
|
181 |
-
return $formattedException;
|
182 |
-
}
|
183 |
-
|
184 |
-
public function testNormalizeHandleLargeArraysWithExactly1000Items()
|
185 |
-
{
|
186 |
-
$formatter = new NormalizerFormatter();
|
187 |
-
$largeArray = range(1, 1000);
|
188 |
-
|
189 |
-
$res = $formatter->format(array(
|
190 |
-
'level_name' => 'CRITICAL',
|
191 |
-
'channel' => 'test',
|
192 |
-
'message' => 'bar',
|
193 |
-
'context' => array($largeArray),
|
194 |
-
'datetime' => new \DateTime,
|
195 |
-
'extra' => array(),
|
196 |
-
));
|
197 |
-
|
198 |
-
$this->assertCount(1000, $res['context'][0]);
|
199 |
-
$this->assertArrayNotHasKey('...', $res['context'][0]);
|
200 |
-
}
|
201 |
-
|
202 |
-
public function testNormalizeHandleLargeArrays()
|
203 |
-
{
|
204 |
-
$formatter = new NormalizerFormatter();
|
205 |
-
$largeArray = range(1, 2000);
|
206 |
-
|
207 |
-
$res = $formatter->format(array(
|
208 |
-
'level_name' => 'CRITICAL',
|
209 |
-
'channel' => 'test',
|
210 |
-
'message' => 'bar',
|
211 |
-
'context' => array($largeArray),
|
212 |
-
'datetime' => new \DateTime,
|
213 |
-
'extra' => array(),
|
214 |
-
));
|
215 |
-
|
216 |
-
$this->assertCount(1001, $res['context'][0]);
|
217 |
-
$this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']);
|
218 |
-
}
|
219 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
DELETED
@@ -1,222 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @covers Monolog\Formatter\LineFormatter
|
16 |
-
*/
|
17 |
-
class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
18 |
-
{
|
19 |
-
public function testDefFormatWithString()
|
20 |
-
{
|
21 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
22 |
-
$message = $formatter->format(array(
|
23 |
-
'level_name' => 'WARNING',
|
24 |
-
'channel' => 'log',
|
25 |
-
'context' => array(),
|
26 |
-
'message' => 'foo',
|
27 |
-
'datetime' => new \DateTime,
|
28 |
-
'extra' => array(),
|
29 |
-
));
|
30 |
-
$this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testDefFormatWithArrayContext()
|
34 |
-
{
|
35 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
36 |
-
$message = $formatter->format(array(
|
37 |
-
'level_name' => 'ERROR',
|
38 |
-
'channel' => 'meh',
|
39 |
-
'message' => 'foo',
|
40 |
-
'datetime' => new \DateTime,
|
41 |
-
'extra' => array(),
|
42 |
-
'context' => array(
|
43 |
-
'foo' => 'bar',
|
44 |
-
'baz' => 'qux',
|
45 |
-
'bool' => false,
|
46 |
-
'null' => null,
|
47 |
-
),
|
48 |
-
));
|
49 |
-
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux","bool":false,"null":null} []'."\n", $message);
|
50 |
-
}
|
51 |
-
|
52 |
-
public function testDefFormatExtras()
|
53 |
-
{
|
54 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
55 |
-
$message = $formatter->format(array(
|
56 |
-
'level_name' => 'ERROR',
|
57 |
-
'channel' => 'meh',
|
58 |
-
'context' => array(),
|
59 |
-
'datetime' => new \DateTime,
|
60 |
-
'extra' => array('ip' => '127.0.0.1'),
|
61 |
-
'message' => 'log',
|
62 |
-
));
|
63 |
-
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message);
|
64 |
-
}
|
65 |
-
|
66 |
-
public function testFormatExtras()
|
67 |
-
{
|
68 |
-
$formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d');
|
69 |
-
$message = $formatter->format(array(
|
70 |
-
'level_name' => 'ERROR',
|
71 |
-
'channel' => 'meh',
|
72 |
-
'context' => array(),
|
73 |
-
'datetime' => new \DateTime,
|
74 |
-
'extra' => array('ip' => '127.0.0.1', 'file' => 'test'),
|
75 |
-
'message' => 'log',
|
76 |
-
));
|
77 |
-
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message);
|
78 |
-
}
|
79 |
-
|
80 |
-
public function testContextAndExtraOptionallyNotShownIfEmpty()
|
81 |
-
{
|
82 |
-
$formatter = new LineFormatter(null, 'Y-m-d', false, true);
|
83 |
-
$message = $formatter->format(array(
|
84 |
-
'level_name' => 'ERROR',
|
85 |
-
'channel' => 'meh',
|
86 |
-
'context' => array(),
|
87 |
-
'datetime' => new \DateTime,
|
88 |
-
'extra' => array(),
|
89 |
-
'message' => 'log',
|
90 |
-
));
|
91 |
-
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log '."\n", $message);
|
92 |
-
}
|
93 |
-
|
94 |
-
public function testContextAndExtraReplacement()
|
95 |
-
{
|
96 |
-
$formatter = new LineFormatter('%context.foo% => %extra.foo%');
|
97 |
-
$message = $formatter->format(array(
|
98 |
-
'level_name' => 'ERROR',
|
99 |
-
'channel' => 'meh',
|
100 |
-
'context' => array('foo' => 'bar'),
|
101 |
-
'datetime' => new \DateTime,
|
102 |
-
'extra' => array('foo' => 'xbar'),
|
103 |
-
'message' => 'log',
|
104 |
-
));
|
105 |
-
$this->assertEquals('bar => xbar', $message);
|
106 |
-
}
|
107 |
-
|
108 |
-
public function testDefFormatWithObject()
|
109 |
-
{
|
110 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
111 |
-
$message = $formatter->format(array(
|
112 |
-
'level_name' => 'ERROR',
|
113 |
-
'channel' => 'meh',
|
114 |
-
'context' => array(),
|
115 |
-
'datetime' => new \DateTime,
|
116 |
-
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
117 |
-
'message' => 'foobar',
|
118 |
-
));
|
119 |
-
|
120 |
-
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: bar)","baz":[],"res":"[resource] (stream)"}'."\n", $message);
|
121 |
-
}
|
122 |
-
|
123 |
-
public function testDefFormatWithException()
|
124 |
-
{
|
125 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
126 |
-
$message = $formatter->format(array(
|
127 |
-
'level_name' => 'CRITICAL',
|
128 |
-
'channel' => 'core',
|
129 |
-
'context' => array('exception' => new \RuntimeException('Foo')),
|
130 |
-
'datetime' => new \DateTime,
|
131 |
-
'extra' => array(),
|
132 |
-
'message' => 'foobar',
|
133 |
-
));
|
134 |
-
|
135 |
-
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
136 |
-
|
137 |
-
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
|
138 |
-
}
|
139 |
-
|
140 |
-
public function testDefFormatWithPreviousException()
|
141 |
-
{
|
142 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
143 |
-
$previous = new \LogicException('Wut?');
|
144 |
-
$message = $formatter->format(array(
|
145 |
-
'level_name' => 'CRITICAL',
|
146 |
-
'channel' => 'core',
|
147 |
-
'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)),
|
148 |
-
'datetime' => new \DateTime,
|
149 |
-
'extra' => array(),
|
150 |
-
'message' => 'foobar',
|
151 |
-
));
|
152 |
-
|
153 |
-
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
154 |
-
|
155 |
-
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).', LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message);
|
156 |
-
}
|
157 |
-
|
158 |
-
public function testBatchFormat()
|
159 |
-
{
|
160 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
161 |
-
$message = $formatter->formatBatch(array(
|
162 |
-
array(
|
163 |
-
'level_name' => 'CRITICAL',
|
164 |
-
'channel' => 'test',
|
165 |
-
'message' => 'bar',
|
166 |
-
'context' => array(),
|
167 |
-
'datetime' => new \DateTime,
|
168 |
-
'extra' => array(),
|
169 |
-
),
|
170 |
-
array(
|
171 |
-
'level_name' => 'WARNING',
|
172 |
-
'channel' => 'log',
|
173 |
-
'message' => 'foo',
|
174 |
-
'context' => array(),
|
175 |
-
'datetime' => new \DateTime,
|
176 |
-
'extra' => array(),
|
177 |
-
),
|
178 |
-
));
|
179 |
-
$this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
180 |
-
}
|
181 |
-
|
182 |
-
public function testFormatShouldStripInlineLineBreaks()
|
183 |
-
{
|
184 |
-
$formatter = new LineFormatter(null, 'Y-m-d');
|
185 |
-
$message = $formatter->format(
|
186 |
-
array(
|
187 |
-
'message' => "foo\nbar",
|
188 |
-
'context' => array(),
|
189 |
-
'extra' => array(),
|
190 |
-
)
|
191 |
-
);
|
192 |
-
|
193 |
-
$this->assertRegExp('/foo bar/', $message);
|
194 |
-
}
|
195 |
-
|
196 |
-
public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
|
197 |
-
{
|
198 |
-
$formatter = new LineFormatter(null, 'Y-m-d', true);
|
199 |
-
$message = $formatter->format(
|
200 |
-
array(
|
201 |
-
'message' => "foo\nbar",
|
202 |
-
'context' => array(),
|
203 |
-
'extra' => array(),
|
204 |
-
)
|
205 |
-
);
|
206 |
-
|
207 |
-
$this->assertRegExp('/foo\nbar/', $message);
|
208 |
-
}
|
209 |
-
}
|
210 |
-
|
211 |
-
class TestFoo
|
212 |
-
{
|
213 |
-
public $foo = 'foo';
|
214 |
-
}
|
215 |
-
|
216 |
-
class TestBar
|
217 |
-
{
|
218 |
-
public function __toString()
|
219 |
-
{
|
220 |
-
return 'bar';
|
221 |
-
}
|
222 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class LogglyFormatterTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Formatter\LogglyFormatter::__construct
|
20 |
-
*/
|
21 |
-
public function testConstruct()
|
22 |
-
{
|
23 |
-
$formatter = new LogglyFormatter();
|
24 |
-
$this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
|
25 |
-
$formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON);
|
26 |
-
$this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @covers Monolog\Formatter\LogglyFormatter::format
|
31 |
-
*/
|
32 |
-
public function testFormat()
|
33 |
-
{
|
34 |
-
$formatter = new LogglyFormatter();
|
35 |
-
$record = $this->getRecord();
|
36 |
-
$formatted_decoded = json_decode($formatter->format($record), true);
|
37 |
-
$this->assertArrayHasKey("timestamp", $formatted_decoded);
|
38 |
-
$this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
DELETED
@@ -1,333 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
public function tearDown()
|
19 |
-
{
|
20 |
-
\PHPUnit_Framework_Error_Warning::$enabled = true;
|
21 |
-
|
22 |
-
return parent::tearDown();
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
27 |
-
*/
|
28 |
-
public function testDefaultFormatter()
|
29 |
-
{
|
30 |
-
$formatter = new LogstashFormatter('test', 'hostname');
|
31 |
-
$record = array(
|
32 |
-
'level' => Logger::ERROR,
|
33 |
-
'level_name' => 'ERROR',
|
34 |
-
'channel' => 'meh',
|
35 |
-
'context' => array(),
|
36 |
-
'datetime' => new \DateTime("@0"),
|
37 |
-
'extra' => array(),
|
38 |
-
'message' => 'log',
|
39 |
-
);
|
40 |
-
|
41 |
-
$message = json_decode($formatter->format($record), true);
|
42 |
-
|
43 |
-
$this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
|
44 |
-
$this->assertEquals('log', $message['@message']);
|
45 |
-
$this->assertEquals('meh', $message['@fields']['channel']);
|
46 |
-
$this->assertContains('meh', $message['@tags']);
|
47 |
-
$this->assertEquals(Logger::ERROR, $message['@fields']['level']);
|
48 |
-
$this->assertEquals('test', $message['@type']);
|
49 |
-
$this->assertEquals('hostname', $message['@source']);
|
50 |
-
|
51 |
-
$formatter = new LogstashFormatter('mysystem');
|
52 |
-
|
53 |
-
$message = json_decode($formatter->format($record), true);
|
54 |
-
|
55 |
-
$this->assertEquals('mysystem', $message['@type']);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
60 |
-
*/
|
61 |
-
public function testFormatWithFileAndLine()
|
62 |
-
{
|
63 |
-
$formatter = new LogstashFormatter('test');
|
64 |
-
$record = array(
|
65 |
-
'level' => Logger::ERROR,
|
66 |
-
'level_name' => 'ERROR',
|
67 |
-
'channel' => 'meh',
|
68 |
-
'context' => array('from' => 'logger'),
|
69 |
-
'datetime' => new \DateTime("@0"),
|
70 |
-
'extra' => array('file' => 'test', 'line' => 14),
|
71 |
-
'message' => 'log',
|
72 |
-
);
|
73 |
-
|
74 |
-
$message = json_decode($formatter->format($record), true);
|
75 |
-
|
76 |
-
$this->assertEquals('test', $message['@fields']['file']);
|
77 |
-
$this->assertEquals(14, $message['@fields']['line']);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
82 |
-
*/
|
83 |
-
public function testFormatWithContext()
|
84 |
-
{
|
85 |
-
$formatter = new LogstashFormatter('test');
|
86 |
-
$record = array(
|
87 |
-
'level' => Logger::ERROR,
|
88 |
-
'level_name' => 'ERROR',
|
89 |
-
'channel' => 'meh',
|
90 |
-
'context' => array('from' => 'logger'),
|
91 |
-
'datetime' => new \DateTime("@0"),
|
92 |
-
'extra' => array('key' => 'pair'),
|
93 |
-
'message' => 'log',
|
94 |
-
);
|
95 |
-
|
96 |
-
$message = json_decode($formatter->format($record), true);
|
97 |
-
|
98 |
-
$message_array = $message['@fields'];
|
99 |
-
|
100 |
-
$this->assertArrayHasKey('ctxt_from', $message_array);
|
101 |
-
$this->assertEquals('logger', $message_array['ctxt_from']);
|
102 |
-
|
103 |
-
// Test with extraPrefix
|
104 |
-
$formatter = new LogstashFormatter('test', null, null, 'CTX');
|
105 |
-
$message = json_decode($formatter->format($record), true);
|
106 |
-
|
107 |
-
$message_array = $message['@fields'];
|
108 |
-
|
109 |
-
$this->assertArrayHasKey('CTXfrom', $message_array);
|
110 |
-
$this->assertEquals('logger', $message_array['CTXfrom']);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
115 |
-
*/
|
116 |
-
public function testFormatWithExtra()
|
117 |
-
{
|
118 |
-
$formatter = new LogstashFormatter('test');
|
119 |
-
$record = array(
|
120 |
-
'level' => Logger::ERROR,
|
121 |
-
'level_name' => 'ERROR',
|
122 |
-
'channel' => 'meh',
|
123 |
-
'context' => array('from' => 'logger'),
|
124 |
-
'datetime' => new \DateTime("@0"),
|
125 |
-
'extra' => array('key' => 'pair'),
|
126 |
-
'message' => 'log',
|
127 |
-
);
|
128 |
-
|
129 |
-
$message = json_decode($formatter->format($record), true);
|
130 |
-
|
131 |
-
$message_array = $message['@fields'];
|
132 |
-
|
133 |
-
$this->assertArrayHasKey('key', $message_array);
|
134 |
-
$this->assertEquals('pair', $message_array['key']);
|
135 |
-
|
136 |
-
// Test with extraPrefix
|
137 |
-
$formatter = new LogstashFormatter('test', null, 'EXT');
|
138 |
-
$message = json_decode($formatter->format($record), true);
|
139 |
-
|
140 |
-
$message_array = $message['@fields'];
|
141 |
-
|
142 |
-
$this->assertArrayHasKey('EXTkey', $message_array);
|
143 |
-
$this->assertEquals('pair', $message_array['EXTkey']);
|
144 |
-
}
|
145 |
-
|
146 |
-
public function testFormatWithApplicationName()
|
147 |
-
{
|
148 |
-
$formatter = new LogstashFormatter('app', 'test');
|
149 |
-
$record = array(
|
150 |
-
'level' => Logger::ERROR,
|
151 |
-
'level_name' => 'ERROR',
|
152 |
-
'channel' => 'meh',
|
153 |
-
'context' => array('from' => 'logger'),
|
154 |
-
'datetime' => new \DateTime("@0"),
|
155 |
-
'extra' => array('key' => 'pair'),
|
156 |
-
'message' => 'log',
|
157 |
-
);
|
158 |
-
|
159 |
-
$message = json_decode($formatter->format($record), true);
|
160 |
-
|
161 |
-
$this->assertArrayHasKey('@type', $message);
|
162 |
-
$this->assertEquals('app', $message['@type']);
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
167 |
-
*/
|
168 |
-
public function testDefaultFormatterV1()
|
169 |
-
{
|
170 |
-
$formatter = new LogstashFormatter('test', 'hostname', null, 'ctxt_', LogstashFormatter::V1);
|
171 |
-
$record = array(
|
172 |
-
'level' => Logger::ERROR,
|
173 |
-
'level_name' => 'ERROR',
|
174 |
-
'channel' => 'meh',
|
175 |
-
'context' => array(),
|
176 |
-
'datetime' => new \DateTime("@0"),
|
177 |
-
'extra' => array(),
|
178 |
-
'message' => 'log',
|
179 |
-
);
|
180 |
-
|
181 |
-
$message = json_decode($formatter->format($record), true);
|
182 |
-
|
183 |
-
$this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
|
184 |
-
$this->assertEquals("1", $message['@version']);
|
185 |
-
$this->assertEquals('log', $message['message']);
|
186 |
-
$this->assertEquals('meh', $message['channel']);
|
187 |
-
$this->assertEquals('ERROR', $message['level']);
|
188 |
-
$this->assertEquals('test', $message['type']);
|
189 |
-
$this->assertEquals('hostname', $message['host']);
|
190 |
-
|
191 |
-
$formatter = new LogstashFormatter('mysystem', null, null, 'ctxt_', LogstashFormatter::V1);
|
192 |
-
|
193 |
-
$message = json_decode($formatter->format($record), true);
|
194 |
-
|
195 |
-
$this->assertEquals('mysystem', $message['type']);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
200 |
-
*/
|
201 |
-
public function testFormatWithFileAndLineV1()
|
202 |
-
{
|
203 |
-
$formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
|
204 |
-
$record = array(
|
205 |
-
'level' => Logger::ERROR,
|
206 |
-
'level_name' => 'ERROR',
|
207 |
-
'channel' => 'meh',
|
208 |
-
'context' => array('from' => 'logger'),
|
209 |
-
'datetime' => new \DateTime("@0"),
|
210 |
-
'extra' => array('file' => 'test', 'line' => 14),
|
211 |
-
'message' => 'log',
|
212 |
-
);
|
213 |
-
|
214 |
-
$message = json_decode($formatter->format($record), true);
|
215 |
-
|
216 |
-
$this->assertEquals('test', $message['file']);
|
217 |
-
$this->assertEquals(14, $message['line']);
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
222 |
-
*/
|
223 |
-
public function testFormatWithContextV1()
|
224 |
-
{
|
225 |
-
$formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
|
226 |
-
$record = array(
|
227 |
-
'level' => Logger::ERROR,
|
228 |
-
'level_name' => 'ERROR',
|
229 |
-
'channel' => 'meh',
|
230 |
-
'context' => array('from' => 'logger'),
|
231 |
-
'datetime' => new \DateTime("@0"),
|
232 |
-
'extra' => array('key' => 'pair'),
|
233 |
-
'message' => 'log',
|
234 |
-
);
|
235 |
-
|
236 |
-
$message = json_decode($formatter->format($record), true);
|
237 |
-
|
238 |
-
$this->assertArrayHasKey('ctxt_from', $message);
|
239 |
-
$this->assertEquals('logger', $message['ctxt_from']);
|
240 |
-
|
241 |
-
// Test with extraPrefix
|
242 |
-
$formatter = new LogstashFormatter('test', null, null, 'CTX', LogstashFormatter::V1);
|
243 |
-
$message = json_decode($formatter->format($record), true);
|
244 |
-
|
245 |
-
$this->assertArrayHasKey('CTXfrom', $message);
|
246 |
-
$this->assertEquals('logger', $message['CTXfrom']);
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* @covers Monolog\Formatter\LogstashFormatter::format
|
251 |
-
*/
|
252 |
-
public function testFormatWithExtraV1()
|
253 |
-
{
|
254 |
-
$formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
|
255 |
-
$record = array(
|
256 |
-
'level' => Logger::ERROR,
|
257 |
-
'level_name' => 'ERROR',
|
258 |
-
'channel' => 'meh',
|
259 |
-
'context' => array('from' => 'logger'),
|
260 |
-
'datetime' => new \DateTime("@0"),
|
261 |
-
'extra' => array('key' => 'pair'),
|
262 |
-
'message' => 'log',
|
263 |
-
);
|
264 |
-
|
265 |
-
$message = json_decode($formatter->format($record), true);
|
266 |
-
|
267 |
-
$this->assertArrayHasKey('key', $message);
|
268 |
-
$this->assertEquals('pair', $message['key']);
|
269 |
-
|
270 |
-
// Test with extraPrefix
|
271 |
-
$formatter = new LogstashFormatter('test', null, 'EXT', 'ctxt_', LogstashFormatter::V1);
|
272 |
-
$message = json_decode($formatter->format($record), true);
|
273 |
-
|
274 |
-
$this->assertArrayHasKey('EXTkey', $message);
|
275 |
-
$this->assertEquals('pair', $message['EXTkey']);
|
276 |
-
}
|
277 |
-
|
278 |
-
public function testFormatWithApplicationNameV1()
|
279 |
-
{
|
280 |
-
$formatter = new LogstashFormatter('app', 'test', null, 'ctxt_', LogstashFormatter::V1);
|
281 |
-
$record = array(
|
282 |
-
'level' => Logger::ERROR,
|
283 |
-
'level_name' => 'ERROR',
|
284 |
-
'channel' => 'meh',
|
285 |
-
'context' => array('from' => 'logger'),
|
286 |
-
'datetime' => new \DateTime("@0"),
|
287 |
-
'extra' => array('key' => 'pair'),
|
288 |
-
'message' => 'log',
|
289 |
-
);
|
290 |
-
|
291 |
-
$message = json_decode($formatter->format($record), true);
|
292 |
-
|
293 |
-
$this->assertArrayHasKey('type', $message);
|
294 |
-
$this->assertEquals('app', $message['type']);
|
295 |
-
}
|
296 |
-
|
297 |
-
public function testFormatWithLatin9Data()
|
298 |
-
{
|
299 |
-
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
|
300 |
-
// Ignore the warning that will be emitted by PHP <5.5.0
|
301 |
-
\PHPUnit_Framework_Error_Warning::$enabled = false;
|
302 |
-
}
|
303 |
-
$formatter = new LogstashFormatter('test', 'hostname');
|
304 |
-
$record = array(
|
305 |
-
'level' => Logger::ERROR,
|
306 |
-
'level_name' => 'ERROR',
|
307 |
-
'channel' => '¯\_(ツ)_/¯',
|
308 |
-
'context' => array(),
|
309 |
-
'datetime' => new \DateTime("@0"),
|
310 |
-
'extra' => array(
|
311 |
-
'user_agent' => "\xD6WN; FBCR/OrangeEspa\xF1a; Vers\xE3o/4.0; F\xE4rist",
|
312 |
-
),
|
313 |
-
'message' => 'log',
|
314 |
-
);
|
315 |
-
|
316 |
-
$message = json_decode($formatter->format($record), true);
|
317 |
-
|
318 |
-
$this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
|
319 |
-
$this->assertEquals('log', $message['@message']);
|
320 |
-
$this->assertEquals('¯\_(ツ)_/¯', $message['@fields']['channel']);
|
321 |
-
$this->assertContains('¯\_(ツ)_/¯', $message['@tags']);
|
322 |
-
$this->assertEquals(Logger::ERROR, $message['@fields']['level']);
|
323 |
-
$this->assertEquals('test', $message['@type']);
|
324 |
-
$this->assertEquals('hostname', $message['@source']);
|
325 |
-
if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
|
326 |
-
$this->assertEquals('ÖWN; FBCR/OrangeEspaña; Versão/4.0; Färist', $message['@fields']['user_agent']);
|
327 |
-
} else {
|
328 |
-
// PHP <5.5 does not return false for an element encoding failure,
|
329 |
-
// instead it emits a warning (possibly) and nulls the value.
|
330 |
-
$this->assertEquals(null, $message['@fields']['user_agent']);
|
331 |
-
}
|
332 |
-
}
|
333 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php
DELETED
@@ -1,262 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Florian Plattner <me@florianplattner.de>
|
18 |
-
*/
|
19 |
-
class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
20 |
-
{
|
21 |
-
public function setUp()
|
22 |
-
{
|
23 |
-
if (!class_exists('MongoDate')) {
|
24 |
-
$this->markTestSkipped('mongo extension not installed');
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
public function constructArgumentProvider()
|
29 |
-
{
|
30 |
-
return array(
|
31 |
-
array(1, true, 1, true),
|
32 |
-
array(0, false, 0, false),
|
33 |
-
);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @param $traceDepth
|
38 |
-
* @param $traceAsString
|
39 |
-
* @param $expectedTraceDepth
|
40 |
-
* @param $expectedTraceAsString
|
41 |
-
*
|
42 |
-
* @dataProvider constructArgumentProvider
|
43 |
-
*/
|
44 |
-
public function testConstruct($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString)
|
45 |
-
{
|
46 |
-
$formatter = new MongoDBFormatter($traceDepth, $traceAsString);
|
47 |
-
|
48 |
-
$reflTrace = new \ReflectionProperty($formatter, 'exceptionTraceAsString');
|
49 |
-
$reflTrace->setAccessible(true);
|
50 |
-
$this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter));
|
51 |
-
|
52 |
-
$reflDepth = new\ReflectionProperty($formatter, 'maxNestingLevel');
|
53 |
-
$reflDepth->setAccessible(true);
|
54 |
-
$this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter));
|
55 |
-
}
|
56 |
-
|
57 |
-
public function testSimpleFormat()
|
58 |
-
{
|
59 |
-
$record = array(
|
60 |
-
'message' => 'some log message',
|
61 |
-
'context' => array(),
|
62 |
-
'level' => Logger::WARNING,
|
63 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
64 |
-
'channel' => 'test',
|
65 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
66 |
-
'extra' => array(),
|
67 |
-
);
|
68 |
-
|
69 |
-
$formatter = new MongoDBFormatter();
|
70 |
-
$formattedRecord = $formatter->format($record);
|
71 |
-
|
72 |
-
$this->assertCount(7, $formattedRecord);
|
73 |
-
$this->assertEquals('some log message', $formattedRecord['message']);
|
74 |
-
$this->assertEquals(array(), $formattedRecord['context']);
|
75 |
-
$this->assertEquals(Logger::WARNING, $formattedRecord['level']);
|
76 |
-
$this->assertEquals(Logger::getLevelName(Logger::WARNING), $formattedRecord['level_name']);
|
77 |
-
$this->assertEquals('test', $formattedRecord['channel']);
|
78 |
-
$this->assertInstanceOf('\MongoDate', $formattedRecord['datetime']);
|
79 |
-
$this->assertEquals('0.00000000 1391212800', $formattedRecord['datetime']->__toString());
|
80 |
-
$this->assertEquals(array(), $formattedRecord['extra']);
|
81 |
-
}
|
82 |
-
|
83 |
-
public function testRecursiveFormat()
|
84 |
-
{
|
85 |
-
$someObject = new \stdClass();
|
86 |
-
$someObject->foo = 'something';
|
87 |
-
$someObject->bar = 'stuff';
|
88 |
-
|
89 |
-
$record = array(
|
90 |
-
'message' => 'some log message',
|
91 |
-
'context' => array(
|
92 |
-
'stuff' => new \DateTime('2014-02-01 02:31:33'),
|
93 |
-
'some_object' => $someObject,
|
94 |
-
'context_string' => 'some string',
|
95 |
-
'context_int' => 123456,
|
96 |
-
'except' => new \Exception('exception message', 987),
|
97 |
-
),
|
98 |
-
'level' => Logger::WARNING,
|
99 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
100 |
-
'channel' => 'test',
|
101 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
102 |
-
'extra' => array(),
|
103 |
-
);
|
104 |
-
|
105 |
-
$formatter = new MongoDBFormatter();
|
106 |
-
$formattedRecord = $formatter->format($record);
|
107 |
-
|
108 |
-
$this->assertCount(5, $formattedRecord['context']);
|
109 |
-
$this->assertInstanceOf('\MongoDate', $formattedRecord['context']['stuff']);
|
110 |
-
$this->assertEquals('0.00000000 1391221893', $formattedRecord['context']['stuff']->__toString());
|
111 |
-
$this->assertEquals(
|
112 |
-
array(
|
113 |
-
'foo' => 'something',
|
114 |
-
'bar' => 'stuff',
|
115 |
-
'class' => 'stdClass',
|
116 |
-
),
|
117 |
-
$formattedRecord['context']['some_object']
|
118 |
-
);
|
119 |
-
$this->assertEquals('some string', $formattedRecord['context']['context_string']);
|
120 |
-
$this->assertEquals(123456, $formattedRecord['context']['context_int']);
|
121 |
-
|
122 |
-
$this->assertCount(5, $formattedRecord['context']['except']);
|
123 |
-
$this->assertEquals('exception message', $formattedRecord['context']['except']['message']);
|
124 |
-
$this->assertEquals(987, $formattedRecord['context']['except']['code']);
|
125 |
-
$this->assertInternalType('string', $formattedRecord['context']['except']['file']);
|
126 |
-
$this->assertInternalType('integer', $formattedRecord['context']['except']['code']);
|
127 |
-
$this->assertInternalType('string', $formattedRecord['context']['except']['trace']);
|
128 |
-
$this->assertEquals('Exception', $formattedRecord['context']['except']['class']);
|
129 |
-
}
|
130 |
-
|
131 |
-
public function testFormatDepthArray()
|
132 |
-
{
|
133 |
-
$record = array(
|
134 |
-
'message' => 'some log message',
|
135 |
-
'context' => array(
|
136 |
-
'nest2' => array(
|
137 |
-
'property' => 'anything',
|
138 |
-
'nest3' => array(
|
139 |
-
'nest4' => 'value',
|
140 |
-
'property' => 'nothing',
|
141 |
-
),
|
142 |
-
),
|
143 |
-
),
|
144 |
-
'level' => Logger::WARNING,
|
145 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
146 |
-
'channel' => 'test',
|
147 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
148 |
-
'extra' => array(),
|
149 |
-
);
|
150 |
-
|
151 |
-
$formatter = new MongoDBFormatter(2);
|
152 |
-
$formattedResult = $formatter->format($record);
|
153 |
-
|
154 |
-
$this->assertEquals(
|
155 |
-
array(
|
156 |
-
'nest2' => array(
|
157 |
-
'property' => 'anything',
|
158 |
-
'nest3' => '[...]',
|
159 |
-
),
|
160 |
-
),
|
161 |
-
$formattedResult['context']
|
162 |
-
);
|
163 |
-
}
|
164 |
-
|
165 |
-
public function testFormatDepthArrayInfiniteNesting()
|
166 |
-
{
|
167 |
-
$record = array(
|
168 |
-
'message' => 'some log message',
|
169 |
-
'context' => array(
|
170 |
-
'nest2' => array(
|
171 |
-
'property' => 'something',
|
172 |
-
'nest3' => array(
|
173 |
-
'property' => 'anything',
|
174 |
-
'nest4' => array(
|
175 |
-
'property' => 'nothing',
|
176 |
-
),
|
177 |
-
),
|
178 |
-
),
|
179 |
-
),
|
180 |
-
'level' => Logger::WARNING,
|
181 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
182 |
-
'channel' => 'test',
|
183 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
184 |
-
'extra' => array(),
|
185 |
-
);
|
186 |
-
|
187 |
-
$formatter = new MongoDBFormatter(0);
|
188 |
-
$formattedResult = $formatter->format($record);
|
189 |
-
|
190 |
-
$this->assertEquals(
|
191 |
-
array(
|
192 |
-
'nest2' => array(
|
193 |
-
'property' => 'something',
|
194 |
-
'nest3' => array(
|
195 |
-
'property' => 'anything',
|
196 |
-
'nest4' => array(
|
197 |
-
'property' => 'nothing',
|
198 |
-
),
|
199 |
-
),
|
200 |
-
),
|
201 |
-
),
|
202 |
-
$formattedResult['context']
|
203 |
-
);
|
204 |
-
}
|
205 |
-
|
206 |
-
public function testFormatDepthObjects()
|
207 |
-
{
|
208 |
-
$someObject = new \stdClass();
|
209 |
-
$someObject->property = 'anything';
|
210 |
-
$someObject->nest3 = new \stdClass();
|
211 |
-
$someObject->nest3->property = 'nothing';
|
212 |
-
$someObject->nest3->nest4 = 'invisible';
|
213 |
-
|
214 |
-
$record = array(
|
215 |
-
'message' => 'some log message',
|
216 |
-
'context' => array(
|
217 |
-
'nest2' => $someObject,
|
218 |
-
),
|
219 |
-
'level' => Logger::WARNING,
|
220 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
221 |
-
'channel' => 'test',
|
222 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
223 |
-
'extra' => array(),
|
224 |
-
);
|
225 |
-
|
226 |
-
$formatter = new MongoDBFormatter(2, true);
|
227 |
-
$formattedResult = $formatter->format($record);
|
228 |
-
|
229 |
-
$this->assertEquals(
|
230 |
-
array(
|
231 |
-
'nest2' => array(
|
232 |
-
'property' => 'anything',
|
233 |
-
'nest3' => '[...]',
|
234 |
-
'class' => 'stdClass',
|
235 |
-
),
|
236 |
-
),
|
237 |
-
$formattedResult['context']
|
238 |
-
);
|
239 |
-
}
|
240 |
-
|
241 |
-
public function testFormatDepthException()
|
242 |
-
{
|
243 |
-
$record = array(
|
244 |
-
'message' => 'some log message',
|
245 |
-
'context' => array(
|
246 |
-
'nest2' => new \Exception('exception message', 987),
|
247 |
-
),
|
248 |
-
'level' => Logger::WARNING,
|
249 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
250 |
-
'channel' => 'test',
|
251 |
-
'datetime' => new \DateTime('2014-02-01 00:00:00'),
|
252 |
-
'extra' => array(),
|
253 |
-
);
|
254 |
-
|
255 |
-
$formatter = new MongoDBFormatter(2, false);
|
256 |
-
$formattedRecord = $formatter->format($record);
|
257 |
-
|
258 |
-
$this->assertEquals('exception message', $formattedRecord['context']['nest2']['message']);
|
259 |
-
$this->assertEquals(987, $formattedRecord['context']['nest2']['code']);
|
260 |
-
$this->assertEquals('[...]', $formattedRecord['context']['nest2']['trace']);
|
261 |
-
}
|
262 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
DELETED
@@ -1,481 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @covers Monolog\Formatter\NormalizerFormatter
|
16 |
-
*/
|
17 |
-
class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
18 |
-
{
|
19 |
-
public function tearDown()
|
20 |
-
{
|
21 |
-
\PHPUnit_Framework_Error_Warning::$enabled = true;
|
22 |
-
|
23 |
-
return parent::tearDown();
|
24 |
-
}
|
25 |
-
|
26 |
-
public function testFormat()
|
27 |
-
{
|
28 |
-
$formatter = new NormalizerFormatter('Y-m-d');
|
29 |
-
$formatted = $formatter->format(array(
|
30 |
-
'level_name' => 'ERROR',
|
31 |
-
'channel' => 'meh',
|
32 |
-
'message' => 'foo',
|
33 |
-
'datetime' => new \DateTime,
|
34 |
-
'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
35 |
-
'context' => array(
|
36 |
-
'foo' => 'bar',
|
37 |
-
'baz' => 'qux',
|
38 |
-
'inf' => INF,
|
39 |
-
'-inf' => -INF,
|
40 |
-
'nan' => acos(4),
|
41 |
-
),
|
42 |
-
));
|
43 |
-
|
44 |
-
$this->assertEquals(array(
|
45 |
-
'level_name' => 'ERROR',
|
46 |
-
'channel' => 'meh',
|
47 |
-
'message' => 'foo',
|
48 |
-
'datetime' => date('Y-m-d'),
|
49 |
-
'extra' => array(
|
50 |
-
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
|
51 |
-
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
|
52 |
-
'baz' => array(),
|
53 |
-
'res' => '[resource] (stream)',
|
54 |
-
),
|
55 |
-
'context' => array(
|
56 |
-
'foo' => 'bar',
|
57 |
-
'baz' => 'qux',
|
58 |
-
'inf' => 'INF',
|
59 |
-
'-inf' => '-INF',
|
60 |
-
'nan' => 'NaN',
|
61 |
-
),
|
62 |
-
), $formatted);
|
63 |
-
}
|
64 |
-
|
65 |
-
public function testFormatExceptions()
|
66 |
-
{
|
67 |
-
$formatter = new NormalizerFormatter('Y-m-d');
|
68 |
-
$e = new \LogicException('bar');
|
69 |
-
$e2 = new \RuntimeException('foo', 0, $e);
|
70 |
-
$formatted = $formatter->format(array(
|
71 |
-
'exception' => $e2,
|
72 |
-
));
|
73 |
-
|
74 |
-
$this->assertGreaterThan(5, count($formatted['exception']['trace']));
|
75 |
-
$this->assertTrue(isset($formatted['exception']['previous']));
|
76 |
-
unset($formatted['exception']['trace'], $formatted['exception']['previous']);
|
77 |
-
|
78 |
-
$this->assertEquals(array(
|
79 |
-
'exception' => array(
|
80 |
-
'class' => get_class($e2),
|
81 |
-
'message' => $e2->getMessage(),
|
82 |
-
'code' => $e2->getCode(),
|
83 |
-
'file' => $e2->getFile().':'.$e2->getLine(),
|
84 |
-
),
|
85 |
-
), $formatted);
|
86 |
-
}
|
87 |
-
|
88 |
-
public function testFormatSoapFaultException()
|
89 |
-
{
|
90 |
-
if (!class_exists('SoapFault')) {
|
91 |
-
$this->markTestSkipped('Requires the soap extension');
|
92 |
-
}
|
93 |
-
|
94 |
-
$formatter = new NormalizerFormatter('Y-m-d');
|
95 |
-
$e = new \SoapFault('foo', 'bar', 'hello', 'world');
|
96 |
-
$formatted = $formatter->format(array(
|
97 |
-
'exception' => $e,
|
98 |
-
));
|
99 |
-
|
100 |
-
unset($formatted['exception']['trace']);
|
101 |
-
|
102 |
-
$this->assertEquals(array(
|
103 |
-
'exception' => array(
|
104 |
-
'class' => 'SoapFault',
|
105 |
-
'message' => 'bar',
|
106 |
-
'code' => 0,
|
107 |
-
'file' => $e->getFile().':'.$e->getLine(),
|
108 |
-
'faultcode' => 'foo',
|
109 |
-
'faultactor' => 'hello',
|
110 |
-
'detail' => 'world',
|
111 |
-
),
|
112 |
-
), $formatted);
|
113 |
-
}
|
114 |
-
|
115 |
-
public function testFormatToStringExceptionHandle()
|
116 |
-
{
|
117 |
-
$formatter = new NormalizerFormatter('Y-m-d');
|
118 |
-
$this->setExpectedException('RuntimeException', 'Could not convert to string');
|
119 |
-
$formatter->format(array(
|
120 |
-
'myObject' => new TestToStringError(),
|
121 |
-
));
|
122 |
-
}
|
123 |
-
|
124 |
-
public function testBatchFormat()
|
125 |
-
{
|
126 |
-
$formatter = new NormalizerFormatter('Y-m-d');
|
127 |
-
$formatted = $formatter->formatBatch(array(
|
128 |
-
array(
|
129 |
-
'level_name' => 'CRITICAL',
|
130 |
-
'channel' => 'test',
|
131 |
-
'message' => 'bar',
|
132 |
-
'context' => array(),
|
133 |
-
'datetime' => new \DateTime,
|
134 |
-
'extra' => array(),
|
135 |
-
),
|
136 |
-
array(
|
137 |
-
'level_name' => 'WARNING',
|
138 |
-
'channel' => 'log',
|
139 |
-
'message' => 'foo',
|
140 |
-
'context' => array(),
|
141 |
-
'datetime' => new \DateTime,
|
142 |
-
'extra' => array(),
|
143 |
-
),
|
144 |
-
));
|
145 |
-
$this->assertEquals(array(
|
146 |
-
array(
|
147 |
-
'level_name' => 'CRITICAL',
|
148 |
-
'channel' => 'test',
|
149 |
-
'message' => 'bar',
|
150 |
-
'context' => array(),
|
151 |
-
'datetime' => date('Y-m-d'),
|
152 |
-
'extra' => array(),
|
153 |
-
),
|
154 |
-
array(
|
155 |
-
'level_name' => 'WARNING',
|
156 |
-
'channel' => 'log',
|
157 |
-
'message' => 'foo',
|
158 |
-
'context' => array(),
|
159 |
-
'datetime' => date('Y-m-d'),
|
160 |
-
'extra' => array(),
|
161 |
-
),
|
162 |
-
), $formatted);
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Test issue #137
|
167 |
-
*/
|
168 |
-
public function testIgnoresRecursiveObjectReferences()
|
169 |
-
{
|
170 |
-
// set up the recursion
|
171 |
-
$foo = new \stdClass();
|
172 |
-
$bar = new \stdClass();
|
173 |
-
|
174 |
-
$foo->bar = $bar;
|
175 |
-
$bar->foo = $foo;
|
176 |
-
|
177 |
-
// set an error handler to assert that the error is not raised anymore
|
178 |
-
$that = $this;
|
179 |
-
set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
|
180 |
-
if (error_reporting() & $level) {
|
181 |
-
restore_error_handler();
|
182 |
-
$that->fail("$message should not be raised");
|
183 |
-
}
|
184 |
-
});
|
185 |
-
|
186 |
-
$formatter = new NormalizerFormatter();
|
187 |
-
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
188 |
-
$reflMethod->setAccessible(true);
|
189 |
-
$res = $reflMethod->invoke($formatter, array($foo, $bar), true);
|
190 |
-
|
191 |
-
restore_error_handler();
|
192 |
-
|
193 |
-
$this->assertEquals(@json_encode(array($foo, $bar)), $res);
|
194 |
-
}
|
195 |
-
|
196 |
-
public function testCanNormalizeReferences()
|
197 |
-
{
|
198 |
-
$formatter = new NormalizerFormatter();
|
199 |
-
$x = array('foo' => 'bar');
|
200 |
-
$y = array('x' => &$x);
|
201 |
-
$x['y'] = &$y;
|
202 |
-
$formatter->format($y);
|
203 |
-
}
|
204 |
-
|
205 |
-
public function testIgnoresInvalidTypes()
|
206 |
-
{
|
207 |
-
// set up the recursion
|
208 |
-
$resource = fopen(__FILE__, 'r');
|
209 |
-
|
210 |
-
// set an error handler to assert that the error is not raised anymore
|
211 |
-
$that = $this;
|
212 |
-
set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
|
213 |
-
if (error_reporting() & $level) {
|
214 |
-
restore_error_handler();
|
215 |
-
$that->fail("$message should not be raised");
|
216 |
-
}
|
217 |
-
});
|
218 |
-
|
219 |
-
$formatter = new NormalizerFormatter();
|
220 |
-
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
221 |
-
$reflMethod->setAccessible(true);
|
222 |
-
$res = $reflMethod->invoke($formatter, array($resource), true);
|
223 |
-
|
224 |
-
restore_error_handler();
|
225 |
-
|
226 |
-
$this->assertEquals(@json_encode(array($resource)), $res);
|
227 |
-
}
|
228 |
-
|
229 |
-
public function testNormalizeHandleLargeArraysWithExactly1000Items()
|
230 |
-
{
|
231 |
-
$formatter = new NormalizerFormatter();
|
232 |
-
$largeArray = range(1, 1000);
|
233 |
-
|
234 |
-
$res = $formatter->format(array(
|
235 |
-
'level_name' => 'CRITICAL',
|
236 |
-
'channel' => 'test',
|
237 |
-
'message' => 'bar',
|
238 |
-
'context' => array($largeArray),
|
239 |
-
'datetime' => new \DateTime,
|
240 |
-
'extra' => array(),
|
241 |
-
));
|
242 |
-
|
243 |
-
$this->assertCount(1000, $res['context'][0]);
|
244 |
-
$this->assertArrayNotHasKey('...', $res['context'][0]);
|
245 |
-
}
|
246 |
-
|
247 |
-
public function testNormalizeHandleLargeArrays()
|
248 |
-
{
|
249 |
-
$formatter = new NormalizerFormatter();
|
250 |
-
$largeArray = range(1, 2000);
|
251 |
-
|
252 |
-
$res = $formatter->format(array(
|
253 |
-
'level_name' => 'CRITICAL',
|
254 |
-
'channel' => 'test',
|
255 |
-
'message' => 'bar',
|
256 |
-
'context' => array($largeArray),
|
257 |
-
'datetime' => new \DateTime,
|
258 |
-
'extra' => array(),
|
259 |
-
));
|
260 |
-
|
261 |
-
$this->assertCount(1001, $res['context'][0]);
|
262 |
-
$this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* @expectedException RuntimeException
|
267 |
-
*/
|
268 |
-
public function testThrowsOnInvalidEncoding()
|
269 |
-
{
|
270 |
-
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
|
271 |
-
// Ignore the warning that will be emitted by PHP <5.5.0
|
272 |
-
\PHPUnit_Framework_Error_Warning::$enabled = false;
|
273 |
-
}
|
274 |
-
$formatter = new NormalizerFormatter();
|
275 |
-
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
276 |
-
$reflMethod->setAccessible(true);
|
277 |
-
|
278 |
-
// send an invalid unicode sequence as a object that can't be cleaned
|
279 |
-
$record = new \stdClass;
|
280 |
-
$record->message = "\xB1\x31";
|
281 |
-
$res = $reflMethod->invoke($formatter, $record);
|
282 |
-
if (PHP_VERSION_ID < 50500 && $res === '{"message":null}') {
|
283 |
-
throw new \RuntimeException('PHP 5.3/5.4 throw a warning and null the value instead of returning false entirely');
|
284 |
-
}
|
285 |
-
}
|
286 |
-
|
287 |
-
public function testConvertsInvalidEncodingAsLatin9()
|
288 |
-
{
|
289 |
-
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
|
290 |
-
// Ignore the warning that will be emitted by PHP <5.5.0
|
291 |
-
\PHPUnit_Framework_Error_Warning::$enabled = false;
|
292 |
-
}
|
293 |
-
$formatter = new NormalizerFormatter();
|
294 |
-
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
295 |
-
$reflMethod->setAccessible(true);
|
296 |
-
|
297 |
-
$res = $reflMethod->invoke($formatter, array('message' => "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"));
|
298 |
-
|
299 |
-
if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
|
300 |
-
$this->assertSame('{"message":"€ŠšŽžŒœŸ"}', $res);
|
301 |
-
} else {
|
302 |
-
// PHP <5.5 does not return false for an element encoding failure,
|
303 |
-
// instead it emits a warning (possibly) and nulls the value.
|
304 |
-
$this->assertSame('{"message":null}', $res);
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* @param mixed $in Input
|
310 |
-
* @param mixed $expect Expected output
|
311 |
-
* @covers Monolog\Formatter\NormalizerFormatter::detectAndCleanUtf8
|
312 |
-
* @dataProvider providesDetectAndCleanUtf8
|
313 |
-
*/
|
314 |
-
public function testDetectAndCleanUtf8($in, $expect)
|
315 |
-
{
|
316 |
-
$formatter = new NormalizerFormatter();
|
317 |
-
$formatter->detectAndCleanUtf8($in);
|
318 |
-
$this->assertSame($expect, $in);
|
319 |
-
}
|
320 |
-
|
321 |
-
public function providesDetectAndCleanUtf8()
|
322 |
-
{
|
323 |
-
$obj = new \stdClass;
|
324 |
-
|
325 |
-
return array(
|
326 |
-
'null' => array(null, null),
|
327 |
-
'int' => array(123, 123),
|
328 |
-
'float' => array(123.45, 123.45),
|
329 |
-
'bool false' => array(false, false),
|
330 |
-
'bool true' => array(true, true),
|
331 |
-
'ascii string' => array('abcdef', 'abcdef'),
|
332 |
-
'latin9 string' => array("\xB1\x31\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xFF", '±1€ŠšŽžŒœŸÿ'),
|
333 |
-
'unicode string' => array('¤¦¨´¸¼½¾€ŠšŽžŒœŸ', '¤¦¨´¸¼½¾€ŠšŽžŒœŸ'),
|
334 |
-
'empty array' => array(array(), array()),
|
335 |
-
'array' => array(array('abcdef'), array('abcdef')),
|
336 |
-
'object' => array($obj, $obj),
|
337 |
-
);
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* @param int $code
|
342 |
-
* @param string $msg
|
343 |
-
* @dataProvider providesHandleJsonErrorFailure
|
344 |
-
*/
|
345 |
-
public function testHandleJsonErrorFailure($code, $msg)
|
346 |
-
{
|
347 |
-
$formatter = new NormalizerFormatter();
|
348 |
-
$reflMethod = new \ReflectionMethod($formatter, 'handleJsonError');
|
349 |
-
$reflMethod->setAccessible(true);
|
350 |
-
|
351 |
-
$this->setExpectedException('RuntimeException', $msg);
|
352 |
-
$reflMethod->invoke($formatter, $code, 'faked');
|
353 |
-
}
|
354 |
-
|
355 |
-
public function providesHandleJsonErrorFailure()
|
356 |
-
{
|
357 |
-
return array(
|
358 |
-
'depth' => array(JSON_ERROR_DEPTH, 'Maximum stack depth exceeded'),
|
359 |
-
'state' => array(JSON_ERROR_STATE_MISMATCH, 'Underflow or the modes mismatch'),
|
360 |
-
'ctrl' => array(JSON_ERROR_CTRL_CHAR, 'Unexpected control character found'),
|
361 |
-
'default' => array(-1, 'Unknown error'),
|
362 |
-
);
|
363 |
-
}
|
364 |
-
|
365 |
-
public function testExceptionTraceWithArgs()
|
366 |
-
{
|
367 |
-
if (defined('HHVM_VERSION')) {
|
368 |
-
$this->markTestSkipped('Not supported in HHVM since it detects errors differently');
|
369 |
-
}
|
370 |
-
|
371 |
-
// This happens i.e. in React promises or Guzzle streams where stream wrappers are registered
|
372 |
-
// and no file or line are included in the trace because it's treated as internal function
|
373 |
-
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
374 |
-
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
375 |
-
});
|
376 |
-
|
377 |
-
try {
|
378 |
-
// This will contain $resource and $wrappedResource as arguments in the trace item
|
379 |
-
$resource = fopen('php://memory', 'rw+');
|
380 |
-
fwrite($resource, 'test_resource');
|
381 |
-
$wrappedResource = new TestFooNorm;
|
382 |
-
$wrappedResource->foo = $resource;
|
383 |
-
// Just do something stupid with a resource/wrapped resource as argument
|
384 |
-
array_keys($wrappedResource);
|
385 |
-
} catch (\Exception $e) {
|
386 |
-
restore_error_handler();
|
387 |
-
}
|
388 |
-
|
389 |
-
$formatter = new NormalizerFormatter();
|
390 |
-
$record = array('context' => array('exception' => $e));
|
391 |
-
$result = $formatter->format($record);
|
392 |
-
|
393 |
-
$this->assertRegExp(
|
394 |
-
'%"resource":"\[resource\] \(stream\)"%',
|
395 |
-
$result['context']['exception']['trace'][0]
|
396 |
-
);
|
397 |
-
|
398 |
-
if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
|
399 |
-
$pattern = '%"wrappedResource":"\[object\] \(Monolog\\\\\\\\Formatter\\\\\\\\TestFooNorm: \)"%';
|
400 |
-
} else {
|
401 |
-
$pattern = '%\\\\"foo\\\\":null%';
|
402 |
-
}
|
403 |
-
|
404 |
-
// Tests that the wrapped resource is ignored while encoding, only works for PHP <= 5.4
|
405 |
-
$this->assertRegExp(
|
406 |
-
$pattern,
|
407 |
-
$result['context']['exception']['trace'][0]
|
408 |
-
);
|
409 |
-
}
|
410 |
-
|
411 |
-
public function testExceptionTraceDoesNotLeakCallUserFuncArgs()
|
412 |
-
{
|
413 |
-
try {
|
414 |
-
$arg = new TestInfoLeak;
|
415 |
-
call_user_func(array($this, 'throwHelper'), $arg, $dt = new \DateTime());
|
416 |
-
} catch (\Exception $e) {
|
417 |
-
}
|
418 |
-
|
419 |
-
$formatter = new NormalizerFormatter();
|
420 |
-
$record = array('context' => array('exception' => $e));
|
421 |
-
$result = $formatter->format($record);
|
422 |
-
|
423 |
-
$this->assertSame(
|
424 |
-
'{"function":"throwHelper","class":"Monolog\\\\Formatter\\\\NormalizerFormatterTest","type":"->","args":["[object] (Monolog\\\\Formatter\\\\TestInfoLeak)","'.$dt->format('Y-m-d H:i:s').'"]}',
|
425 |
-
$result['context']['exception']['trace'][0]
|
426 |
-
);
|
427 |
-
}
|
428 |
-
|
429 |
-
private function throwHelper($arg)
|
430 |
-
{
|
431 |
-
throw new \RuntimeException('Thrown');
|
432 |
-
}
|
433 |
-
}
|
434 |
-
|
435 |
-
class TestFooNorm
|
436 |
-
{
|
437 |
-
public $foo = 'foo';
|
438 |
-
}
|
439 |
-
|
440 |
-
class TestBarNorm
|
441 |
-
{
|
442 |
-
public function __toString()
|
443 |
-
{
|
444 |
-
return 'bar';
|
445 |
-
}
|
446 |
-
}
|
447 |
-
|
448 |
-
class TestStreamFoo
|
449 |
-
{
|
450 |
-
public $foo;
|
451 |
-
public $resource;
|
452 |
-
|
453 |
-
public function __construct($resource)
|
454 |
-
{
|
455 |
-
$this->resource = $resource;
|
456 |
-
$this->foo = 'BAR';
|
457 |
-
}
|
458 |
-
|
459 |
-
public function __toString()
|
460 |
-
{
|
461 |
-
fseek($this->resource, 0);
|
462 |
-
|
463 |
-
return $this->foo . ' - ' . (string) stream_get_contents($this->resource);
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
class TestToStringError
|
468 |
-
{
|
469 |
-
public function __toString()
|
470 |
-
{
|
471 |
-
throw new \RuntimeException('Could not convert to string');
|
472 |
-
}
|
473 |
-
}
|
474 |
-
|
475 |
-
class TestInfoLeak
|
476 |
-
{
|
477 |
-
public function __toString()
|
478 |
-
{
|
479 |
-
return 'Sensitive information';
|
480 |
-
}
|
481 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php
DELETED
@@ -1,110 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
class ScalarFormatterTest extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
private $formatter;
|
17 |
-
|
18 |
-
public function setUp()
|
19 |
-
{
|
20 |
-
$this->formatter = new ScalarFormatter();
|
21 |
-
}
|
22 |
-
|
23 |
-
public function buildTrace(\Exception $e)
|
24 |
-
{
|
25 |
-
$data = array();
|
26 |
-
$trace = $e->getTrace();
|
27 |
-
foreach ($trace as $frame) {
|
28 |
-
if (isset($frame['file'])) {
|
29 |
-
$data[] = $frame['file'].':'.$frame['line'];
|
30 |
-
} else {
|
31 |
-
$data[] = json_encode($frame);
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
return $data;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function encodeJson($data)
|
39 |
-
{
|
40 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
41 |
-
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
42 |
-
}
|
43 |
-
|
44 |
-
return json_encode($data);
|
45 |
-
}
|
46 |
-
|
47 |
-
public function testFormat()
|
48 |
-
{
|
49 |
-
$exception = new \Exception('foo');
|
50 |
-
$formatted = $this->formatter->format(array(
|
51 |
-
'foo' => 'string',
|
52 |
-
'bar' => 1,
|
53 |
-
'baz' => false,
|
54 |
-
'bam' => array(1, 2, 3),
|
55 |
-
'bat' => array('foo' => 'bar'),
|
56 |
-
'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
|
57 |
-
'ban' => $exception,
|
58 |
-
));
|
59 |
-
|
60 |
-
$this->assertSame(array(
|
61 |
-
'foo' => 'string',
|
62 |
-
'bar' => 1,
|
63 |
-
'baz' => false,
|
64 |
-
'bam' => $this->encodeJson(array(1, 2, 3)),
|
65 |
-
'bat' => $this->encodeJson(array('foo' => 'bar')),
|
66 |
-
'bap' => '1970-01-01 00:00:00',
|
67 |
-
'ban' => $this->encodeJson(array(
|
68 |
-
'class' => get_class($exception),
|
69 |
-
'message' => $exception->getMessage(),
|
70 |
-
'code' => $exception->getCode(),
|
71 |
-
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
72 |
-
'trace' => $this->buildTrace($exception),
|
73 |
-
)),
|
74 |
-
), $formatted);
|
75 |
-
}
|
76 |
-
|
77 |
-
public function testFormatWithErrorContext()
|
78 |
-
{
|
79 |
-
$context = array('file' => 'foo', 'line' => 1);
|
80 |
-
$formatted = $this->formatter->format(array(
|
81 |
-
'context' => $context,
|
82 |
-
));
|
83 |
-
|
84 |
-
$this->assertSame(array(
|
85 |
-
'context' => $this->encodeJson($context),
|
86 |
-
), $formatted);
|
87 |
-
}
|
88 |
-
|
89 |
-
public function testFormatWithExceptionContext()
|
90 |
-
{
|
91 |
-
$exception = new \Exception('foo');
|
92 |
-
$formatted = $this->formatter->format(array(
|
93 |
-
'context' => array(
|
94 |
-
'exception' => $exception,
|
95 |
-
),
|
96 |
-
));
|
97 |
-
|
98 |
-
$this->assertSame(array(
|
99 |
-
'context' => $this->encodeJson(array(
|
100 |
-
'exception' => array(
|
101 |
-
'class' => get_class($exception),
|
102 |
-
'message' => $exception->getMessage(),
|
103 |
-
'code' => $exception->getCode(),
|
104 |
-
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
105 |
-
'trace' => $this->buildTrace($exception),
|
106 |
-
),
|
107 |
-
)),
|
108 |
-
), $formatted);
|
109 |
-
}
|
110 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
DELETED
@@ -1,142 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Formatter\WildfireFormatter::format
|
20 |
-
*/
|
21 |
-
public function testDefaultFormat()
|
22 |
-
{
|
23 |
-
$wildfire = new WildfireFormatter();
|
24 |
-
$record = array(
|
25 |
-
'level' => Logger::ERROR,
|
26 |
-
'level_name' => 'ERROR',
|
27 |
-
'channel' => 'meh',
|
28 |
-
'context' => array('from' => 'logger'),
|
29 |
-
'datetime' => new \DateTime("@0"),
|
30 |
-
'extra' => array('ip' => '127.0.0.1'),
|
31 |
-
'message' => 'log',
|
32 |
-
);
|
33 |
-
|
34 |
-
$message = $wildfire->format($record);
|
35 |
-
|
36 |
-
$this->assertEquals(
|
37 |
-
'125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},'
|
38 |
-
.'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
|
39 |
-
$message
|
40 |
-
);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @covers Monolog\Formatter\WildfireFormatter::format
|
45 |
-
*/
|
46 |
-
public function testFormatWithFileAndLine()
|
47 |
-
{
|
48 |
-
$wildfire = new WildfireFormatter();
|
49 |
-
$record = array(
|
50 |
-
'level' => Logger::ERROR,
|
51 |
-
'level_name' => 'ERROR',
|
52 |
-
'channel' => 'meh',
|
53 |
-
'context' => array('from' => 'logger'),
|
54 |
-
'datetime' => new \DateTime("@0"),
|
55 |
-
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
56 |
-
'message' => 'log',
|
57 |
-
);
|
58 |
-
|
59 |
-
$message = $wildfire->format($record);
|
60 |
-
|
61 |
-
$this->assertEquals(
|
62 |
-
'129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},'
|
63 |
-
.'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
|
64 |
-
$message
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @covers Monolog\Formatter\WildfireFormatter::format
|
70 |
-
*/
|
71 |
-
public function testFormatWithoutContext()
|
72 |
-
{
|
73 |
-
$wildfire = new WildfireFormatter();
|
74 |
-
$record = array(
|
75 |
-
'level' => Logger::ERROR,
|
76 |
-
'level_name' => 'ERROR',
|
77 |
-
'channel' => 'meh',
|
78 |
-
'context' => array(),
|
79 |
-
'datetime' => new \DateTime("@0"),
|
80 |
-
'extra' => array(),
|
81 |
-
'message' => 'log',
|
82 |
-
);
|
83 |
-
|
84 |
-
$message = $wildfire->format($record);
|
85 |
-
|
86 |
-
$this->assertEquals(
|
87 |
-
'58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|',
|
88 |
-
$message
|
89 |
-
);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @covers Monolog\Formatter\WildfireFormatter::formatBatch
|
94 |
-
* @expectedException BadMethodCallException
|
95 |
-
*/
|
96 |
-
public function testBatchFormatThrowException()
|
97 |
-
{
|
98 |
-
$wildfire = new WildfireFormatter();
|
99 |
-
$record = array(
|
100 |
-
'level' => Logger::ERROR,
|
101 |
-
'level_name' => 'ERROR',
|
102 |
-
'channel' => 'meh',
|
103 |
-
'context' => array(),
|
104 |
-
'datetime' => new \DateTime("@0"),
|
105 |
-
'extra' => array(),
|
106 |
-
'message' => 'log',
|
107 |
-
);
|
108 |
-
|
109 |
-
$wildfire->formatBatch(array($record));
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* @covers Monolog\Formatter\WildfireFormatter::format
|
114 |
-
*/
|
115 |
-
public function testTableFormat()
|
116 |
-
{
|
117 |
-
$wildfire = new WildfireFormatter();
|
118 |
-
$record = array(
|
119 |
-
'level' => Logger::ERROR,
|
120 |
-
'level_name' => 'ERROR',
|
121 |
-
'channel' => 'table-channel',
|
122 |
-
'context' => array(
|
123 |
-
WildfireFormatter::TABLE => array(
|
124 |
-
array('col1', 'col2', 'col3'),
|
125 |
-
array('val1', 'val2', 'val3'),
|
126 |
-
array('foo1', 'foo2', 'foo3'),
|
127 |
-
array('bar1', 'bar2', 'bar3'),
|
128 |
-
),
|
129 |
-
),
|
130 |
-
'datetime' => new \DateTime("@0"),
|
131 |
-
'extra' => array(),
|
132 |
-
'message' => 'table-message',
|
133 |
-
);
|
134 |
-
|
135 |
-
$message = $wildfire->format($record);
|
136 |
-
|
137 |
-
$this->assertEquals(
|
138 |
-
'171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|',
|
139 |
-
$message
|
140 |
-
);
|
141 |
-
}
|
142 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
use Monolog\Processor\WebProcessor;
|
18 |
-
|
19 |
-
class AbstractHandlerTest extends TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @covers Monolog\Handler\AbstractHandler::__construct
|
23 |
-
* @covers Monolog\Handler\AbstractHandler::getLevel
|
24 |
-
* @covers Monolog\Handler\AbstractHandler::setLevel
|
25 |
-
* @covers Monolog\Handler\AbstractHandler::getBubble
|
26 |
-
* @covers Monolog\Handler\AbstractHandler::setBubble
|
27 |
-
* @covers Monolog\Handler\AbstractHandler::getFormatter
|
28 |
-
* @covers Monolog\Handler\AbstractHandler::setFormatter
|
29 |
-
*/
|
30 |
-
public function testConstructAndGetSet()
|
31 |
-
{
|
32 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
33 |
-
$this->assertEquals(Logger::WARNING, $handler->getLevel());
|
34 |
-
$this->assertEquals(false, $handler->getBubble());
|
35 |
-
|
36 |
-
$handler->setLevel(Logger::ERROR);
|
37 |
-
$handler->setBubble(true);
|
38 |
-
$handler->setFormatter($formatter = new LineFormatter);
|
39 |
-
$this->assertEquals(Logger::ERROR, $handler->getLevel());
|
40 |
-
$this->assertEquals(true, $handler->getBubble());
|
41 |
-
$this->assertSame($formatter, $handler->getFormatter());
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @covers Monolog\Handler\AbstractHandler::handleBatch
|
46 |
-
*/
|
47 |
-
public function testHandleBatch()
|
48 |
-
{
|
49 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
50 |
-
$handler->expects($this->exactly(2))
|
51 |
-
->method('handle');
|
52 |
-
$handler->handleBatch(array($this->getRecord(), $this->getRecord()));
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @covers Monolog\Handler\AbstractHandler::isHandling
|
57 |
-
*/
|
58 |
-
public function testIsHandling()
|
59 |
-
{
|
60 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
61 |
-
$this->assertTrue($handler->isHandling($this->getRecord()));
|
62 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* @covers Monolog\Handler\AbstractHandler::__construct
|
67 |
-
*/
|
68 |
-
public function testHandlesPsrStyleLevels()
|
69 |
-
{
|
70 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array('warning', false));
|
71 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
72 |
-
$handler->setLevel('debug');
|
73 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @covers Monolog\Handler\AbstractHandler::getFormatter
|
78 |
-
* @covers Monolog\Handler\AbstractHandler::getDefaultFormatter
|
79 |
-
*/
|
80 |
-
public function testGetFormatterInitializesDefault()
|
81 |
-
{
|
82 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
83 |
-
$this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter());
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @covers Monolog\Handler\AbstractHandler::pushProcessor
|
88 |
-
* @covers Monolog\Handler\AbstractHandler::popProcessor
|
89 |
-
* @expectedException LogicException
|
90 |
-
*/
|
91 |
-
public function testPushPopProcessor()
|
92 |
-
{
|
93 |
-
$logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
94 |
-
$processor1 = new WebProcessor;
|
95 |
-
$processor2 = new WebProcessor;
|
96 |
-
|
97 |
-
$logger->pushProcessor($processor1);
|
98 |
-
$logger->pushProcessor($processor2);
|
99 |
-
|
100 |
-
$this->assertEquals($processor2, $logger->popProcessor());
|
101 |
-
$this->assertEquals($processor1, $logger->popProcessor());
|
102 |
-
$logger->popProcessor();
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @covers Monolog\Handler\AbstractHandler::pushProcessor
|
107 |
-
* @expectedException InvalidArgumentException
|
108 |
-
*/
|
109 |
-
public function testPushProcessorWithNonCallable()
|
110 |
-
{
|
111 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
112 |
-
|
113 |
-
$handler->pushProcessor(new \stdClass());
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Processor\WebProcessor;
|
17 |
-
|
18 |
-
class AbstractProcessingHandlerTest extends TestCase
|
19 |
-
{
|
20 |
-
/**
|
21 |
-
* @covers Monolog\Handler\AbstractProcessingHandler::handle
|
22 |
-
*/
|
23 |
-
public function testHandleLowerLevelMessage()
|
24 |
-
{
|
25 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
|
26 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @covers Monolog\Handler\AbstractProcessingHandler::handle
|
31 |
-
*/
|
32 |
-
public function testHandleBubbling()
|
33 |
-
{
|
34 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
|
35 |
-
$this->assertFalse($handler->handle($this->getRecord()));
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @covers Monolog\Handler\AbstractProcessingHandler::handle
|
40 |
-
*/
|
41 |
-
public function testHandleNotBubbling()
|
42 |
-
{
|
43 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
|
44 |
-
$this->assertTrue($handler->handle($this->getRecord()));
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @covers Monolog\Handler\AbstractProcessingHandler::handle
|
49 |
-
*/
|
50 |
-
public function testHandleIsFalseWhenNotHandled()
|
51 |
-
{
|
52 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
|
53 |
-
$this->assertTrue($handler->handle($this->getRecord()));
|
54 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @covers Monolog\Handler\AbstractProcessingHandler::processRecord
|
59 |
-
*/
|
60 |
-
public function testProcessRecord()
|
61 |
-
{
|
62 |
-
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
63 |
-
$handler->pushProcessor(new WebProcessor(array(
|
64 |
-
'REQUEST_URI' => '',
|
65 |
-
'REQUEST_METHOD' => '',
|
66 |
-
'REMOTE_ADDR' => '',
|
67 |
-
'SERVER_NAME' => '',
|
68 |
-
'UNIQUE_ID' => '',
|
69 |
-
)));
|
70 |
-
$handledRecord = null;
|
71 |
-
$handler->expects($this->once())
|
72 |
-
->method('write')
|
73 |
-
->will($this->returnCallback(function ($record) use (&$handledRecord) {
|
74 |
-
$handledRecord = $record;
|
75 |
-
}))
|
76 |
-
;
|
77 |
-
$handler->handle($this->getRecord());
|
78 |
-
$this->assertEquals(6, count($handledRecord['extra']));
|
79 |
-
}
|
80 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
DELETED
@@ -1,136 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use PhpAmqpLib\Message\AMQPMessage;
|
17 |
-
use PhpAmqpLib\Connection\AMQPConnection;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\RotatingFileHandler
|
21 |
-
*/
|
22 |
-
class AmqpHandlerTest extends TestCase
|
23 |
-
{
|
24 |
-
public function testHandleAmqpExt()
|
25 |
-
{
|
26 |
-
if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) {
|
27 |
-
$this->markTestSkipped("amqp-php not installed");
|
28 |
-
}
|
29 |
-
|
30 |
-
if (!class_exists('AMQPChannel')) {
|
31 |
-
$this->markTestSkipped("Please update AMQP to version >= 1.0");
|
32 |
-
}
|
33 |
-
|
34 |
-
$messages = array();
|
35 |
-
|
36 |
-
$exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
|
37 |
-
$exchange->expects($this->once())
|
38 |
-
->method('setName')
|
39 |
-
->with('log')
|
40 |
-
;
|
41 |
-
$exchange->expects($this->any())
|
42 |
-
->method('publish')
|
43 |
-
->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) {
|
44 |
-
$messages[] = array($message, $routing_key, $flags, $attributes);
|
45 |
-
}))
|
46 |
-
;
|
47 |
-
|
48 |
-
$handler = new AmqpHandler($exchange, 'log');
|
49 |
-
|
50 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
51 |
-
|
52 |
-
$expected = array(
|
53 |
-
array(
|
54 |
-
'message' => 'test',
|
55 |
-
'context' => array(
|
56 |
-
'data' => array(),
|
57 |
-
'foo' => 34,
|
58 |
-
),
|
59 |
-
'level' => 300,
|
60 |
-
'level_name' => 'WARNING',
|
61 |
-
'channel' => 'test',
|
62 |
-
'extra' => array(),
|
63 |
-
),
|
64 |
-
'warn.test',
|
65 |
-
0,
|
66 |
-
array(
|
67 |
-
'delivery_mode' => 2,
|
68 |
-
'content_type' => 'application/json',
|
69 |
-
),
|
70 |
-
);
|
71 |
-
|
72 |
-
$handler->handle($record);
|
73 |
-
|
74 |
-
$this->assertCount(1, $messages);
|
75 |
-
$messages[0][0] = json_decode($messages[0][0], true);
|
76 |
-
unset($messages[0][0]['datetime']);
|
77 |
-
$this->assertEquals($expected, $messages[0]);
|
78 |
-
}
|
79 |
-
|
80 |
-
public function testHandlePhpAmqpLib()
|
81 |
-
{
|
82 |
-
if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) {
|
83 |
-
$this->markTestSkipped("php-amqplib not installed");
|
84 |
-
}
|
85 |
-
|
86 |
-
$messages = array();
|
87 |
-
|
88 |
-
$exchange = $this->getMock('PhpAmqpLib\Channel\AMQPChannel', array('basic_publish', '__destruct'), array(), '', false);
|
89 |
-
|
90 |
-
$exchange->expects($this->any())
|
91 |
-
->method('basic_publish')
|
92 |
-
->will($this->returnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) {
|
93 |
-
$messages[] = array($msg, $exchange, $routing_key, $mandatory, $immediate, $ticket);
|
94 |
-
}))
|
95 |
-
;
|
96 |
-
|
97 |
-
$handler = new AmqpHandler($exchange, 'log');
|
98 |
-
|
99 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
100 |
-
|
101 |
-
$expected = array(
|
102 |
-
array(
|
103 |
-
'message' => 'test',
|
104 |
-
'context' => array(
|
105 |
-
'data' => array(),
|
106 |
-
'foo' => 34,
|
107 |
-
),
|
108 |
-
'level' => 300,
|
109 |
-
'level_name' => 'WARNING',
|
110 |
-
'channel' => 'test',
|
111 |
-
'extra' => array(),
|
112 |
-
),
|
113 |
-
'log',
|
114 |
-
'warn.test',
|
115 |
-
false,
|
116 |
-
false,
|
117 |
-
null,
|
118 |
-
array(
|
119 |
-
'delivery_mode' => 2,
|
120 |
-
'content_type' => 'application/json',
|
121 |
-
),
|
122 |
-
);
|
123 |
-
|
124 |
-
$handler->handle($record);
|
125 |
-
|
126 |
-
$this->assertCount(1, $messages);
|
127 |
-
|
128 |
-
/* @var $msg AMQPMessage */
|
129 |
-
$msg = $messages[0][0];
|
130 |
-
$messages[0][0] = json_decode($msg->body, true);
|
131 |
-
$messages[0][] = $msg->get_properties();
|
132 |
-
unset($messages[0][0]['datetime']);
|
133 |
-
|
134 |
-
$this->assertEquals($expected, $messages[0]);
|
135 |
-
}
|
136 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\BrowserConsoleHandlerTest
|
19 |
-
*/
|
20 |
-
class BrowserConsoleHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
protected function setUp()
|
23 |
-
{
|
24 |
-
BrowserConsoleHandler::resetStatic();
|
25 |
-
}
|
26 |
-
|
27 |
-
protected function generateScript()
|
28 |
-
{
|
29 |
-
$reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript');
|
30 |
-
$reflMethod->setAccessible(true);
|
31 |
-
|
32 |
-
return $reflMethod->invoke(null);
|
33 |
-
}
|
34 |
-
|
35 |
-
public function testStyling()
|
36 |
-
{
|
37 |
-
$handler = new BrowserConsoleHandler();
|
38 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
39 |
-
|
40 |
-
$handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
|
41 |
-
|
42 |
-
$expected = <<<EOF
|
43 |
-
(function (c) {if (c && c.groupCollapsed) {
|
44 |
-
c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
|
45 |
-
}})(console);
|
46 |
-
EOF;
|
47 |
-
|
48 |
-
$this->assertEquals($expected, $this->generateScript());
|
49 |
-
}
|
50 |
-
|
51 |
-
public function testEscaping()
|
52 |
-
{
|
53 |
-
$handler = new BrowserConsoleHandler();
|
54 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
55 |
-
|
56 |
-
$handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
|
57 |
-
|
58 |
-
$expected = <<<EOF
|
59 |
-
(function (c) {if (c && c.groupCollapsed) {
|
60 |
-
c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
|
61 |
-
}})(console);
|
62 |
-
EOF;
|
63 |
-
|
64 |
-
$this->assertEquals($expected, $this->generateScript());
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testAutolabel()
|
68 |
-
{
|
69 |
-
$handler = new BrowserConsoleHandler();
|
70 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
71 |
-
|
72 |
-
$handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
|
73 |
-
$handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}'));
|
74 |
-
$handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
|
75 |
-
|
76 |
-
$expected = <<<EOF
|
77 |
-
(function (c) {if (c && c.groupCollapsed) {
|
78 |
-
c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
|
79 |
-
c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
|
80 |
-
c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
|
81 |
-
}})(console);
|
82 |
-
EOF;
|
83 |
-
|
84 |
-
$this->assertEquals($expected, $this->generateScript());
|
85 |
-
}
|
86 |
-
|
87 |
-
public function testContext()
|
88 |
-
{
|
89 |
-
$handler = new BrowserConsoleHandler();
|
90 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
91 |
-
|
92 |
-
$handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
|
93 |
-
|
94 |
-
$expected = <<<EOF
|
95 |
-
(function (c) {if (c && c.groupCollapsed) {
|
96 |
-
c.groupCollapsed("%ctest", "font-weight: normal");
|
97 |
-
c.log("%c%s", "font-weight: bold", "Context");
|
98 |
-
c.log("%s: %o", "foo", "bar");
|
99 |
-
c.groupEnd();
|
100 |
-
}})(console);
|
101 |
-
EOF;
|
102 |
-
|
103 |
-
$this->assertEquals($expected, $this->generateScript());
|
104 |
-
}
|
105 |
-
|
106 |
-
public function testConcurrentHandlers()
|
107 |
-
{
|
108 |
-
$handler1 = new BrowserConsoleHandler();
|
109 |
-
$handler1->setFormatter($this->getIdentityFormatter());
|
110 |
-
|
111 |
-
$handler2 = new BrowserConsoleHandler();
|
112 |
-
$handler2->setFormatter($this->getIdentityFormatter());
|
113 |
-
|
114 |
-
$handler1->handle($this->getRecord(Logger::DEBUG, 'test1'));
|
115 |
-
$handler2->handle($this->getRecord(Logger::DEBUG, 'test2'));
|
116 |
-
$handler1->handle($this->getRecord(Logger::DEBUG, 'test3'));
|
117 |
-
$handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
|
118 |
-
|
119 |
-
$expected = <<<EOF
|
120 |
-
(function (c) {if (c && c.groupCollapsed) {
|
121 |
-
c.log("%ctest1", "font-weight: normal");
|
122 |
-
c.log("%ctest2", "font-weight: normal");
|
123 |
-
c.log("%ctest3", "font-weight: normal");
|
124 |
-
c.log("%ctest4", "font-weight: normal");
|
125 |
-
}})(console);
|
126 |
-
EOF;
|
127 |
-
|
128 |
-
$this->assertEquals($expected, $this->generateScript());
|
129 |
-
}
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
DELETED
@@ -1,158 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class BufferHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
private $shutdownCheckHandler;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @covers Monolog\Handler\BufferHandler::__construct
|
23 |
-
* @covers Monolog\Handler\BufferHandler::handle
|
24 |
-
* @covers Monolog\Handler\BufferHandler::close
|
25 |
-
*/
|
26 |
-
public function testHandleBuffers()
|
27 |
-
{
|
28 |
-
$test = new TestHandler();
|
29 |
-
$handler = new BufferHandler($test);
|
30 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
31 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
32 |
-
$this->assertFalse($test->hasDebugRecords());
|
33 |
-
$this->assertFalse($test->hasInfoRecords());
|
34 |
-
$handler->close();
|
35 |
-
$this->assertTrue($test->hasInfoRecords());
|
36 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @covers Monolog\Handler\BufferHandler::close
|
41 |
-
* @covers Monolog\Handler\BufferHandler::flush
|
42 |
-
*/
|
43 |
-
public function testPropagatesRecordsAtEndOfRequest()
|
44 |
-
{
|
45 |
-
$test = new TestHandler();
|
46 |
-
$handler = new BufferHandler($test);
|
47 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
48 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
49 |
-
$this->shutdownCheckHandler = $test;
|
50 |
-
register_shutdown_function(array($this, 'checkPropagation'));
|
51 |
-
}
|
52 |
-
|
53 |
-
public function checkPropagation()
|
54 |
-
{
|
55 |
-
if (!$this->shutdownCheckHandler->hasWarningRecords() || !$this->shutdownCheckHandler->hasDebugRecords()) {
|
56 |
-
echo '!!! BufferHandlerTest::testPropagatesRecordsAtEndOfRequest failed to verify that the messages have been propagated' . PHP_EOL;
|
57 |
-
exit(1);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @covers Monolog\Handler\BufferHandler::handle
|
63 |
-
*/
|
64 |
-
public function testHandleBufferLimit()
|
65 |
-
{
|
66 |
-
$test = new TestHandler();
|
67 |
-
$handler = new BufferHandler($test, 2);
|
68 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
69 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
70 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
71 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
72 |
-
$handler->close();
|
73 |
-
$this->assertTrue($test->hasWarningRecords());
|
74 |
-
$this->assertTrue($test->hasInfoRecords());
|
75 |
-
$this->assertFalse($test->hasDebugRecords());
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @covers Monolog\Handler\BufferHandler::handle
|
80 |
-
*/
|
81 |
-
public function testHandleBufferLimitWithFlushOnOverflow()
|
82 |
-
{
|
83 |
-
$test = new TestHandler();
|
84 |
-
$handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
|
85 |
-
|
86 |
-
// send two records
|
87 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
88 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
89 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
90 |
-
$this->assertFalse($test->hasDebugRecords());
|
91 |
-
$this->assertCount(0, $test->getRecords());
|
92 |
-
|
93 |
-
// overflow
|
94 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
95 |
-
$this->assertTrue($test->hasDebugRecords());
|
96 |
-
$this->assertCount(3, $test->getRecords());
|
97 |
-
|
98 |
-
// should buffer again
|
99 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
100 |
-
$this->assertCount(3, $test->getRecords());
|
101 |
-
|
102 |
-
$handler->close();
|
103 |
-
$this->assertCount(5, $test->getRecords());
|
104 |
-
$this->assertTrue($test->hasWarningRecords());
|
105 |
-
$this->assertTrue($test->hasInfoRecords());
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @covers Monolog\Handler\BufferHandler::handle
|
110 |
-
*/
|
111 |
-
public function testHandleLevel()
|
112 |
-
{
|
113 |
-
$test = new TestHandler();
|
114 |
-
$handler = new BufferHandler($test, 0, Logger::INFO);
|
115 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
116 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
117 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
118 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
119 |
-
$handler->close();
|
120 |
-
$this->assertTrue($test->hasWarningRecords());
|
121 |
-
$this->assertTrue($test->hasInfoRecords());
|
122 |
-
$this->assertFalse($test->hasDebugRecords());
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @covers Monolog\Handler\BufferHandler::flush
|
127 |
-
*/
|
128 |
-
public function testFlush()
|
129 |
-
{
|
130 |
-
$test = new TestHandler();
|
131 |
-
$handler = new BufferHandler($test, 0);
|
132 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
133 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
134 |
-
$handler->flush();
|
135 |
-
$this->assertTrue($test->hasInfoRecords());
|
136 |
-
$this->assertTrue($test->hasDebugRecords());
|
137 |
-
$this->assertFalse($test->hasWarningRecords());
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* @covers Monolog\Handler\BufferHandler::handle
|
142 |
-
*/
|
143 |
-
public function testHandleUsesProcessors()
|
144 |
-
{
|
145 |
-
$test = new TestHandler();
|
146 |
-
$handler = new BufferHandler($test);
|
147 |
-
$handler->pushProcessor(function ($record) {
|
148 |
-
$record['extra']['foo'] = true;
|
149 |
-
|
150 |
-
return $record;
|
151 |
-
});
|
152 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
153 |
-
$handler->flush();
|
154 |
-
$this->assertTrue($test->hasWarningRecords());
|
155 |
-
$records = $test->getRecords();
|
156 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
157 |
-
}
|
158 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
DELETED
@@ -1,156 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\ChromePHPHandler
|
19 |
-
*/
|
20 |
-
class ChromePHPHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
protected function setUp()
|
23 |
-
{
|
24 |
-
TestChromePHPHandler::resetStatic();
|
25 |
-
$_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @dataProvider agentsProvider
|
30 |
-
*/
|
31 |
-
public function testHeaders($agent)
|
32 |
-
{
|
33 |
-
$_SERVER['HTTP_USER_AGENT'] = $agent;
|
34 |
-
|
35 |
-
$handler = new TestChromePHPHandler();
|
36 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
37 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
38 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
39 |
-
|
40 |
-
$expected = array(
|
41 |
-
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
42 |
-
'version' => ChromePHPHandler::VERSION,
|
43 |
-
'columns' => array('label', 'log', 'backtrace', 'type'),
|
44 |
-
'rows' => array(
|
45 |
-
'test',
|
46 |
-
'test',
|
47 |
-
),
|
48 |
-
'request_uri' => '',
|
49 |
-
)))),
|
50 |
-
);
|
51 |
-
|
52 |
-
$this->assertEquals($expected, $handler->getHeaders());
|
53 |
-
}
|
54 |
-
|
55 |
-
public static function agentsProvider()
|
56 |
-
{
|
57 |
-
return array(
|
58 |
-
array('Monolog Test; Chrome/1.0'),
|
59 |
-
array('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'),
|
60 |
-
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36'),
|
61 |
-
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36'),
|
62 |
-
);
|
63 |
-
}
|
64 |
-
|
65 |
-
public function testHeadersOverflow()
|
66 |
-
{
|
67 |
-
$handler = new TestChromePHPHandler();
|
68 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
69 |
-
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150 * 1024)));
|
70 |
-
|
71 |
-
// overflow chrome headers limit
|
72 |
-
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100 * 1024)));
|
73 |
-
|
74 |
-
$expected = array(
|
75 |
-
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
76 |
-
'version' => ChromePHPHandler::VERSION,
|
77 |
-
'columns' => array('label', 'log', 'backtrace', 'type'),
|
78 |
-
'rows' => array(
|
79 |
-
array(
|
80 |
-
'test',
|
81 |
-
'test',
|
82 |
-
'unknown',
|
83 |
-
'log',
|
84 |
-
),
|
85 |
-
array(
|
86 |
-
'test',
|
87 |
-
str_repeat('a', 150 * 1024),
|
88 |
-
'unknown',
|
89 |
-
'warn',
|
90 |
-
),
|
91 |
-
array(
|
92 |
-
'monolog',
|
93 |
-
'Incomplete logs, chrome header size limit reached',
|
94 |
-
'unknown',
|
95 |
-
'warn',
|
96 |
-
),
|
97 |
-
),
|
98 |
-
'request_uri' => '',
|
99 |
-
)))),
|
100 |
-
);
|
101 |
-
|
102 |
-
$this->assertEquals($expected, $handler->getHeaders());
|
103 |
-
}
|
104 |
-
|
105 |
-
public function testConcurrentHandlers()
|
106 |
-
{
|
107 |
-
$handler = new TestChromePHPHandler();
|
108 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
109 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
110 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
111 |
-
|
112 |
-
$handler2 = new TestChromePHPHandler();
|
113 |
-
$handler2->setFormatter($this->getIdentityFormatter());
|
114 |
-
$handler2->handle($this->getRecord(Logger::DEBUG));
|
115 |
-
$handler2->handle($this->getRecord(Logger::WARNING));
|
116 |
-
|
117 |
-
$expected = array(
|
118 |
-
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
119 |
-
'version' => ChromePHPHandler::VERSION,
|
120 |
-
'columns' => array('label', 'log', 'backtrace', 'type'),
|
121 |
-
'rows' => array(
|
122 |
-
'test',
|
123 |
-
'test',
|
124 |
-
'test',
|
125 |
-
'test',
|
126 |
-
),
|
127 |
-
'request_uri' => '',
|
128 |
-
)))),
|
129 |
-
);
|
130 |
-
|
131 |
-
$this->assertEquals($expected, $handler2->getHeaders());
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
class TestChromePHPHandler extends ChromePHPHandler
|
136 |
-
{
|
137 |
-
protected $headers = array();
|
138 |
-
|
139 |
-
public static function resetStatic()
|
140 |
-
{
|
141 |
-
self::$initialized = false;
|
142 |
-
self::$overflowed = false;
|
143 |
-
self::$sendHeaders = true;
|
144 |
-
self::$json['rows'] = array();
|
145 |
-
}
|
146 |
-
|
147 |
-
protected function sendHeader($header, $content)
|
148 |
-
{
|
149 |
-
$this->headers[$header] = $content;
|
150 |
-
}
|
151 |
-
|
152 |
-
public function getHeaders()
|
153 |
-
{
|
154 |
-
return $this->headers;
|
155 |
-
}
|
156 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class CouchDBHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
public function testHandle()
|
20 |
-
{
|
21 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
22 |
-
|
23 |
-
$handler = new CouchDBHandler();
|
24 |
-
|
25 |
-
try {
|
26 |
-
$handler->handle($record);
|
27 |
-
} catch (\RuntimeException $e) {
|
28 |
-
$this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984');
|
29 |
-
}
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/DeduplicationHandlerTest.php
DELETED
@@ -1,165 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class DeduplicationHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\DeduplicationHandler::flush
|
21 |
-
*/
|
22 |
-
public function testFlushPassthruIfAllRecordsUnderTrigger()
|
23 |
-
{
|
24 |
-
$test = new TestHandler();
|
25 |
-
@unlink(sys_get_temp_dir().'/monolog_dedup.log');
|
26 |
-
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
27 |
-
|
28 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
29 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
30 |
-
|
31 |
-
$handler->flush();
|
32 |
-
|
33 |
-
$this->assertTrue($test->hasInfoRecords());
|
34 |
-
$this->assertTrue($test->hasDebugRecords());
|
35 |
-
$this->assertFalse($test->hasWarningRecords());
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @covers Monolog\Handler\DeduplicationHandler::flush
|
40 |
-
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
|
41 |
-
*/
|
42 |
-
public function testFlushPassthruIfEmptyLog()
|
43 |
-
{
|
44 |
-
$test = new TestHandler();
|
45 |
-
@unlink(sys_get_temp_dir().'/monolog_dedup.log');
|
46 |
-
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
47 |
-
|
48 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
|
49 |
-
$handler->handle($this->getRecord(Logger::CRITICAL, "Foo\nbar"));
|
50 |
-
|
51 |
-
$handler->flush();
|
52 |
-
|
53 |
-
$this->assertTrue($test->hasErrorRecords());
|
54 |
-
$this->assertTrue($test->hasCriticalRecords());
|
55 |
-
$this->assertFalse($test->hasWarningRecords());
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @covers Monolog\Handler\DeduplicationHandler::flush
|
60 |
-
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
|
61 |
-
* @covers Monolog\Handler\DeduplicationHandler::isDuplicate
|
62 |
-
* @depends testFlushPassthruIfEmptyLog
|
63 |
-
*/
|
64 |
-
public function testFlushSkipsIfLogExists()
|
65 |
-
{
|
66 |
-
$test = new TestHandler();
|
67 |
-
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
68 |
-
|
69 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
|
70 |
-
$handler->handle($this->getRecord(Logger::CRITICAL, "Foo\nbar"));
|
71 |
-
|
72 |
-
$handler->flush();
|
73 |
-
|
74 |
-
$this->assertFalse($test->hasErrorRecords());
|
75 |
-
$this->assertFalse($test->hasCriticalRecords());
|
76 |
-
$this->assertFalse($test->hasWarningRecords());
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @covers Monolog\Handler\DeduplicationHandler::flush
|
81 |
-
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
|
82 |
-
* @covers Monolog\Handler\DeduplicationHandler::isDuplicate
|
83 |
-
* @depends testFlushPassthruIfEmptyLog
|
84 |
-
*/
|
85 |
-
public function testFlushPassthruIfLogTooOld()
|
86 |
-
{
|
87 |
-
$test = new TestHandler();
|
88 |
-
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
89 |
-
|
90 |
-
$record = $this->getRecord(Logger::ERROR);
|
91 |
-
$record['datetime']->modify('+62seconds');
|
92 |
-
$handler->handle($record);
|
93 |
-
$record = $this->getRecord(Logger::CRITICAL);
|
94 |
-
$record['datetime']->modify('+62seconds');
|
95 |
-
$handler->handle($record);
|
96 |
-
|
97 |
-
$handler->flush();
|
98 |
-
|
99 |
-
$this->assertTrue($test->hasErrorRecords());
|
100 |
-
$this->assertTrue($test->hasCriticalRecords());
|
101 |
-
$this->assertFalse($test->hasWarningRecords());
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @covers Monolog\Handler\DeduplicationHandler::flush
|
106 |
-
* @covers Monolog\Handler\DeduplicationHandler::appendRecord
|
107 |
-
* @covers Monolog\Handler\DeduplicationHandler::isDuplicate
|
108 |
-
* @covers Monolog\Handler\DeduplicationHandler::collectLogs
|
109 |
-
*/
|
110 |
-
public function testGcOldLogs()
|
111 |
-
{
|
112 |
-
$test = new TestHandler();
|
113 |
-
@unlink(sys_get_temp_dir().'/monolog_dedup.log');
|
114 |
-
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
|
115 |
-
|
116 |
-
// handle two records from yesterday, and one recent
|
117 |
-
$record = $this->getRecord(Logger::ERROR);
|
118 |
-
$record['datetime']->modify('-1day -10seconds');
|
119 |
-
$handler->handle($record);
|
120 |
-
$record2 = $this->getRecord(Logger::CRITICAL);
|
121 |
-
$record2['datetime']->modify('-1day -10seconds');
|
122 |
-
$handler->handle($record2);
|
123 |
-
$record3 = $this->getRecord(Logger::CRITICAL);
|
124 |
-
$record3['datetime']->modify('-30seconds');
|
125 |
-
$handler->handle($record3);
|
126 |
-
|
127 |
-
// log is written as none of them are duplicate
|
128 |
-
$handler->flush();
|
129 |
-
$this->assertSame(
|
130 |
-
$record['datetime']->getTimestamp() . ":ERROR:test\n" .
|
131 |
-
$record2['datetime']->getTimestamp() . ":CRITICAL:test\n" .
|
132 |
-
$record3['datetime']->getTimestamp() . ":CRITICAL:test\n",
|
133 |
-
file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log')
|
134 |
-
);
|
135 |
-
$this->assertTrue($test->hasErrorRecords());
|
136 |
-
$this->assertTrue($test->hasCriticalRecords());
|
137 |
-
$this->assertFalse($test->hasWarningRecords());
|
138 |
-
|
139 |
-
// clear test handler
|
140 |
-
$test->clear();
|
141 |
-
$this->assertFalse($test->hasErrorRecords());
|
142 |
-
$this->assertFalse($test->hasCriticalRecords());
|
143 |
-
|
144 |
-
// log new records, duplicate log gets GC'd at the end of this flush call
|
145 |
-
$handler->handle($record = $this->getRecord(Logger::ERROR));
|
146 |
-
$handler->handle($record2 = $this->getRecord(Logger::CRITICAL));
|
147 |
-
$handler->flush();
|
148 |
-
|
149 |
-
// log should now contain the new errors and the previous one that was recent enough
|
150 |
-
$this->assertSame(
|
151 |
-
$record3['datetime']->getTimestamp() . ":CRITICAL:test\n" .
|
152 |
-
$record['datetime']->getTimestamp() . ":ERROR:test\n" .
|
153 |
-
$record2['datetime']->getTimestamp() . ":CRITICAL:test\n",
|
154 |
-
file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log')
|
155 |
-
);
|
156 |
-
$this->assertTrue($test->hasErrorRecords());
|
157 |
-
$this->assertTrue($test->hasCriticalRecords());
|
158 |
-
$this->assertFalse($test->hasWarningRecords());
|
159 |
-
}
|
160 |
-
|
161 |
-
public static function tearDownAfterClass()
|
162 |
-
{
|
163 |
-
@unlink(sys_get_temp_dir().'/monolog_dedup.log');
|
164 |
-
}
|
165 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class DoctrineCouchDBHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
protected function setup()
|
20 |
-
{
|
21 |
-
if (!class_exists('Doctrine\CouchDB\CouchDBClient')) {
|
22 |
-
$this->markTestSkipped('The "doctrine/couchdb" package is not installed');
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
public function testHandle()
|
27 |
-
{
|
28 |
-
$client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
|
29 |
-
->setMethods(array('postDocument'))
|
30 |
-
->disableOriginalConstructor()
|
31 |
-
->getMock();
|
32 |
-
|
33 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
34 |
-
|
35 |
-
$expected = array(
|
36 |
-
'message' => 'test',
|
37 |
-
'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
|
38 |
-
'level' => Logger::WARNING,
|
39 |
-
'level_name' => 'WARNING',
|
40 |
-
'channel' => 'test',
|
41 |
-
'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
|
42 |
-
'extra' => array(),
|
43 |
-
);
|
44 |
-
|
45 |
-
$client->expects($this->once())
|
46 |
-
->method('postDocument')
|
47 |
-
->with($expected);
|
48 |
-
|
49 |
-
$handler = new DoctrineCouchDBHandler($client);
|
50 |
-
$handler->handle($record);
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class DynamoDbHandlerTest extends TestCase
|
17 |
-
{
|
18 |
-
private $client;
|
19 |
-
|
20 |
-
public function setUp()
|
21 |
-
{
|
22 |
-
if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
|
23 |
-
$this->markTestSkipped('aws/aws-sdk-php not installed');
|
24 |
-
}
|
25 |
-
|
26 |
-
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
|
27 |
-
->setMethods(array('formatAttributes', '__call'))
|
28 |
-
->disableOriginalConstructor()->getMock();
|
29 |
-
}
|
30 |
-
|
31 |
-
public function testConstruct()
|
32 |
-
{
|
33 |
-
$this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
|
34 |
-
}
|
35 |
-
|
36 |
-
public function testInterface()
|
37 |
-
{
|
38 |
-
$this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
|
39 |
-
}
|
40 |
-
|
41 |
-
public function testGetFormatter()
|
42 |
-
{
|
43 |
-
$handler = new DynamoDbHandler($this->client, 'foo');
|
44 |
-
$this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
|
45 |
-
}
|
46 |
-
|
47 |
-
public function testHandle()
|
48 |
-
{
|
49 |
-
$record = $this->getRecord();
|
50 |
-
$formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
|
51 |
-
$formatted = array('foo' => 1, 'bar' => 2);
|
52 |
-
$handler = new DynamoDbHandler($this->client, 'foo');
|
53 |
-
$handler->setFormatter($formatter);
|
54 |
-
|
55 |
-
$isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
|
56 |
-
if ($isV3) {
|
57 |
-
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
|
58 |
-
} else {
|
59 |
-
$expFormatted = $formatted;
|
60 |
-
}
|
61 |
-
|
62 |
-
$formatter
|
63 |
-
->expects($this->once())
|
64 |
-
->method('format')
|
65 |
-
->with($record)
|
66 |
-
->will($this->returnValue($formatted));
|
67 |
-
$this->client
|
68 |
-
->expects($isV3 ? $this->never() : $this->once())
|
69 |
-
->method('formatAttributes')
|
70 |
-
->with($this->isType('array'))
|
71 |
-
->will($this->returnValue($formatted));
|
72 |
-
$this->client
|
73 |
-
->expects($this->once())
|
74 |
-
->method('__call')
|
75 |
-
->with('putItem', array(array(
|
76 |
-
'TableName' => 'foo',
|
77 |
-
'Item' => $expFormatted,
|
78 |
-
)));
|
79 |
-
|
80 |
-
$handler->handle($record);
|
81 |
-
}
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php
DELETED
@@ -1,239 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\ElasticaFormatter;
|
15 |
-
use Monolog\Formatter\NormalizerFormatter;
|
16 |
-
use Monolog\TestCase;
|
17 |
-
use Monolog\Logger;
|
18 |
-
use Elastica\Client;
|
19 |
-
use Elastica\Request;
|
20 |
-
use Elastica\Response;
|
21 |
-
|
22 |
-
class ElasticSearchHandlerTest extends TestCase
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @var Client mock
|
26 |
-
*/
|
27 |
-
protected $client;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var array Default handler options
|
31 |
-
*/
|
32 |
-
protected $options = array(
|
33 |
-
'index' => 'my_index',
|
34 |
-
'type' => 'doc_type',
|
35 |
-
);
|
36 |
-
|
37 |
-
public function setUp()
|
38 |
-
{
|
39 |
-
// Elastica lib required
|
40 |
-
if (!class_exists("Elastica\Client")) {
|
41 |
-
$this->markTestSkipped("ruflin/elastica not installed");
|
42 |
-
}
|
43 |
-
|
44 |
-
// base mock Elastica Client object
|
45 |
-
$this->client = $this->getMockBuilder('Elastica\Client')
|
46 |
-
->setMethods(array('addDocuments'))
|
47 |
-
->disableOriginalConstructor()
|
48 |
-
->getMock();
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @covers Monolog\Handler\ElasticSearchHandler::write
|
53 |
-
* @covers Monolog\Handler\ElasticSearchHandler::handleBatch
|
54 |
-
* @covers Monolog\Handler\ElasticSearchHandler::bulkSend
|
55 |
-
* @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
|
56 |
-
*/
|
57 |
-
public function testHandle()
|
58 |
-
{
|
59 |
-
// log message
|
60 |
-
$msg = array(
|
61 |
-
'level' => Logger::ERROR,
|
62 |
-
'level_name' => 'ERROR',
|
63 |
-
'channel' => 'meh',
|
64 |
-
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
65 |
-
'datetime' => new \DateTime("@0"),
|
66 |
-
'extra' => array(),
|
67 |
-
'message' => 'log',
|
68 |
-
);
|
69 |
-
|
70 |
-
// format expected result
|
71 |
-
$formatter = new ElasticaFormatter($this->options['index'], $this->options['type']);
|
72 |
-
$expected = array($formatter->format($msg));
|
73 |
-
|
74 |
-
// setup ES client mock
|
75 |
-
$this->client->expects($this->any())
|
76 |
-
->method('addDocuments')
|
77 |
-
->with($expected);
|
78 |
-
|
79 |
-
// perform tests
|
80 |
-
$handler = new ElasticSearchHandler($this->client, $this->options);
|
81 |
-
$handler->handle($msg);
|
82 |
-
$handler->handleBatch(array($msg));
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @covers Monolog\Handler\ElasticSearchHandler::setFormatter
|
87 |
-
*/
|
88 |
-
public function testSetFormatter()
|
89 |
-
{
|
90 |
-
$handler = new ElasticSearchHandler($this->client);
|
91 |
-
$formatter = new ElasticaFormatter('index_new', 'type_new');
|
92 |
-
$handler->setFormatter($formatter);
|
93 |
-
$this->assertInstanceOf('Monolog\Formatter\ElasticaFormatter', $handler->getFormatter());
|
94 |
-
$this->assertEquals('index_new', $handler->getFormatter()->getIndex());
|
95 |
-
$this->assertEquals('type_new', $handler->getFormatter()->getType());
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @covers Monolog\Handler\ElasticSearchHandler::setFormatter
|
100 |
-
* @expectedException InvalidArgumentException
|
101 |
-
* @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter
|
102 |
-
*/
|
103 |
-
public function testSetFormatterInvalid()
|
104 |
-
{
|
105 |
-
$handler = new ElasticSearchHandler($this->client);
|
106 |
-
$formatter = new NormalizerFormatter();
|
107 |
-
$handler->setFormatter($formatter);
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @covers Monolog\Handler\ElasticSearchHandler::__construct
|
112 |
-
* @covers Monolog\Handler\ElasticSearchHandler::getOptions
|
113 |
-
*/
|
114 |
-
public function testOptions()
|
115 |
-
{
|
116 |
-
$expected = array(
|
117 |
-
'index' => $this->options['index'],
|
118 |
-
'type' => $this->options['type'],
|
119 |
-
'ignore_error' => false,
|
120 |
-
);
|
121 |
-
$handler = new ElasticSearchHandler($this->client, $this->options);
|
122 |
-
$this->assertEquals($expected, $handler->getOptions());
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @covers Monolog\Handler\ElasticSearchHandler::bulkSend
|
127 |
-
* @dataProvider providerTestConnectionErrors
|
128 |
-
*/
|
129 |
-
public function testConnectionErrors($ignore, $expectedError)
|
130 |
-
{
|
131 |
-
$clientOpts = array('host' => '127.0.0.1', 'port' => 1);
|
132 |
-
$client = new Client($clientOpts);
|
133 |
-
$handlerOpts = array('ignore_error' => $ignore);
|
134 |
-
$handler = new ElasticSearchHandler($client, $handlerOpts);
|
135 |
-
|
136 |
-
if ($expectedError) {
|
137 |
-
$this->setExpectedException($expectedError[0], $expectedError[1]);
|
138 |
-
$handler->handle($this->getRecord());
|
139 |
-
} else {
|
140 |
-
$this->assertFalse($handler->handle($this->getRecord()));
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* @return array
|
146 |
-
*/
|
147 |
-
public function providerTestConnectionErrors()
|
148 |
-
{
|
149 |
-
return array(
|
150 |
-
array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')),
|
151 |
-
array(true, false),
|
152 |
-
);
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Integration test using localhost Elastic Search server
|
157 |
-
*
|
158 |
-
* @covers Monolog\Handler\ElasticSearchHandler::__construct
|
159 |
-
* @covers Monolog\Handler\ElasticSearchHandler::handleBatch
|
160 |
-
* @covers Monolog\Handler\ElasticSearchHandler::bulkSend
|
161 |
-
* @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
|
162 |
-
*/
|
163 |
-
public function testHandleIntegration()
|
164 |
-
{
|
165 |
-
$msg = array(
|
166 |
-
'level' => Logger::ERROR,
|
167 |
-
'level_name' => 'ERROR',
|
168 |
-
'channel' => 'meh',
|
169 |
-
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
170 |
-
'datetime' => new \DateTime("@0"),
|
171 |
-
'extra' => array(),
|
172 |
-
'message' => 'log',
|
173 |
-
);
|
174 |
-
|
175 |
-
$expected = $msg;
|
176 |
-
$expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601);
|
177 |
-
$expected['context'] = array(
|
178 |
-
'class' => '[object] (stdClass: {})',
|
179 |
-
'foo' => 7,
|
180 |
-
0 => 'bar',
|
181 |
-
);
|
182 |
-
|
183 |
-
$client = new Client();
|
184 |
-
$handler = new ElasticSearchHandler($client, $this->options);
|
185 |
-
try {
|
186 |
-
$handler->handleBatch(array($msg));
|
187 |
-
} catch (\RuntimeException $e) {
|
188 |
-
$this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
|
189 |
-
}
|
190 |
-
|
191 |
-
// check document id from ES server response
|
192 |
-
$documentId = $this->getCreatedDocId($client->getLastResponse());
|
193 |
-
$this->assertNotEmpty($documentId, 'No elastic document id received');
|
194 |
-
|
195 |
-
// retrieve document source from ES and validate
|
196 |
-
$document = $this->getDocSourceFromElastic(
|
197 |
-
$client,
|
198 |
-
$this->options['index'],
|
199 |
-
$this->options['type'],
|
200 |
-
$documentId
|
201 |
-
);
|
202 |
-
$this->assertEquals($expected, $document);
|
203 |
-
|
204 |
-
// remove test index from ES
|
205 |
-
$client->request("/{$this->options['index']}", Request::DELETE);
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Return last created document id from ES response
|
210 |
-
* @param Response $response Elastica Response object
|
211 |
-
* @return string|null
|
212 |
-
*/
|
213 |
-
protected function getCreatedDocId(Response $response)
|
214 |
-
{
|
215 |
-
$data = $response->getData();
|
216 |
-
if (!empty($data['items'][0]['create']['_id'])) {
|
217 |
-
return $data['items'][0]['create']['_id'];
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Retrieve document by id from Elasticsearch
|
223 |
-
* @param Client $client Elastica client
|
224 |
-
* @param string $index
|
225 |
-
* @param string $type
|
226 |
-
* @param string $documentId
|
227 |
-
* @return array
|
228 |
-
*/
|
229 |
-
protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
|
230 |
-
{
|
231 |
-
$resp = $client->request("/{$index}/{$type}/{$documentId}", Request::GET);
|
232 |
-
$data = $resp->getData();
|
233 |
-
if (!empty($data['_source'])) {
|
234 |
-
return $data['_source'];
|
235 |
-
}
|
236 |
-
|
237 |
-
return array();
|
238 |
-
}
|
239 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
|
18 |
-
function error_log()
|
19 |
-
{
|
20 |
-
$GLOBALS['error_log'][] = func_get_args();
|
21 |
-
}
|
22 |
-
|
23 |
-
class ErrorLogHandlerTest extends TestCase
|
24 |
-
{
|
25 |
-
protected function setUp()
|
26 |
-
{
|
27 |
-
$GLOBALS['error_log'] = array();
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @covers Monolog\Handler\ErrorLogHandler::__construct
|
32 |
-
* @expectedException InvalidArgumentException
|
33 |
-
* @expectedExceptionMessage The given message type "42" is not supported
|
34 |
-
*/
|
35 |
-
public function testShouldNotAcceptAnInvalidTypeOnContructor()
|
36 |
-
{
|
37 |
-
new ErrorLogHandler(42);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @covers Monolog\Handler\ErrorLogHandler::write
|
42 |
-
*/
|
43 |
-
public function testShouldLogMessagesUsingErrorLogFuncion()
|
44 |
-
{
|
45 |
-
$type = ErrorLogHandler::OPERATING_SYSTEM;
|
46 |
-
$handler = new ErrorLogHandler($type);
|
47 |
-
$handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
|
48 |
-
$handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
|
49 |
-
|
50 |
-
$this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
|
51 |
-
$this->assertSame($GLOBALS['error_log'][0][1], $type);
|
52 |
-
|
53 |
-
$handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
|
54 |
-
$handler->setFormatter(new LineFormatter(null, null, true));
|
55 |
-
$handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
|
56 |
-
|
57 |
-
$this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
|
58 |
-
$this->assertSame($GLOBALS['error_log'][1][1], $type);
|
59 |
-
|
60 |
-
$this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
|
61 |
-
$this->assertSame($GLOBALS['error_log'][2][1], $type);
|
62 |
-
|
63 |
-
$this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
|
64 |
-
$this->assertSame($GLOBALS['error_log'][3][1], $type);
|
65 |
-
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php
DELETED
@@ -1,170 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class FilterHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\FilterHandler::isHandling
|
21 |
-
*/
|
22 |
-
public function testIsHandling()
|
23 |
-
{
|
24 |
-
$test = new TestHandler();
|
25 |
-
$handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE);
|
26 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
27 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::INFO)));
|
28 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::NOTICE)));
|
29 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::WARNING)));
|
30 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::ERROR)));
|
31 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::CRITICAL)));
|
32 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::ALERT)));
|
33 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::EMERGENCY)));
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @covers Monolog\Handler\FilterHandler::handle
|
38 |
-
* @covers Monolog\Handler\FilterHandler::setAcceptedLevels
|
39 |
-
* @covers Monolog\Handler\FilterHandler::isHandling
|
40 |
-
*/
|
41 |
-
public function testHandleProcessOnlyNeededLevels()
|
42 |
-
{
|
43 |
-
$test = new TestHandler();
|
44 |
-
$handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE);
|
45 |
-
|
46 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
47 |
-
$this->assertFalse($test->hasDebugRecords());
|
48 |
-
|
49 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
50 |
-
$this->assertTrue($test->hasInfoRecords());
|
51 |
-
$handler->handle($this->getRecord(Logger::NOTICE));
|
52 |
-
$this->assertTrue($test->hasNoticeRecords());
|
53 |
-
|
54 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
55 |
-
$this->assertFalse($test->hasWarningRecords());
|
56 |
-
$handler->handle($this->getRecord(Logger::ERROR));
|
57 |
-
$this->assertFalse($test->hasErrorRecords());
|
58 |
-
$handler->handle($this->getRecord(Logger::CRITICAL));
|
59 |
-
$this->assertFalse($test->hasCriticalRecords());
|
60 |
-
$handler->handle($this->getRecord(Logger::ALERT));
|
61 |
-
$this->assertFalse($test->hasAlertRecords());
|
62 |
-
$handler->handle($this->getRecord(Logger::EMERGENCY));
|
63 |
-
$this->assertFalse($test->hasEmergencyRecords());
|
64 |
-
|
65 |
-
$test = new TestHandler();
|
66 |
-
$handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR));
|
67 |
-
|
68 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
69 |
-
$this->assertFalse($test->hasDebugRecords());
|
70 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
71 |
-
$this->assertTrue($test->hasInfoRecords());
|
72 |
-
$handler->handle($this->getRecord(Logger::NOTICE));
|
73 |
-
$this->assertFalse($test->hasNoticeRecords());
|
74 |
-
$handler->handle($this->getRecord(Logger::ERROR));
|
75 |
-
$this->assertTrue($test->hasErrorRecords());
|
76 |
-
$handler->handle($this->getRecord(Logger::CRITICAL));
|
77 |
-
$this->assertFalse($test->hasCriticalRecords());
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* @covers Monolog\Handler\FilterHandler::setAcceptedLevels
|
82 |
-
* @covers Monolog\Handler\FilterHandler::getAcceptedLevels
|
83 |
-
*/
|
84 |
-
public function testAcceptedLevelApi()
|
85 |
-
{
|
86 |
-
$test = new TestHandler();
|
87 |
-
$handler = new FilterHandler($test);
|
88 |
-
|
89 |
-
$levels = array(Logger::INFO, Logger::ERROR);
|
90 |
-
$handler->setAcceptedLevels($levels);
|
91 |
-
$this->assertSame($levels, $handler->getAcceptedLevels());
|
92 |
-
|
93 |
-
$handler->setAcceptedLevels(array('info', 'error'));
|
94 |
-
$this->assertSame($levels, $handler->getAcceptedLevels());
|
95 |
-
|
96 |
-
$levels = array(Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
|
97 |
-
$handler->setAcceptedLevels(Logger::CRITICAL, Logger::EMERGENCY);
|
98 |
-
$this->assertSame($levels, $handler->getAcceptedLevels());
|
99 |
-
|
100 |
-
$handler->setAcceptedLevels('critical', 'emergency');
|
101 |
-
$this->assertSame($levels, $handler->getAcceptedLevels());
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @covers Monolog\Handler\FilterHandler::handle
|
106 |
-
*/
|
107 |
-
public function testHandleUsesProcessors()
|
108 |
-
{
|
109 |
-
$test = new TestHandler();
|
110 |
-
$handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY);
|
111 |
-
$handler->pushProcessor(
|
112 |
-
function ($record) {
|
113 |
-
$record['extra']['foo'] = true;
|
114 |
-
|
115 |
-
return $record;
|
116 |
-
}
|
117 |
-
);
|
118 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
119 |
-
$this->assertTrue($test->hasWarningRecords());
|
120 |
-
$records = $test->getRecords();
|
121 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @covers Monolog\Handler\FilterHandler::handle
|
126 |
-
*/
|
127 |
-
public function testHandleRespectsBubble()
|
128 |
-
{
|
129 |
-
$test = new TestHandler();
|
130 |
-
|
131 |
-
$handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, false);
|
132 |
-
$this->assertTrue($handler->handle($this->getRecord(Logger::INFO)));
|
133 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
|
134 |
-
|
135 |
-
$handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, true);
|
136 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::INFO)));
|
137 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* @covers Monolog\Handler\FilterHandler::handle
|
142 |
-
*/
|
143 |
-
public function testHandleWithCallback()
|
144 |
-
{
|
145 |
-
$test = new TestHandler();
|
146 |
-
$handler = new FilterHandler(
|
147 |
-
function ($record, $handler) use ($test) {
|
148 |
-
return $test;
|
149 |
-
}, Logger::INFO, Logger::NOTICE, false
|
150 |
-
);
|
151 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
152 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
153 |
-
$this->assertFalse($test->hasDebugRecords());
|
154 |
-
$this->assertTrue($test->hasInfoRecords());
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @covers Monolog\Handler\FilterHandler::handle
|
159 |
-
* @expectedException \RuntimeException
|
160 |
-
*/
|
161 |
-
public function testHandleWithBadCallbackThrowsException()
|
162 |
-
{
|
163 |
-
$handler = new FilterHandler(
|
164 |
-
function ($record, $handler) {
|
165 |
-
return 'foo';
|
166 |
-
}
|
167 |
-
);
|
168 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
169 |
-
}
|
170 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
DELETED
@@ -1,279 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
|
17 |
-
use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
|
18 |
-
use Psr\Log\LogLevel;
|
19 |
-
|
20 |
-
class FingersCrossedHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
24 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
25 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
26 |
-
*/
|
27 |
-
public function testHandleBuffers()
|
28 |
-
{
|
29 |
-
$test = new TestHandler();
|
30 |
-
$handler = new FingersCrossedHandler($test);
|
31 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
32 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
33 |
-
$this->assertFalse($test->hasDebugRecords());
|
34 |
-
$this->assertFalse($test->hasInfoRecords());
|
35 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
36 |
-
$handler->close();
|
37 |
-
$this->assertTrue($test->hasInfoRecords());
|
38 |
-
$this->assertTrue(count($test->getRecords()) === 3);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
43 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
44 |
-
*/
|
45 |
-
public function testHandleStopsBufferingAfterTrigger()
|
46 |
-
{
|
47 |
-
$test = new TestHandler();
|
48 |
-
$handler = new FingersCrossedHandler($test);
|
49 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
50 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
51 |
-
$handler->close();
|
52 |
-
$this->assertTrue($test->hasWarningRecords());
|
53 |
-
$this->assertTrue($test->hasDebugRecords());
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
58 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
59 |
-
* @covers Monolog\Handler\FingersCrossedHandler::reset
|
60 |
-
*/
|
61 |
-
public function testHandleResetBufferingAfterReset()
|
62 |
-
{
|
63 |
-
$test = new TestHandler();
|
64 |
-
$handler = new FingersCrossedHandler($test);
|
65 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
66 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
67 |
-
$handler->reset();
|
68 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
69 |
-
$handler->close();
|
70 |
-
$this->assertTrue($test->hasWarningRecords());
|
71 |
-
$this->assertTrue($test->hasDebugRecords());
|
72 |
-
$this->assertFalse($test->hasInfoRecords());
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
77 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
78 |
-
*/
|
79 |
-
public function testHandleResetBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled()
|
80 |
-
{
|
81 |
-
$test = new TestHandler();
|
82 |
-
$handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false);
|
83 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
84 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
85 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
86 |
-
$handler->close();
|
87 |
-
$this->assertTrue($test->hasWarningRecords());
|
88 |
-
$this->assertTrue($test->hasDebugRecords());
|
89 |
-
$this->assertFalse($test->hasInfoRecords());
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
94 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
95 |
-
*/
|
96 |
-
public function testHandleBufferLimit()
|
97 |
-
{
|
98 |
-
$test = new TestHandler();
|
99 |
-
$handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
|
100 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
101 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
102 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
103 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
104 |
-
$this->assertTrue($test->hasWarningRecords());
|
105 |
-
$this->assertTrue($test->hasInfoRecords());
|
106 |
-
$this->assertFalse($test->hasDebugRecords());
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
111 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
112 |
-
*/
|
113 |
-
public function testHandleWithCallback()
|
114 |
-
{
|
115 |
-
$test = new TestHandler();
|
116 |
-
$handler = new FingersCrossedHandler(function ($record, $handler) use ($test) {
|
117 |
-
return $test;
|
118 |
-
});
|
119 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
120 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
121 |
-
$this->assertFalse($test->hasDebugRecords());
|
122 |
-
$this->assertFalse($test->hasInfoRecords());
|
123 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
124 |
-
$this->assertTrue($test->hasInfoRecords());
|
125 |
-
$this->assertTrue(count($test->getRecords()) === 3);
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
130 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
131 |
-
* @expectedException RuntimeException
|
132 |
-
*/
|
133 |
-
public function testHandleWithBadCallbackThrowsException()
|
134 |
-
{
|
135 |
-
$handler = new FingersCrossedHandler(function ($record, $handler) {
|
136 |
-
return 'foo';
|
137 |
-
});
|
138 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* @covers Monolog\Handler\FingersCrossedHandler::isHandling
|
143 |
-
*/
|
144 |
-
public function testIsHandlingAlways()
|
145 |
-
{
|
146 |
-
$test = new TestHandler();
|
147 |
-
$handler = new FingersCrossedHandler($test, Logger::ERROR);
|
148 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
153 |
-
* @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct
|
154 |
-
* @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated
|
155 |
-
*/
|
156 |
-
public function testErrorLevelActivationStrategy()
|
157 |
-
{
|
158 |
-
$test = new TestHandler();
|
159 |
-
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING));
|
160 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
161 |
-
$this->assertFalse($test->hasDebugRecords());
|
162 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
163 |
-
$this->assertTrue($test->hasDebugRecords());
|
164 |
-
$this->assertTrue($test->hasWarningRecords());
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
169 |
-
* @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct
|
170 |
-
* @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated
|
171 |
-
*/
|
172 |
-
public function testErrorLevelActivationStrategyWithPsrLevel()
|
173 |
-
{
|
174 |
-
$test = new TestHandler();
|
175 |
-
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy('warning'));
|
176 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
177 |
-
$this->assertFalse($test->hasDebugRecords());
|
178 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
179 |
-
$this->assertTrue($test->hasDebugRecords());
|
180 |
-
$this->assertTrue($test->hasWarningRecords());
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
185 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
186 |
-
*/
|
187 |
-
public function testOverrideActivationStrategy()
|
188 |
-
{
|
189 |
-
$test = new TestHandler();
|
190 |
-
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy('warning'));
|
191 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
192 |
-
$this->assertFalse($test->hasDebugRecords());
|
193 |
-
$handler->activate();
|
194 |
-
$this->assertTrue($test->hasDebugRecords());
|
195 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
196 |
-
$this->assertTrue($test->hasInfoRecords());
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct
|
201 |
-
* @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated
|
202 |
-
*/
|
203 |
-
public function testChannelLevelActivationStrategy()
|
204 |
-
{
|
205 |
-
$test = new TestHandler();
|
206 |
-
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG)));
|
207 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
208 |
-
$this->assertFalse($test->hasWarningRecords());
|
209 |
-
$record = $this->getRecord(Logger::DEBUG);
|
210 |
-
$record['channel'] = 'othertest';
|
211 |
-
$handler->handle($record);
|
212 |
-
$this->assertTrue($test->hasDebugRecords());
|
213 |
-
$this->assertTrue($test->hasWarningRecords());
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct
|
218 |
-
* @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated
|
219 |
-
*/
|
220 |
-
public function testChannelLevelActivationStrategyWithPsrLevels()
|
221 |
-
{
|
222 |
-
$test = new TestHandler();
|
223 |
-
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy('error', array('othertest' => 'debug')));
|
224 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
225 |
-
$this->assertFalse($test->hasWarningRecords());
|
226 |
-
$record = $this->getRecord(Logger::DEBUG);
|
227 |
-
$record['channel'] = 'othertest';
|
228 |
-
$handler->handle($record);
|
229 |
-
$this->assertTrue($test->hasDebugRecords());
|
230 |
-
$this->assertTrue($test->hasWarningRecords());
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
235 |
-
* @covers Monolog\Handler\FingersCrossedHandler::activate
|
236 |
-
*/
|
237 |
-
public function testHandleUsesProcessors()
|
238 |
-
{
|
239 |
-
$test = new TestHandler();
|
240 |
-
$handler = new FingersCrossedHandler($test, Logger::INFO);
|
241 |
-
$handler->pushProcessor(function ($record) {
|
242 |
-
$record['extra']['foo'] = true;
|
243 |
-
|
244 |
-
return $record;
|
245 |
-
});
|
246 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
247 |
-
$this->assertTrue($test->hasWarningRecords());
|
248 |
-
$records = $test->getRecords();
|
249 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
250 |
-
}
|
251 |
-
|
252 |
-
/**
|
253 |
-
* @covers Monolog\Handler\FingersCrossedHandler::close
|
254 |
-
*/
|
255 |
-
public function testPassthruOnClose()
|
256 |
-
{
|
257 |
-
$test = new TestHandler();
|
258 |
-
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, Logger::INFO);
|
259 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
260 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
261 |
-
$handler->close();
|
262 |
-
$this->assertFalse($test->hasDebugRecords());
|
263 |
-
$this->assertTrue($test->hasInfoRecords());
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* @covers Monolog\Handler\FingersCrossedHandler::close
|
268 |
-
*/
|
269 |
-
public function testPsrLevelPassthruOnClose()
|
270 |
-
{
|
271 |
-
$test = new TestHandler();
|
272 |
-
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, LogLevel::INFO);
|
273 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
274 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
275 |
-
$handler->close();
|
276 |
-
$this->assertFalse($test->hasDebugRecords());
|
277 |
-
$this->assertTrue($test->hasInfoRecords());
|
278 |
-
}
|
279 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\FirePHPHandler
|
19 |
-
*/
|
20 |
-
class FirePHPHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
public function setUp()
|
23 |
-
{
|
24 |
-
TestFirePHPHandler::resetStatic();
|
25 |
-
$_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0';
|
26 |
-
}
|
27 |
-
|
28 |
-
public function testHeaders()
|
29 |
-
{
|
30 |
-
$handler = new TestFirePHPHandler;
|
31 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
32 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
33 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
34 |
-
|
35 |
-
$expected = array(
|
36 |
-
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
37 |
-
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
38 |
-
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
39 |
-
'X-Wf-1-1-1-1' => 'test',
|
40 |
-
'X-Wf-1-1-1-2' => 'test',
|
41 |
-
);
|
42 |
-
|
43 |
-
$this->assertEquals($expected, $handler->getHeaders());
|
44 |
-
}
|
45 |
-
|
46 |
-
public function testConcurrentHandlers()
|
47 |
-
{
|
48 |
-
$handler = new TestFirePHPHandler;
|
49 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
50 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
51 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
52 |
-
|
53 |
-
$handler2 = new TestFirePHPHandler;
|
54 |
-
$handler2->setFormatter($this->getIdentityFormatter());
|
55 |
-
$handler2->handle($this->getRecord(Logger::DEBUG));
|
56 |
-
$handler2->handle($this->getRecord(Logger::WARNING));
|
57 |
-
|
58 |
-
$expected = array(
|
59 |
-
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
60 |
-
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
61 |
-
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
62 |
-
'X-Wf-1-1-1-1' => 'test',
|
63 |
-
'X-Wf-1-1-1-2' => 'test',
|
64 |
-
);
|
65 |
-
|
66 |
-
$expected2 = array(
|
67 |
-
'X-Wf-1-1-1-3' => 'test',
|
68 |
-
'X-Wf-1-1-1-4' => 'test',
|
69 |
-
);
|
70 |
-
|
71 |
-
$this->assertEquals($expected, $handler->getHeaders());
|
72 |
-
$this->assertEquals($expected2, $handler2->getHeaders());
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
class TestFirePHPHandler extends FirePHPHandler
|
77 |
-
{
|
78 |
-
protected $headers = array();
|
79 |
-
|
80 |
-
public static function resetStatic()
|
81 |
-
{
|
82 |
-
self::$initialized = false;
|
83 |
-
self::$sendHeaders = true;
|
84 |
-
self::$messageIndex = 1;
|
85 |
-
}
|
86 |
-
|
87 |
-
protected function sendHeader($header, $content)
|
88 |
-
{
|
89 |
-
$this->headers[$header] = $content;
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getHeaders()
|
93 |
-
{
|
94 |
-
return $this->headers;
|
95 |
-
}
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php
DELETED
@@ -1,85 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\TestCase;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @coversDefaultClass \Monolog\Handler\FleepHookHandler
|
20 |
-
*/
|
21 |
-
class FleepHookHandlerTest extends TestCase
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Default token to use in tests
|
25 |
-
*/
|
26 |
-
const TOKEN = '123abc';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var FleepHookHandler
|
30 |
-
*/
|
31 |
-
private $handler;
|
32 |
-
|
33 |
-
public function setUp()
|
34 |
-
{
|
35 |
-
parent::setUp();
|
36 |
-
|
37 |
-
if (!extension_loaded('openssl')) {
|
38 |
-
$this->markTestSkipped('This test requires openssl extension to run');
|
39 |
-
}
|
40 |
-
|
41 |
-
// Create instances of the handler and logger for convenience
|
42 |
-
$this->handler = new FleepHookHandler(self::TOKEN);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @covers ::__construct
|
47 |
-
*/
|
48 |
-
public function testConstructorSetsExpectedDefaults()
|
49 |
-
{
|
50 |
-
$this->assertEquals(Logger::DEBUG, $this->handler->getLevel());
|
51 |
-
$this->assertEquals(true, $this->handler->getBubble());
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @covers ::getDefaultFormatter
|
56 |
-
*/
|
57 |
-
public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
|
58 |
-
{
|
59 |
-
$record = array(
|
60 |
-
'message' => 'msg',
|
61 |
-
'context' => array(),
|
62 |
-
'level' => Logger::DEBUG,
|
63 |
-
'level_name' => Logger::getLevelName(Logger::DEBUG),
|
64 |
-
'channel' => 'channel',
|
65 |
-
'datetime' => new \DateTime(),
|
66 |
-
'extra' => array(),
|
67 |
-
);
|
68 |
-
|
69 |
-
$expectedFormatter = new LineFormatter(null, null, true, true);
|
70 |
-
$expected = $expectedFormatter->format($record);
|
71 |
-
|
72 |
-
$handlerFormatter = $this->handler->getFormatter();
|
73 |
-
$actual = $handlerFormatter->format($record);
|
74 |
-
|
75 |
-
$this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @covers ::__construct
|
80 |
-
*/
|
81 |
-
public function testConnectionStringisConstructedCorrectly()
|
82 |
-
{
|
83 |
-
$this->assertEquals('ssl://' . FleepHookHandler::FLEEP_HOST . ':443', $this->handler->getConnectionString());
|
84 |
-
}
|
85 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FlowdockFormatter;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
use Monolog\Logger;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @author Dominik Liebler <liebler.dominik@gmail.com>
|
20 |
-
* @see https://www.hipchat.com/docs/api
|
21 |
-
*/
|
22 |
-
class FlowdockHandlerTest extends TestCase
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @var resource
|
26 |
-
*/
|
27 |
-
private $res;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var FlowdockHandler
|
31 |
-
*/
|
32 |
-
private $handler;
|
33 |
-
|
34 |
-
public function setUp()
|
35 |
-
{
|
36 |
-
if (!extension_loaded('openssl')) {
|
37 |
-
$this->markTestSkipped('This test requires openssl to run');
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
public function testWriteHeader()
|
42 |
-
{
|
43 |
-
$this->createHandler();
|
44 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
45 |
-
fseek($this->res, 0);
|
46 |
-
$content = fread($this->res, 1024);
|
47 |
-
|
48 |
-
$this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
49 |
-
|
50 |
-
return $content;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @depends testWriteHeader
|
55 |
-
*/
|
56 |
-
public function testWriteContent($content)
|
57 |
-
{
|
58 |
-
$this->assertRegexp('/"source":"test_source"/', $content);
|
59 |
-
$this->assertRegexp('/"from_address":"source@test\.com"/', $content);
|
60 |
-
}
|
61 |
-
|
62 |
-
private function createHandler($token = 'myToken')
|
63 |
-
{
|
64 |
-
$constructorArgs = array($token, Logger::DEBUG);
|
65 |
-
$this->res = fopen('php://memory', 'a');
|
66 |
-
$this->handler = $this->getMock(
|
67 |
-
'\Monolog\Handler\FlowdockHandler',
|
68 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
69 |
-
$constructorArgs
|
70 |
-
);
|
71 |
-
|
72 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
73 |
-
$reflectionProperty->setAccessible(true);
|
74 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
75 |
-
|
76 |
-
$this->handler->expects($this->any())
|
77 |
-
->method('fsockopen')
|
78 |
-
->will($this->returnValue($this->res));
|
79 |
-
$this->handler->expects($this->any())
|
80 |
-
->method('streamSetTimeout')
|
81 |
-
->will($this->returnValue(true));
|
82 |
-
$this->handler->expects($this->any())
|
83 |
-
->method('closeSocket')
|
84 |
-
->will($this->returnValue(true));
|
85 |
-
|
86 |
-
$this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
|
87 |
-
}
|
88 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Gelf\Message;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Monolog\Formatter\GelfMessageFormatter;
|
18 |
-
|
19 |
-
class GelfHandlerLegacyTest extends TestCase
|
20 |
-
{
|
21 |
-
public function setUp()
|
22 |
-
{
|
23 |
-
if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
|
24 |
-
$this->markTestSkipped("mlehner/gelf-php not installed");
|
25 |
-
}
|
26 |
-
|
27 |
-
require_once __DIR__ . '/GelfMockMessagePublisher.php';
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @covers Monolog\Handler\GelfHandler::__construct
|
32 |
-
*/
|
33 |
-
public function testConstruct()
|
34 |
-
{
|
35 |
-
$handler = new GelfHandler($this->getMessagePublisher());
|
36 |
-
$this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
|
37 |
-
}
|
38 |
-
|
39 |
-
protected function getHandler($messagePublisher)
|
40 |
-
{
|
41 |
-
$handler = new GelfHandler($messagePublisher);
|
42 |
-
|
43 |
-
return $handler;
|
44 |
-
}
|
45 |
-
|
46 |
-
protected function getMessagePublisher()
|
47 |
-
{
|
48 |
-
return new GelfMockMessagePublisher('localhost');
|
49 |
-
}
|
50 |
-
|
51 |
-
public function testDebug()
|
52 |
-
{
|
53 |
-
$messagePublisher = $this->getMessagePublisher();
|
54 |
-
$handler = $this->getHandler($messagePublisher);
|
55 |
-
|
56 |
-
$record = $this->getRecord(Logger::DEBUG, "A test debug message");
|
57 |
-
$handler->handle($record);
|
58 |
-
|
59 |
-
$this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
|
60 |
-
$this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
|
61 |
-
$this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
|
62 |
-
$this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
|
63 |
-
}
|
64 |
-
|
65 |
-
public function testWarning()
|
66 |
-
{
|
67 |
-
$messagePublisher = $this->getMessagePublisher();
|
68 |
-
$handler = $this->getHandler($messagePublisher);
|
69 |
-
|
70 |
-
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
71 |
-
$handler->handle($record);
|
72 |
-
|
73 |
-
$this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
|
74 |
-
$this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
|
75 |
-
$this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
|
76 |
-
$this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
|
77 |
-
}
|
78 |
-
|
79 |
-
public function testInjectedGelfMessageFormatter()
|
80 |
-
{
|
81 |
-
$messagePublisher = $this->getMessagePublisher();
|
82 |
-
$handler = $this->getHandler($messagePublisher);
|
83 |
-
|
84 |
-
$handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
|
85 |
-
|
86 |
-
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
87 |
-
$record['extra']['blarg'] = 'yep';
|
88 |
-
$record['context']['from'] = 'logger';
|
89 |
-
$handler->handle($record);
|
90 |
-
|
91 |
-
$this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
|
92 |
-
$this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
|
93 |
-
$this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Gelf\Message;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Monolog\Formatter\GelfMessageFormatter;
|
18 |
-
|
19 |
-
class GelfHandlerTest extends TestCase
|
20 |
-
{
|
21 |
-
public function setUp()
|
22 |
-
{
|
23 |
-
if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) {
|
24 |
-
$this->markTestSkipped("graylog2/gelf-php not installed");
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @covers Monolog\Handler\GelfHandler::__construct
|
30 |
-
*/
|
31 |
-
public function testConstruct()
|
32 |
-
{
|
33 |
-
$handler = new GelfHandler($this->getMessagePublisher());
|
34 |
-
$this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
|
35 |
-
}
|
36 |
-
|
37 |
-
protected function getHandler($messagePublisher)
|
38 |
-
{
|
39 |
-
$handler = new GelfHandler($messagePublisher);
|
40 |
-
|
41 |
-
return $handler;
|
42 |
-
}
|
43 |
-
|
44 |
-
protected function getMessagePublisher()
|
45 |
-
{
|
46 |
-
return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false);
|
47 |
-
}
|
48 |
-
|
49 |
-
public function testDebug()
|
50 |
-
{
|
51 |
-
$record = $this->getRecord(Logger::DEBUG, "A test debug message");
|
52 |
-
$expectedMessage = new Message();
|
53 |
-
$expectedMessage
|
54 |
-
->setLevel(7)
|
55 |
-
->setFacility("test")
|
56 |
-
->setShortMessage($record['message'])
|
57 |
-
->setTimestamp($record['datetime'])
|
58 |
-
;
|
59 |
-
|
60 |
-
$messagePublisher = $this->getMessagePublisher();
|
61 |
-
$messagePublisher->expects($this->once())
|
62 |
-
->method('publish')
|
63 |
-
->with($expectedMessage);
|
64 |
-
|
65 |
-
$handler = $this->getHandler($messagePublisher);
|
66 |
-
|
67 |
-
$handler->handle($record);
|
68 |
-
}
|
69 |
-
|
70 |
-
public function testWarning()
|
71 |
-
{
|
72 |
-
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
73 |
-
$expectedMessage = new Message();
|
74 |
-
$expectedMessage
|
75 |
-
->setLevel(4)
|
76 |
-
->setFacility("test")
|
77 |
-
->setShortMessage($record['message'])
|
78 |
-
->setTimestamp($record['datetime'])
|
79 |
-
;
|
80 |
-
|
81 |
-
$messagePublisher = $this->getMessagePublisher();
|
82 |
-
$messagePublisher->expects($this->once())
|
83 |
-
->method('publish')
|
84 |
-
->with($expectedMessage);
|
85 |
-
|
86 |
-
$handler = $this->getHandler($messagePublisher);
|
87 |
-
|
88 |
-
$handler->handle($record);
|
89 |
-
}
|
90 |
-
|
91 |
-
public function testInjectedGelfMessageFormatter()
|
92 |
-
{
|
93 |
-
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
94 |
-
$record['extra']['blarg'] = 'yep';
|
95 |
-
$record['context']['from'] = 'logger';
|
96 |
-
|
97 |
-
$expectedMessage = new Message();
|
98 |
-
$expectedMessage
|
99 |
-
->setLevel(4)
|
100 |
-
->setFacility("test")
|
101 |
-
->setHost("mysystem")
|
102 |
-
->setShortMessage($record['message'])
|
103 |
-
->setTimestamp($record['datetime'])
|
104 |
-
->setAdditional("EXTblarg", 'yep')
|
105 |
-
->setAdditional("CTXfrom", 'logger')
|
106 |
-
;
|
107 |
-
|
108 |
-
$messagePublisher = $this->getMessagePublisher();
|
109 |
-
$messagePublisher->expects($this->once())
|
110 |
-
->method('publish')
|
111 |
-
->with($expectedMessage);
|
112 |
-
|
113 |
-
$handler = $this->getHandler($messagePublisher);
|
114 |
-
$handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
|
115 |
-
$handler->handle($record);
|
116 |
-
}
|
117 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Gelf\MessagePublisher;
|
15 |
-
use Gelf\Message;
|
16 |
-
|
17 |
-
class GelfMockMessagePublisher extends MessagePublisher
|
18 |
-
{
|
19 |
-
public function publish(Message $message)
|
20 |
-
{
|
21 |
-
$this->lastMessage = $message;
|
22 |
-
}
|
23 |
-
|
24 |
-
public $lastMessage = null;
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class GroupHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\GroupHandler::__construct
|
21 |
-
* @expectedException InvalidArgumentException
|
22 |
-
*/
|
23 |
-
public function testConstructorOnlyTakesHandler()
|
24 |
-
{
|
25 |
-
new GroupHandler(array(new TestHandler(), "foo"));
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @covers Monolog\Handler\GroupHandler::__construct
|
30 |
-
* @covers Monolog\Handler\GroupHandler::handle
|
31 |
-
*/
|
32 |
-
public function testHandle()
|
33 |
-
{
|
34 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
35 |
-
$handler = new GroupHandler($testHandlers);
|
36 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
37 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
38 |
-
foreach ($testHandlers as $test) {
|
39 |
-
$this->assertTrue($test->hasDebugRecords());
|
40 |
-
$this->assertTrue($test->hasInfoRecords());
|
41 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @covers Monolog\Handler\GroupHandler::handleBatch
|
47 |
-
*/
|
48 |
-
public function testHandleBatch()
|
49 |
-
{
|
50 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
51 |
-
$handler = new GroupHandler($testHandlers);
|
52 |
-
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
53 |
-
foreach ($testHandlers as $test) {
|
54 |
-
$this->assertTrue($test->hasDebugRecords());
|
55 |
-
$this->assertTrue($test->hasInfoRecords());
|
56 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @covers Monolog\Handler\GroupHandler::isHandling
|
62 |
-
*/
|
63 |
-
public function testIsHandling()
|
64 |
-
{
|
65 |
-
$testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
|
66 |
-
$handler = new GroupHandler($testHandlers);
|
67 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
|
68 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
|
69 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @covers Monolog\Handler\GroupHandler::handle
|
74 |
-
*/
|
75 |
-
public function testHandleUsesProcessors()
|
76 |
-
{
|
77 |
-
$test = new TestHandler();
|
78 |
-
$handler = new GroupHandler(array($test));
|
79 |
-
$handler->pushProcessor(function ($record) {
|
80 |
-
$record['extra']['foo'] = true;
|
81 |
-
|
82 |
-
return $record;
|
83 |
-
});
|
84 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
85 |
-
$this->assertTrue($test->hasWarningRecords());
|
86 |
-
$records = $test->getRecords();
|
87 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* @covers Monolog\Handler\GroupHandler::handle
|
92 |
-
*/
|
93 |
-
public function testHandleBatchUsesProcessors()
|
94 |
-
{
|
95 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
96 |
-
$handler = new GroupHandler($testHandlers);
|
97 |
-
$handler->pushProcessor(function ($record) {
|
98 |
-
$record['extra']['foo'] = true;
|
99 |
-
|
100 |
-
return $record;
|
101 |
-
});
|
102 |
-
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
103 |
-
foreach ($testHandlers as $test) {
|
104 |
-
$this->assertTrue($test->hasDebugRecords());
|
105 |
-
$this->assertTrue($test->hasInfoRecords());
|
106 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
107 |
-
$records = $test->getRecords();
|
108 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
109 |
-
$this->assertTrue($records[1]['extra']['foo']);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/HandlerWrapperTest.php
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Alexey Karapetov <alexey@karapetov.com>
|
18 |
-
*/
|
19 |
-
class HandlerWrapperTest extends TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var HandlerWrapper
|
23 |
-
*/
|
24 |
-
private $wrapper;
|
25 |
-
|
26 |
-
private $handler;
|
27 |
-
|
28 |
-
public function setUp()
|
29 |
-
{
|
30 |
-
parent::setUp();
|
31 |
-
$this->handler = $this->getMock('Monolog\\Handler\\HandlerInterface');
|
32 |
-
$this->wrapper = new HandlerWrapper($this->handler);
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @return array
|
37 |
-
*/
|
38 |
-
public function trueFalseDataProvider()
|
39 |
-
{
|
40 |
-
return array(
|
41 |
-
array(true),
|
42 |
-
array(false),
|
43 |
-
);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @param $result
|
48 |
-
* @dataProvider trueFalseDataProvider
|
49 |
-
*/
|
50 |
-
public function testIsHandling($result)
|
51 |
-
{
|
52 |
-
$record = $this->getRecord();
|
53 |
-
$this->handler->expects($this->once())
|
54 |
-
->method('isHandling')
|
55 |
-
->with($record)
|
56 |
-
->willReturn($result);
|
57 |
-
|
58 |
-
$this->assertEquals($result, $this->wrapper->isHandling($record));
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @param $result
|
63 |
-
* @dataProvider trueFalseDataProvider
|
64 |
-
*/
|
65 |
-
public function testHandle($result)
|
66 |
-
{
|
67 |
-
$record = $this->getRecord();
|
68 |
-
$this->handler->expects($this->once())
|
69 |
-
->method('handle')
|
70 |
-
->with($record)
|
71 |
-
->willReturn($result);
|
72 |
-
|
73 |
-
$this->assertEquals($result, $this->wrapper->handle($record));
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @param $result
|
78 |
-
* @dataProvider trueFalseDataProvider
|
79 |
-
*/
|
80 |
-
public function testHandleBatch($result)
|
81 |
-
{
|
82 |
-
$records = $this->getMultipleRecords();
|
83 |
-
$this->handler->expects($this->once())
|
84 |
-
->method('handleBatch')
|
85 |
-
->with($records)
|
86 |
-
->willReturn($result);
|
87 |
-
|
88 |
-
$this->assertEquals($result, $this->wrapper->handleBatch($records));
|
89 |
-
}
|
90 |
-
|
91 |
-
public function testPushProcessor()
|
92 |
-
{
|
93 |
-
$processor = function () {};
|
94 |
-
$this->handler->expects($this->once())
|
95 |
-
->method('pushProcessor')
|
96 |
-
->with($processor);
|
97 |
-
|
98 |
-
$this->assertEquals($this->wrapper, $this->wrapper->pushProcessor($processor));
|
99 |
-
}
|
100 |
-
|
101 |
-
public function testPopProcessor()
|
102 |
-
{
|
103 |
-
$processor = function () {};
|
104 |
-
$this->handler->expects($this->once())
|
105 |
-
->method('popProcessor')
|
106 |
-
->willReturn($processor);
|
107 |
-
|
108 |
-
$this->assertEquals($processor, $this->wrapper->popProcessor());
|
109 |
-
}
|
110 |
-
|
111 |
-
public function testSetFormatter()
|
112 |
-
{
|
113 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
114 |
-
$this->handler->expects($this->once())
|
115 |
-
->method('setFormatter')
|
116 |
-
->with($formatter);
|
117 |
-
|
118 |
-
$this->assertEquals($this->wrapper, $this->wrapper->setFormatter($formatter));
|
119 |
-
}
|
120 |
-
|
121 |
-
public function testGetFormatter()
|
122 |
-
{
|
123 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
124 |
-
$this->handler->expects($this->once())
|
125 |
-
->method('getFormatter')
|
126 |
-
->willReturn($formatter);
|
127 |
-
|
128 |
-
$this->assertEquals($formatter, $this->wrapper->getFormatter());
|
129 |
-
}
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php
DELETED
@@ -1,279 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Rafael Dohms <rafael@doh.ms>
|
19 |
-
* @see https://www.hipchat.com/docs/api
|
20 |
-
*/
|
21 |
-
class HipChatHandlerTest extends TestCase
|
22 |
-
{
|
23 |
-
private $res;
|
24 |
-
/** @var HipChatHandler */
|
25 |
-
private $handler;
|
26 |
-
|
27 |
-
public function testWriteHeader()
|
28 |
-
{
|
29 |
-
$this->createHandler();
|
30 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
31 |
-
fseek($this->res, 0);
|
32 |
-
$content = fread($this->res, 1024);
|
33 |
-
|
34 |
-
$this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
35 |
-
|
36 |
-
return $content;
|
37 |
-
}
|
38 |
-
|
39 |
-
public function testWriteCustomHostHeader()
|
40 |
-
{
|
41 |
-
$this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar');
|
42 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
43 |
-
fseek($this->res, 0);
|
44 |
-
$content = fread($this->res, 1024);
|
45 |
-
|
46 |
-
$this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
47 |
-
|
48 |
-
return $content;
|
49 |
-
}
|
50 |
-
|
51 |
-
public function testWriteV2()
|
52 |
-
{
|
53 |
-
$this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2');
|
54 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
55 |
-
fseek($this->res, 0);
|
56 |
-
$content = fread($this->res, 1024);
|
57 |
-
|
58 |
-
$this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
59 |
-
|
60 |
-
return $content;
|
61 |
-
}
|
62 |
-
|
63 |
-
public function testWriteV2Notify()
|
64 |
-
{
|
65 |
-
$this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2');
|
66 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
67 |
-
fseek($this->res, 0);
|
68 |
-
$content = fread($this->res, 1024);
|
69 |
-
|
70 |
-
$this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
71 |
-
|
72 |
-
return $content;
|
73 |
-
}
|
74 |
-
|
75 |
-
public function testRoomSpaces()
|
76 |
-
{
|
77 |
-
$this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2');
|
78 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
79 |
-
fseek($this->res, 0);
|
80 |
-
$content = fread($this->res, 1024);
|
81 |
-
|
82 |
-
$this->assertRegexp('/POST \/v2\/room\/room%20name\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
83 |
-
|
84 |
-
return $content;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @depends testWriteHeader
|
89 |
-
*/
|
90 |
-
public function testWriteContent($content)
|
91 |
-
{
|
92 |
-
$this->assertRegexp('/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
|
93 |
-
}
|
94 |
-
|
95 |
-
public function testWriteContentV1WithoutName()
|
96 |
-
{
|
97 |
-
$this->createHandler('myToken', 'room1', null, false, 'hipchat.foo.bar', 'v1');
|
98 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
99 |
-
fseek($this->res, 0);
|
100 |
-
$content = fread($this->res, 1024);
|
101 |
-
|
102 |
-
$this->assertRegexp('/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=$/', $content);
|
103 |
-
|
104 |
-
return $content;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* @depends testWriteCustomHostHeader
|
109 |
-
*/
|
110 |
-
public function testWriteContentNotify($content)
|
111 |
-
{
|
112 |
-
$this->assertRegexp('/notify=1&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @depends testWriteV2
|
117 |
-
*/
|
118 |
-
public function testWriteContentV2($content)
|
119 |
-
{
|
120 |
-
$this->assertRegexp('/notify=false&message=test1&message_format=text&color=red&from=Monolog$/', $content);
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* @depends testWriteV2Notify
|
125 |
-
*/
|
126 |
-
public function testWriteContentV2Notify($content)
|
127 |
-
{
|
128 |
-
$this->assertRegexp('/notify=true&message=test1&message_format=text&color=red&from=Monolog$/', $content);
|
129 |
-
}
|
130 |
-
|
131 |
-
public function testWriteContentV2WithoutName()
|
132 |
-
{
|
133 |
-
$this->createHandler('myToken', 'room1', null, false, 'hipchat.foo.bar', 'v2');
|
134 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
135 |
-
fseek($this->res, 0);
|
136 |
-
$content = fread($this->res, 1024);
|
137 |
-
|
138 |
-
$this->assertRegexp('/notify=false&message=test1&message_format=text&color=red$/', $content);
|
139 |
-
|
140 |
-
return $content;
|
141 |
-
}
|
142 |
-
|
143 |
-
public function testWriteWithComplexMessage()
|
144 |
-
{
|
145 |
-
$this->createHandler();
|
146 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
|
147 |
-
fseek($this->res, 0);
|
148 |
-
$content = fread($this->res, 1024);
|
149 |
-
|
150 |
-
$this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
|
151 |
-
}
|
152 |
-
|
153 |
-
public function testWriteTruncatesLongMessage()
|
154 |
-
{
|
155 |
-
$this->createHandler();
|
156 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, str_repeat('abcde', 2000)));
|
157 |
-
fseek($this->res, 0);
|
158 |
-
$content = fread($this->res, 12000);
|
159 |
-
|
160 |
-
$this->assertRegexp('/message='.str_repeat('abcde', 1900).'\+%5Btruncated%5D/', $content);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @dataProvider provideLevelColors
|
165 |
-
*/
|
166 |
-
public function testWriteWithErrorLevelsAndColors($level, $expectedColor)
|
167 |
-
{
|
168 |
-
$this->createHandler();
|
169 |
-
$this->handler->handle($this->getRecord($level, 'Backup of database "example" finished in 16 minutes.'));
|
170 |
-
fseek($this->res, 0);
|
171 |
-
$content = fread($this->res, 1024);
|
172 |
-
|
173 |
-
$this->assertRegexp('/color='.$expectedColor.'/', $content);
|
174 |
-
}
|
175 |
-
|
176 |
-
public function provideLevelColors()
|
177 |
-
{
|
178 |
-
return array(
|
179 |
-
array(Logger::DEBUG, 'gray'),
|
180 |
-
array(Logger::INFO, 'green'),
|
181 |
-
array(Logger::WARNING, 'yellow'),
|
182 |
-
array(Logger::ERROR, 'red'),
|
183 |
-
array(Logger::CRITICAL, 'red'),
|
184 |
-
array(Logger::ALERT, 'red'),
|
185 |
-
array(Logger::EMERGENCY,'red'),
|
186 |
-
array(Logger::NOTICE, 'green'),
|
187 |
-
);
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* @dataProvider provideBatchRecords
|
192 |
-
*/
|
193 |
-
public function testHandleBatch($records, $expectedColor)
|
194 |
-
{
|
195 |
-
$this->createHandler();
|
196 |
-
|
197 |
-
$this->handler->handleBatch($records);
|
198 |
-
|
199 |
-
fseek($this->res, 0);
|
200 |
-
$content = fread($this->res, 1024);
|
201 |
-
|
202 |
-
$this->assertRegexp('/color='.$expectedColor.'/', $content);
|
203 |
-
}
|
204 |
-
|
205 |
-
public function provideBatchRecords()
|
206 |
-
{
|
207 |
-
return array(
|
208 |
-
array(
|
209 |
-
array(
|
210 |
-
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
|
211 |
-
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
212 |
-
array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime()),
|
213 |
-
),
|
214 |
-
'red',
|
215 |
-
),
|
216 |
-
array(
|
217 |
-
array(
|
218 |
-
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
|
219 |
-
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
220 |
-
),
|
221 |
-
'yellow',
|
222 |
-
),
|
223 |
-
array(
|
224 |
-
array(
|
225 |
-
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
|
226 |
-
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
|
227 |
-
),
|
228 |
-
'green',
|
229 |
-
),
|
230 |
-
array(
|
231 |
-
array(
|
232 |
-
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
|
233 |
-
),
|
234 |
-
'gray',
|
235 |
-
),
|
236 |
-
);
|
237 |
-
}
|
238 |
-
|
239 |
-
private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com', $version = 'v1')
|
240 |
-
{
|
241 |
-
$constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version);
|
242 |
-
$this->res = fopen('php://memory', 'a');
|
243 |
-
$this->handler = $this->getMock(
|
244 |
-
'\Monolog\Handler\HipChatHandler',
|
245 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
246 |
-
$constructorArgs
|
247 |
-
);
|
248 |
-
|
249 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
250 |
-
$reflectionProperty->setAccessible(true);
|
251 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
252 |
-
|
253 |
-
$this->handler->expects($this->any())
|
254 |
-
->method('fsockopen')
|
255 |
-
->will($this->returnValue($this->res));
|
256 |
-
$this->handler->expects($this->any())
|
257 |
-
->method('streamSetTimeout')
|
258 |
-
->will($this->returnValue(true));
|
259 |
-
$this->handler->expects($this->any())
|
260 |
-
->method('closeSocket')
|
261 |
-
->will($this->returnValue(true));
|
262 |
-
|
263 |
-
$this->handler->setFormatter($this->getIdentityFormatter());
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* @expectedException InvalidArgumentException
|
268 |
-
*/
|
269 |
-
public function testCreateWithTooLongName()
|
270 |
-
{
|
271 |
-
$hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere');
|
272 |
-
}
|
273 |
-
|
274 |
-
public function testCreateWithTooLongNameV2()
|
275 |
-
{
|
276 |
-
// creating a handler with too long of a name but using the v2 api doesn't matter.
|
277 |
-
$hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2');
|
278 |
-
}
|
279 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Robert Kaufmann III <rok3@rok3.me>
|
19 |
-
* @author Gabriel Machado <gabriel.ms1@hotmail.com>
|
20 |
-
*/
|
21 |
-
class InsightOpsHandlerTest extends TestCase
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* @var resource
|
25 |
-
*/
|
26 |
-
private $resource;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var LogEntriesHandler
|
30 |
-
*/
|
31 |
-
private $handler;
|
32 |
-
|
33 |
-
public function testWriteContent()
|
34 |
-
{
|
35 |
-
$this->createHandler();
|
36 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
|
37 |
-
|
38 |
-
fseek($this->resource, 0);
|
39 |
-
$content = fread($this->resource, 1024);
|
40 |
-
|
41 |
-
$this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
|
42 |
-
}
|
43 |
-
|
44 |
-
public function testWriteBatchContent()
|
45 |
-
{
|
46 |
-
$this->createHandler();
|
47 |
-
$this->handler->handleBatch($this->getMultipleRecords());
|
48 |
-
|
49 |
-
fseek($this->resource, 0);
|
50 |
-
$content = fread($this->resource, 1024);
|
51 |
-
|
52 |
-
$this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
|
53 |
-
}
|
54 |
-
|
55 |
-
private function createHandler()
|
56 |
-
{
|
57 |
-
$useSSL = extension_loaded('openssl');
|
58 |
-
$args = array('testToken', 'us', $useSSL, Logger::DEBUG, true);
|
59 |
-
$this->resource = fopen('php://memory', 'a');
|
60 |
-
$this->handler = $this->getMock(
|
61 |
-
'\Monolog\Handler\InsightOpsHandler',
|
62 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
63 |
-
$args
|
64 |
-
);
|
65 |
-
|
66 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
67 |
-
$reflectionProperty->setAccessible(true);
|
68 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
69 |
-
|
70 |
-
$this->handler->expects($this->any())
|
71 |
-
->method('fsockopen')
|
72 |
-
->will($this->returnValue($this->resource));
|
73 |
-
$this->handler->expects($this->any())
|
74 |
-
->method('streamSetTimeout')
|
75 |
-
->will($this->returnValue(true));
|
76 |
-
$this->handler->expects($this->any())
|
77 |
-
->method('closeSocket')
|
78 |
-
->will($this->returnValue(true));
|
79 |
-
}
|
80 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Robert Kaufmann III <rok3@rok3.me>
|
19 |
-
*/
|
20 |
-
class LogEntriesHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @var resource
|
24 |
-
*/
|
25 |
-
private $res;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var LogEntriesHandler
|
29 |
-
*/
|
30 |
-
private $handler;
|
31 |
-
|
32 |
-
public function testWriteContent()
|
33 |
-
{
|
34 |
-
$this->createHandler();
|
35 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
|
36 |
-
|
37 |
-
fseek($this->res, 0);
|
38 |
-
$content = fread($this->res, 1024);
|
39 |
-
|
40 |
-
$this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
|
41 |
-
}
|
42 |
-
|
43 |
-
public function testWriteBatchContent()
|
44 |
-
{
|
45 |
-
$records = array(
|
46 |
-
$this->getRecord(),
|
47 |
-
$this->getRecord(),
|
48 |
-
$this->getRecord(),
|
49 |
-
);
|
50 |
-
$this->createHandler();
|
51 |
-
$this->handler->handleBatch($records);
|
52 |
-
|
53 |
-
fseek($this->res, 0);
|
54 |
-
$content = fread($this->res, 1024);
|
55 |
-
|
56 |
-
$this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
|
57 |
-
}
|
58 |
-
|
59 |
-
private function createHandler()
|
60 |
-
{
|
61 |
-
$useSSL = extension_loaded('openssl');
|
62 |
-
$args = array('testToken', $useSSL, Logger::DEBUG, true);
|
63 |
-
$this->res = fopen('php://memory', 'a');
|
64 |
-
$this->handler = $this->getMock(
|
65 |
-
'\Monolog\Handler\LogEntriesHandler',
|
66 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
67 |
-
$args
|
68 |
-
);
|
69 |
-
|
70 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
71 |
-
$reflectionProperty->setAccessible(true);
|
72 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
73 |
-
|
74 |
-
$this->handler->expects($this->any())
|
75 |
-
->method('fsockopen')
|
76 |
-
->will($this->returnValue($this->res));
|
77 |
-
$this->handler->expects($this->any())
|
78 |
-
->method('streamSetTimeout')
|
79 |
-
->will($this->returnValue(true));
|
80 |
-
$this->handler->expects($this->any())
|
81 |
-
->method('closeSocket')
|
82 |
-
->will($this->returnValue(true));
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class MailHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\MailHandler::handleBatch
|
21 |
-
*/
|
22 |
-
public function testHandleBatch()
|
23 |
-
{
|
24 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
25 |
-
$formatter->expects($this->once())
|
26 |
-
->method('formatBatch'); // Each record is formatted
|
27 |
-
|
28 |
-
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
29 |
-
$handler->expects($this->once())
|
30 |
-
->method('send');
|
31 |
-
$handler->expects($this->never())
|
32 |
-
->method('write'); // write is for individual records
|
33 |
-
|
34 |
-
$handler->setFormatter($formatter);
|
35 |
-
|
36 |
-
$handler->handleBatch($this->getMultipleRecords());
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @covers Monolog\Handler\MailHandler::handleBatch
|
41 |
-
*/
|
42 |
-
public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
|
43 |
-
{
|
44 |
-
$records = array(
|
45 |
-
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
46 |
-
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
47 |
-
$this->getRecord(Logger::INFO, 'information'),
|
48 |
-
);
|
49 |
-
|
50 |
-
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
51 |
-
$handler->expects($this->never())
|
52 |
-
->method('send');
|
53 |
-
$handler->setLevel(Logger::ERROR);
|
54 |
-
|
55 |
-
$handler->handleBatch($records);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @covers Monolog\Handler\MailHandler::write
|
60 |
-
*/
|
61 |
-
public function testHandle()
|
62 |
-
{
|
63 |
-
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
64 |
-
|
65 |
-
$record = $this->getRecord();
|
66 |
-
$records = array($record);
|
67 |
-
$records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n";
|
68 |
-
|
69 |
-
$handler->expects($this->once())
|
70 |
-
->method('send')
|
71 |
-
->with($records[0]['formatted'], $records);
|
72 |
-
|
73 |
-
$handler->handle($record);
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Raven_Client;
|
15 |
-
|
16 |
-
class MockRavenClient extends Raven_Client
|
17 |
-
{
|
18 |
-
public function capture($data, $stack, $vars = null)
|
19 |
-
{
|
20 |
-
$data = array_merge($this->get_user_data(), $data);
|
21 |
-
$this->lastData = $data;
|
22 |
-
$this->lastStack = $stack;
|
23 |
-
}
|
24 |
-
|
25 |
-
public $lastData;
|
26 |
-
public $lastStack;
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class MongoDBHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @expectedException InvalidArgumentException
|
21 |
-
*/
|
22 |
-
public function testConstructorShouldThrowExceptionForInvalidMongo()
|
23 |
-
{
|
24 |
-
new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
|
25 |
-
}
|
26 |
-
|
27 |
-
public function testHandle()
|
28 |
-
{
|
29 |
-
$mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
|
30 |
-
$collection = $this->getMock('stdClass', array('save'));
|
31 |
-
|
32 |
-
$mongo->expects($this->once())
|
33 |
-
->method('selectCollection')
|
34 |
-
->with('DB', 'Collection')
|
35 |
-
->will($this->returnValue($collection));
|
36 |
-
|
37 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
38 |
-
|
39 |
-
$expected = array(
|
40 |
-
'message' => 'test',
|
41 |
-
'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
|
42 |
-
'level' => Logger::WARNING,
|
43 |
-
'level_name' => 'WARNING',
|
44 |
-
'channel' => 'test',
|
45 |
-
'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
|
46 |
-
'extra' => array(),
|
47 |
-
);
|
48 |
-
|
49 |
-
$collection->expects($this->once())
|
50 |
-
->method('save')
|
51 |
-
->with($expected);
|
52 |
-
|
53 |
-
$handler = new MongoDBHandler($mongo, 'DB', 'Collection');
|
54 |
-
$handler->handle($record);
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
if (!class_exists('Mongo')) {
|
59 |
-
class Mongo
|
60 |
-
{
|
61 |
-
public function selectCollection()
|
62 |
-
{
|
63 |
-
}
|
64 |
-
}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use InvalidArgumentException;
|
17 |
-
|
18 |
-
function mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null)
|
19 |
-
{
|
20 |
-
$GLOBALS['mail'][] = func_get_args();
|
21 |
-
}
|
22 |
-
|
23 |
-
class NativeMailerHandlerTest extends TestCase
|
24 |
-
{
|
25 |
-
protected function setUp()
|
26 |
-
{
|
27 |
-
$GLOBALS['mail'] = array();
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @expectedException InvalidArgumentException
|
32 |
-
*/
|
33 |
-
public function testConstructorHeaderInjection()
|
34 |
-
{
|
35 |
-
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @expectedException InvalidArgumentException
|
40 |
-
*/
|
41 |
-
public function testSetterHeaderInjection()
|
42 |
-
{
|
43 |
-
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
44 |
-
$mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @expectedException InvalidArgumentException
|
49 |
-
*/
|
50 |
-
public function testSetterArrayHeaderInjection()
|
51 |
-
{
|
52 |
-
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
53 |
-
$mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @expectedException InvalidArgumentException
|
58 |
-
*/
|
59 |
-
public function testSetterContentTypeInjection()
|
60 |
-
{
|
61 |
-
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
62 |
-
$mailer->setContentType("text/html\r\nFrom: faked@attacker.org");
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* @expectedException InvalidArgumentException
|
67 |
-
*/
|
68 |
-
public function testSetterEncodingInjection()
|
69 |
-
{
|
70 |
-
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
71 |
-
$mailer->setEncoding("utf-8\r\nFrom: faked@attacker.org");
|
72 |
-
}
|
73 |
-
|
74 |
-
public function testSend()
|
75 |
-
{
|
76 |
-
$to = 'spammer@example.org';
|
77 |
-
$subject = 'dear victim';
|
78 |
-
$from = 'receiver@example.org';
|
79 |
-
|
80 |
-
$mailer = new NativeMailerHandler($to, $subject, $from);
|
81 |
-
$mailer->handleBatch(array());
|
82 |
-
|
83 |
-
// batch is empty, nothing sent
|
84 |
-
$this->assertEmpty($GLOBALS['mail']);
|
85 |
-
|
86 |
-
// non-empty batch
|
87 |
-
$mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
|
88 |
-
$this->assertNotEmpty($GLOBALS['mail']);
|
89 |
-
$this->assertInternalType('array', $GLOBALS['mail']);
|
90 |
-
$this->assertArrayHasKey('0', $GLOBALS['mail']);
|
91 |
-
$params = $GLOBALS['mail'][0];
|
92 |
-
$this->assertCount(5, $params);
|
93 |
-
$this->assertSame($to, $params[0]);
|
94 |
-
$this->assertSame($subject, $params[1]);
|
95 |
-
$this->assertStringEndsWith(" test.ERROR: Foo Bar Baz [] []\n", $params[2]);
|
96 |
-
$this->assertSame("From: $from\r\nContent-type: text/plain; charset=utf-8\r\n", $params[3]);
|
97 |
-
$this->assertSame('', $params[4]);
|
98 |
-
}
|
99 |
-
|
100 |
-
public function testMessageSubjectFormatting()
|
101 |
-
{
|
102 |
-
$mailer = new NativeMailerHandler('to@example.org', 'Alert: %level_name% %message%', 'from@example.org');
|
103 |
-
$mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
|
104 |
-
$this->assertNotEmpty($GLOBALS['mail']);
|
105 |
-
$this->assertInternalType('array', $GLOBALS['mail']);
|
106 |
-
$this->assertArrayHasKey('0', $GLOBALS['mail']);
|
107 |
-
$params = $GLOBALS['mail'][0];
|
108 |
-
$this->assertCount(5, $params);
|
109 |
-
$this->assertSame('Alert: ERROR Foo Bar Baz', $params[1]);
|
110 |
-
}
|
111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php
DELETED
@@ -1,200 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
use Monolog\Logger;
|
17 |
-
|
18 |
-
class NewRelicHandlerTest extends TestCase
|
19 |
-
{
|
20 |
-
public static $appname;
|
21 |
-
public static $customParameters;
|
22 |
-
public static $transactionName;
|
23 |
-
|
24 |
-
public function setUp()
|
25 |
-
{
|
26 |
-
self::$appname = null;
|
27 |
-
self::$customParameters = array();
|
28 |
-
self::$transactionName = null;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @expectedException Monolog\Handler\MissingExtensionException
|
33 |
-
*/
|
34 |
-
public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded()
|
35 |
-
{
|
36 |
-
$handler = new StubNewRelicHandlerWithoutExtension();
|
37 |
-
$handler->handle($this->getRecord(Logger::ERROR));
|
38 |
-
}
|
39 |
-
|
40 |
-
public function testThehandlerCanHandleTheRecord()
|
41 |
-
{
|
42 |
-
$handler = new StubNewRelicHandler();
|
43 |
-
$handler->handle($this->getRecord(Logger::ERROR));
|
44 |
-
}
|
45 |
-
|
46 |
-
public function testThehandlerCanAddContextParamsToTheNewRelicTrace()
|
47 |
-
{
|
48 |
-
$handler = new StubNewRelicHandler();
|
49 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
|
50 |
-
$this->assertEquals(array('context_a' => 'b'), self::$customParameters);
|
51 |
-
}
|
52 |
-
|
53 |
-
public function testThehandlerCanAddExplodedContextParamsToTheNewRelicTrace()
|
54 |
-
{
|
55 |
-
$handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
|
56 |
-
$handler->handle($this->getRecord(
|
57 |
-
Logger::ERROR,
|
58 |
-
'log message',
|
59 |
-
array('a' => array('key1' => 'value1', 'key2' => 'value2'))
|
60 |
-
));
|
61 |
-
$this->assertEquals(
|
62 |
-
array('context_a_key1' => 'value1', 'context_a_key2' => 'value2'),
|
63 |
-
self::$customParameters
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
|
68 |
-
{
|
69 |
-
$record = $this->getRecord(Logger::ERROR, 'log message');
|
70 |
-
$record['extra'] = array('c' => 'd');
|
71 |
-
|
72 |
-
$handler = new StubNewRelicHandler();
|
73 |
-
$handler->handle($record);
|
74 |
-
|
75 |
-
$this->assertEquals(array('extra_c' => 'd'), self::$customParameters);
|
76 |
-
}
|
77 |
-
|
78 |
-
public function testThehandlerCanAddExplodedExtraParamsToTheNewRelicTrace()
|
79 |
-
{
|
80 |
-
$record = $this->getRecord(Logger::ERROR, 'log message');
|
81 |
-
$record['extra'] = array('c' => array('key1' => 'value1', 'key2' => 'value2'));
|
82 |
-
|
83 |
-
$handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
|
84 |
-
$handler->handle($record);
|
85 |
-
|
86 |
-
$this->assertEquals(
|
87 |
-
array('extra_c_key1' => 'value1', 'extra_c_key2' => 'value2'),
|
88 |
-
self::$customParameters
|
89 |
-
);
|
90 |
-
}
|
91 |
-
|
92 |
-
public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
|
93 |
-
{
|
94 |
-
$record = $this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'));
|
95 |
-
$record['extra'] = array('c' => 'd');
|
96 |
-
|
97 |
-
$handler = new StubNewRelicHandler();
|
98 |
-
$handler->handle($record);
|
99 |
-
|
100 |
-
$expected = array(
|
101 |
-
'context_a' => 'b',
|
102 |
-
'extra_c' => 'd',
|
103 |
-
);
|
104 |
-
|
105 |
-
$this->assertEquals($expected, self::$customParameters);
|
106 |
-
}
|
107 |
-
|
108 |
-
public function testThehandlerCanHandleTheRecordsFormattedUsingTheLineFormatter()
|
109 |
-
{
|
110 |
-
$handler = new StubNewRelicHandler();
|
111 |
-
$handler->setFormatter(new LineFormatter());
|
112 |
-
$handler->handle($this->getRecord(Logger::ERROR));
|
113 |
-
}
|
114 |
-
|
115 |
-
public function testTheAppNameIsNullByDefault()
|
116 |
-
{
|
117 |
-
$handler = new StubNewRelicHandler();
|
118 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message'));
|
119 |
-
|
120 |
-
$this->assertEquals(null, self::$appname);
|
121 |
-
}
|
122 |
-
|
123 |
-
public function testTheAppNameCanBeInjectedFromtheConstructor()
|
124 |
-
{
|
125 |
-
$handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName');
|
126 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message'));
|
127 |
-
|
128 |
-
$this->assertEquals('myAppName', self::$appname);
|
129 |
-
}
|
130 |
-
|
131 |
-
public function testTheAppNameCanBeOverriddenFromEachLog()
|
132 |
-
{
|
133 |
-
$handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName');
|
134 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName')));
|
135 |
-
|
136 |
-
$this->assertEquals('logAppName', self::$appname);
|
137 |
-
}
|
138 |
-
|
139 |
-
public function testTheTransactionNameIsNullByDefault()
|
140 |
-
{
|
141 |
-
$handler = new StubNewRelicHandler();
|
142 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message'));
|
143 |
-
|
144 |
-
$this->assertEquals(null, self::$transactionName);
|
145 |
-
}
|
146 |
-
|
147 |
-
public function testTheTransactionNameCanBeInjectedFromTheConstructor()
|
148 |
-
{
|
149 |
-
$handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction');
|
150 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message'));
|
151 |
-
|
152 |
-
$this->assertEquals('myTransaction', self::$transactionName);
|
153 |
-
}
|
154 |
-
|
155 |
-
public function testTheTransactionNameCanBeOverriddenFromEachLog()
|
156 |
-
{
|
157 |
-
$handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction');
|
158 |
-
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('transaction_name' => 'logTransactName')));
|
159 |
-
|
160 |
-
$this->assertEquals('logTransactName', self::$transactionName);
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
|
165 |
-
{
|
166 |
-
protected function isNewRelicEnabled()
|
167 |
-
{
|
168 |
-
return false;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
class StubNewRelicHandler extends NewRelicHandler
|
173 |
-
{
|
174 |
-
protected function isNewRelicEnabled()
|
175 |
-
{
|
176 |
-
return true;
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
function newrelic_notice_error()
|
181 |
-
{
|
182 |
-
return true;
|
183 |
-
}
|
184 |
-
|
185 |
-
function newrelic_set_appname($appname)
|
186 |
-
{
|
187 |
-
return NewRelicHandlerTest::$appname = $appname;
|
188 |
-
}
|
189 |
-
|
190 |
-
function newrelic_name_transaction($transactionName)
|
191 |
-
{
|
192 |
-
return NewRelicHandlerTest::$transactionName = $transactionName;
|
193 |
-
}
|
194 |
-
|
195 |
-
function newrelic_add_custom_parameter($key, $value)
|
196 |
-
{
|
197 |
-
NewRelicHandlerTest::$customParameters[$key] = $value;
|
198 |
-
|
199 |
-
return true;
|
200 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\NullHandler::handle
|
19 |
-
*/
|
20 |
-
class NullHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
public function testHandle()
|
23 |
-
{
|
24 |
-
$handler = new NullHandler();
|
25 |
-
$this->assertTrue($handler->handle($this->getRecord()));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function testHandleLowerLevelRecord()
|
29 |
-
{
|
30 |
-
$handler = new NullHandler(Logger::WARNING);
|
31 |
-
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php
DELETED
@@ -1,273 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Exception;
|
15 |
-
use Monolog\ErrorHandler;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Monolog\TestCase;
|
18 |
-
use PhpConsole\Connector;
|
19 |
-
use PhpConsole\Dispatcher\Debug as DebugDispatcher;
|
20 |
-
use PhpConsole\Dispatcher\Errors as ErrorDispatcher;
|
21 |
-
use PhpConsole\Handler;
|
22 |
-
use PHPUnit_Framework_MockObject_MockObject;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @covers Monolog\Handler\PHPConsoleHandler
|
26 |
-
* @author Sergey Barbushin https://www.linkedin.com/in/barbushin
|
27 |
-
*/
|
28 |
-
class PHPConsoleHandlerTest extends TestCase
|
29 |
-
{
|
30 |
-
/** @var Connector|PHPUnit_Framework_MockObject_MockObject */
|
31 |
-
protected $connector;
|
32 |
-
/** @var DebugDispatcher|PHPUnit_Framework_MockObject_MockObject */
|
33 |
-
protected $debugDispatcher;
|
34 |
-
/** @var ErrorDispatcher|PHPUnit_Framework_MockObject_MockObject */
|
35 |
-
protected $errorDispatcher;
|
36 |
-
|
37 |
-
protected function setUp()
|
38 |
-
{
|
39 |
-
if (!class_exists('PhpConsole\Connector')) {
|
40 |
-
$this->markTestSkipped('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
|
41 |
-
}
|
42 |
-
$this->connector = $this->initConnectorMock();
|
43 |
-
|
44 |
-
$this->debugDispatcher = $this->initDebugDispatcherMock($this->connector);
|
45 |
-
$this->connector->setDebugDispatcher($this->debugDispatcher);
|
46 |
-
|
47 |
-
$this->errorDispatcher = $this->initErrorDispatcherMock($this->connector);
|
48 |
-
$this->connector->setErrorsDispatcher($this->errorDispatcher);
|
49 |
-
}
|
50 |
-
|
51 |
-
protected function initDebugDispatcherMock(Connector $connector)
|
52 |
-
{
|
53 |
-
return $this->getMockBuilder('PhpConsole\Dispatcher\Debug')
|
54 |
-
->disableOriginalConstructor()
|
55 |
-
->setMethods(array('dispatchDebug'))
|
56 |
-
->setConstructorArgs(array($connector, $connector->getDumper()))
|
57 |
-
->getMock();
|
58 |
-
}
|
59 |
-
|
60 |
-
protected function initErrorDispatcherMock(Connector $connector)
|
61 |
-
{
|
62 |
-
return $this->getMockBuilder('PhpConsole\Dispatcher\Errors')
|
63 |
-
->disableOriginalConstructor()
|
64 |
-
->setMethods(array('dispatchError', 'dispatchException'))
|
65 |
-
->setConstructorArgs(array($connector, $connector->getDumper()))
|
66 |
-
->getMock();
|
67 |
-
}
|
68 |
-
|
69 |
-
protected function initConnectorMock()
|
70 |
-
{
|
71 |
-
$connector = $this->getMockBuilder('PhpConsole\Connector')
|
72 |
-
->disableOriginalConstructor()
|
73 |
-
->setMethods(array(
|
74 |
-
'sendMessage',
|
75 |
-
'onShutDown',
|
76 |
-
'isActiveClient',
|
77 |
-
'setSourcesBasePath',
|
78 |
-
'setServerEncoding',
|
79 |
-
'setPassword',
|
80 |
-
'enableSslOnlyMode',
|
81 |
-
'setAllowedIpMasks',
|
82 |
-
'setHeadersLimit',
|
83 |
-
'startEvalRequestsListener',
|
84 |
-
))
|
85 |
-
->getMock();
|
86 |
-
|
87 |
-
$connector->expects($this->any())
|
88 |
-
->method('isActiveClient')
|
89 |
-
->will($this->returnValue(true));
|
90 |
-
|
91 |
-
return $connector;
|
92 |
-
}
|
93 |
-
|
94 |
-
protected function getHandlerDefaultOption($name)
|
95 |
-
{
|
96 |
-
$handler = new PHPConsoleHandler(array(), $this->connector);
|
97 |
-
$options = $handler->getOptions();
|
98 |
-
|
99 |
-
return $options[$name];
|
100 |
-
}
|
101 |
-
|
102 |
-
protected function initLogger($handlerOptions = array(), $level = Logger::DEBUG)
|
103 |
-
{
|
104 |
-
return new Logger('test', array(
|
105 |
-
new PHPConsoleHandler($handlerOptions, $this->connector, $level),
|
106 |
-
));
|
107 |
-
}
|
108 |
-
|
109 |
-
public function testInitWithDefaultConnector()
|
110 |
-
{
|
111 |
-
$handler = new PHPConsoleHandler();
|
112 |
-
$this->assertEquals(spl_object_hash(Connector::getInstance()), spl_object_hash($handler->getConnector()));
|
113 |
-
}
|
114 |
-
|
115 |
-
public function testInitWithCustomConnector()
|
116 |
-
{
|
117 |
-
$handler = new PHPConsoleHandler(array(), $this->connector);
|
118 |
-
$this->assertEquals(spl_object_hash($this->connector), spl_object_hash($handler->getConnector()));
|
119 |
-
}
|
120 |
-
|
121 |
-
public function testDebug()
|
122 |
-
{
|
123 |
-
$this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with($this->equalTo('test'));
|
124 |
-
$this->initLogger()->addDebug('test');
|
125 |
-
}
|
126 |
-
|
127 |
-
public function testDebugContextInMessage()
|
128 |
-
{
|
129 |
-
$message = 'test';
|
130 |
-
$tag = 'tag';
|
131 |
-
$context = array($tag, 'custom' => mt_rand());
|
132 |
-
$expectedMessage = $message . ' ' . json_encode(array_slice($context, 1));
|
133 |
-
$this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with(
|
134 |
-
$this->equalTo($expectedMessage),
|
135 |
-
$this->equalTo($tag)
|
136 |
-
);
|
137 |
-
$this->initLogger()->addDebug($message, $context);
|
138 |
-
}
|
139 |
-
|
140 |
-
public function testDebugTags($tagsContextKeys = null)
|
141 |
-
{
|
142 |
-
$expectedTags = mt_rand();
|
143 |
-
$logger = $this->initLogger($tagsContextKeys ? array('debugTagsKeysInContext' => $tagsContextKeys) : array());
|
144 |
-
if (!$tagsContextKeys) {
|
145 |
-
$tagsContextKeys = $this->getHandlerDefaultOption('debugTagsKeysInContext');
|
146 |
-
}
|
147 |
-
foreach ($tagsContextKeys as $key) {
|
148 |
-
$debugDispatcher = $this->initDebugDispatcherMock($this->connector);
|
149 |
-
$debugDispatcher->expects($this->once())->method('dispatchDebug')->with(
|
150 |
-
$this->anything(),
|
151 |
-
$this->equalTo($expectedTags)
|
152 |
-
);
|
153 |
-
$this->connector->setDebugDispatcher($debugDispatcher);
|
154 |
-
$logger->addDebug('test', array($key => $expectedTags));
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
public function testError($classesPartialsTraceIgnore = null)
|
159 |
-
{
|
160 |
-
$code = E_USER_NOTICE;
|
161 |
-
$message = 'message';
|
162 |
-
$file = __FILE__;
|
163 |
-
$line = __LINE__;
|
164 |
-
$this->errorDispatcher->expects($this->once())->method('dispatchError')->with(
|
165 |
-
$this->equalTo($code),
|
166 |
-
$this->equalTo($message),
|
167 |
-
$this->equalTo($file),
|
168 |
-
$this->equalTo($line),
|
169 |
-
$classesPartialsTraceIgnore ?: $this->equalTo($this->getHandlerDefaultOption('classesPartialsTraceIgnore'))
|
170 |
-
);
|
171 |
-
$errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? array('classesPartialsTraceIgnore' => $classesPartialsTraceIgnore) : array()), false);
|
172 |
-
$errorHandler->registerErrorHandler(array(), false, E_USER_WARNING);
|
173 |
-
$errorHandler->handleError($code, $message, $file, $line);
|
174 |
-
}
|
175 |
-
|
176 |
-
public function testException()
|
177 |
-
{
|
178 |
-
$e = new Exception();
|
179 |
-
$this->errorDispatcher->expects($this->once())->method('dispatchException')->with(
|
180 |
-
$this->equalTo($e)
|
181 |
-
);
|
182 |
-
$handler = $this->initLogger();
|
183 |
-
$handler->log(
|
184 |
-
\Psr\Log\LogLevel::ERROR,
|
185 |
-
sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
|
186 |
-
array('exception' => $e)
|
187 |
-
);
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* @expectedException Exception
|
192 |
-
*/
|
193 |
-
public function testWrongOptionsThrowsException()
|
194 |
-
{
|
195 |
-
new PHPConsoleHandler(array('xxx' => 1));
|
196 |
-
}
|
197 |
-
|
198 |
-
public function testOptionEnabled()
|
199 |
-
{
|
200 |
-
$this->debugDispatcher->expects($this->never())->method('dispatchDebug');
|
201 |
-
$this->initLogger(array('enabled' => false))->addDebug('test');
|
202 |
-
}
|
203 |
-
|
204 |
-
public function testOptionClassesPartialsTraceIgnore()
|
205 |
-
{
|
206 |
-
$this->testError(array('Class', 'Namespace\\'));
|
207 |
-
}
|
208 |
-
|
209 |
-
public function testOptionDebugTagsKeysInContext()
|
210 |
-
{
|
211 |
-
$this->testDebugTags(array('key1', 'key2'));
|
212 |
-
}
|
213 |
-
|
214 |
-
public function testOptionUseOwnErrorsAndExceptionsHandler()
|
215 |
-
{
|
216 |
-
$this->initLogger(array('useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true));
|
217 |
-
$this->assertEquals(array(Handler::getInstance(), 'handleError'), set_error_handler(function () {
|
218 |
-
}));
|
219 |
-
$this->assertEquals(array(Handler::getInstance(), 'handleException'), set_exception_handler(function () {
|
220 |
-
}));
|
221 |
-
}
|
222 |
-
|
223 |
-
public static function provideConnectorMethodsOptionsSets()
|
224 |
-
{
|
225 |
-
return array(
|
226 |
-
array('sourcesBasePath', 'setSourcesBasePath', __DIR__),
|
227 |
-
array('serverEncoding', 'setServerEncoding', 'cp1251'),
|
228 |
-
array('password', 'setPassword', '******'),
|
229 |
-
array('enableSslOnlyMode', 'enableSslOnlyMode', true, false),
|
230 |
-
array('ipMasks', 'setAllowedIpMasks', array('127.0.0.*')),
|
231 |
-
array('headersLimit', 'setHeadersLimit', 2500),
|
232 |
-
array('enableEvalListener', 'startEvalRequestsListener', true, false),
|
233 |
-
);
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* @dataProvider provideConnectorMethodsOptionsSets
|
238 |
-
*/
|
239 |
-
public function testOptionCallsConnectorMethod($option, $method, $value, $isArgument = true)
|
240 |
-
{
|
241 |
-
$expectCall = $this->connector->expects($this->once())->method($method);
|
242 |
-
if ($isArgument) {
|
243 |
-
$expectCall->with($value);
|
244 |
-
}
|
245 |
-
new PHPConsoleHandler(array($option => $value), $this->connector);
|
246 |
-
}
|
247 |
-
|
248 |
-
public function testOptionDetectDumpTraceAndSource()
|
249 |
-
{
|
250 |
-
new PHPConsoleHandler(array('detectDumpTraceAndSource' => true), $this->connector);
|
251 |
-
$this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource);
|
252 |
-
}
|
253 |
-
|
254 |
-
public static function provideDumperOptionsValues()
|
255 |
-
{
|
256 |
-
return array(
|
257 |
-
array('dumperLevelLimit', 'levelLimit', 1001),
|
258 |
-
array('dumperItemsCountLimit', 'itemsCountLimit', 1002),
|
259 |
-
array('dumperItemSizeLimit', 'itemSizeLimit', 1003),
|
260 |
-
array('dumperDumpSizeLimit', 'dumpSizeLimit', 1004),
|
261 |
-
array('dumperDetectCallbacks', 'detectCallbacks', true),
|
262 |
-
);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* @dataProvider provideDumperOptionsValues
|
267 |
-
*/
|
268 |
-
public function testDumperOptions($option, $dumperProperty, $value)
|
269 |
-
{
|
270 |
-
new PHPConsoleHandler(array($option => $value), $this->connector);
|
271 |
-
$this->assertEquals($value, $this->connector->getDumper()->$dumperProperty);
|
272 |
-
}
|
273 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\PsrHandler::handle
|
19 |
-
*/
|
20 |
-
class PsrHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
public function logLevelProvider()
|
23 |
-
{
|
24 |
-
$levels = array();
|
25 |
-
$monologLogger = new Logger('');
|
26 |
-
|
27 |
-
foreach ($monologLogger->getLevels() as $levelName => $level) {
|
28 |
-
$levels[] = array($levelName, $level);
|
29 |
-
}
|
30 |
-
|
31 |
-
return $levels;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @dataProvider logLevelProvider
|
36 |
-
*/
|
37 |
-
public function testHandlesAllLevels($levelName, $level)
|
38 |
-
{
|
39 |
-
$message = 'Hello, world! ' . $level;
|
40 |
-
$context = array('foo' => 'bar', 'level' => $level);
|
41 |
-
|
42 |
-
$psrLogger = $this->getMock('Psr\Log\NullLogger');
|
43 |
-
$psrLogger->expects($this->once())
|
44 |
-
->method('log')
|
45 |
-
->with(strtolower($levelName), $message, $context);
|
46 |
-
|
47 |
-
$handler = new PsrHandler($psrLogger);
|
48 |
-
$handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context));
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Almost all examples (expected header, titles, messages) taken from
|
19 |
-
* https://www.pushover.net/api
|
20 |
-
* @author Sebastian Göttschkes <sebastian.goettschkes@googlemail.com>
|
21 |
-
* @see https://www.pushover.net/api
|
22 |
-
*/
|
23 |
-
class PushoverHandlerTest extends TestCase
|
24 |
-
{
|
25 |
-
private $res;
|
26 |
-
private $handler;
|
27 |
-
|
28 |
-
public function testWriteHeader()
|
29 |
-
{
|
30 |
-
$this->createHandler();
|
31 |
-
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
32 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
33 |
-
fseek($this->res, 0);
|
34 |
-
$content = fread($this->res, 1024);
|
35 |
-
|
36 |
-
$this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
37 |
-
|
38 |
-
return $content;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @depends testWriteHeader
|
43 |
-
*/
|
44 |
-
public function testWriteContent($content)
|
45 |
-
{
|
46 |
-
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content);
|
47 |
-
}
|
48 |
-
|
49 |
-
public function testWriteWithComplexTitle()
|
50 |
-
{
|
51 |
-
$this->createHandler('myToken', 'myUser', 'Backup finished - SQL1');
|
52 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
53 |
-
fseek($this->res, 0);
|
54 |
-
$content = fread($this->res, 1024);
|
55 |
-
|
56 |
-
$this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content);
|
57 |
-
}
|
58 |
-
|
59 |
-
public function testWriteWithComplexMessage()
|
60 |
-
{
|
61 |
-
$this->createHandler();
|
62 |
-
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
63 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
|
64 |
-
fseek($this->res, 0);
|
65 |
-
$content = fread($this->res, 1024);
|
66 |
-
|
67 |
-
$this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
|
68 |
-
}
|
69 |
-
|
70 |
-
public function testWriteWithTooLongMessage()
|
71 |
-
{
|
72 |
-
$message = str_pad('test', 520, 'a');
|
73 |
-
$this->createHandler();
|
74 |
-
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
75 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, $message));
|
76 |
-
fseek($this->res, 0);
|
77 |
-
$content = fread($this->res, 1024);
|
78 |
-
|
79 |
-
$expectedMessage = substr($message, 0, 505);
|
80 |
-
|
81 |
-
$this->assertRegexp('/message=' . $expectedMessage . '&title/', $content);
|
82 |
-
}
|
83 |
-
|
84 |
-
public function testWriteWithHighPriority()
|
85 |
-
{
|
86 |
-
$this->createHandler();
|
87 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
88 |
-
fseek($this->res, 0);
|
89 |
-
$content = fread($this->res, 1024);
|
90 |
-
|
91 |
-
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content);
|
92 |
-
}
|
93 |
-
|
94 |
-
public function testWriteWithEmergencyPriority()
|
95 |
-
{
|
96 |
-
$this->createHandler();
|
97 |
-
$this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
|
98 |
-
fseek($this->res, 0);
|
99 |
-
$content = fread($this->res, 1024);
|
100 |
-
|
101 |
-
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
|
102 |
-
}
|
103 |
-
|
104 |
-
public function testWriteToMultipleUsers()
|
105 |
-
{
|
106 |
-
$this->createHandler('myToken', array('userA', 'userB'));
|
107 |
-
$this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
|
108 |
-
fseek($this->res, 0);
|
109 |
-
$content = fread($this->res, 1024);
|
110 |
-
|
111 |
-
$this->assertRegexp('/token=myToken&user=userA&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200POST/', $content);
|
112 |
-
$this->assertRegexp('/token=myToken&user=userB&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
|
113 |
-
}
|
114 |
-
|
115 |
-
private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
|
116 |
-
{
|
117 |
-
$constructorArgs = array($token, $user, $title);
|
118 |
-
$this->res = fopen('php://memory', 'a');
|
119 |
-
$this->handler = $this->getMock(
|
120 |
-
'\Monolog\Handler\PushoverHandler',
|
121 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
122 |
-
$constructorArgs
|
123 |
-
);
|
124 |
-
|
125 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
126 |
-
$reflectionProperty->setAccessible(true);
|
127 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
128 |
-
|
129 |
-
$this->handler->expects($this->any())
|
130 |
-
->method('fsockopen')
|
131 |
-
->will($this->returnValue($this->res));
|
132 |
-
$this->handler->expects($this->any())
|
133 |
-
->method('streamSetTimeout')
|
134 |
-
->will($this->returnValue(true));
|
135 |
-
$this->handler->expects($this->any())
|
136 |
-
->method('closeSocket')
|
137 |
-
->will($this->returnValue(true));
|
138 |
-
|
139 |
-
$this->handler->setFormatter($this->getIdentityFormatter());
|
140 |
-
}
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
DELETED
@@ -1,255 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
|
18 |
-
class RavenHandlerTest extends TestCase
|
19 |
-
{
|
20 |
-
public function setUp()
|
21 |
-
{
|
22 |
-
if (!class_exists('Raven_Client')) {
|
23 |
-
$this->markTestSkipped('raven/raven not installed');
|
24 |
-
}
|
25 |
-
|
26 |
-
require_once __DIR__ . '/MockRavenClient.php';
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @covers Monolog\Handler\RavenHandler::__construct
|
31 |
-
*/
|
32 |
-
public function testConstruct()
|
33 |
-
{
|
34 |
-
$handler = new RavenHandler($this->getRavenClient());
|
35 |
-
$this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler);
|
36 |
-
}
|
37 |
-
|
38 |
-
protected function getHandler($ravenClient)
|
39 |
-
{
|
40 |
-
$handler = new RavenHandler($ravenClient);
|
41 |
-
|
42 |
-
return $handler;
|
43 |
-
}
|
44 |
-
|
45 |
-
protected function getRavenClient()
|
46 |
-
{
|
47 |
-
$dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
|
48 |
-
|
49 |
-
return new MockRavenClient($dsn);
|
50 |
-
}
|
51 |
-
|
52 |
-
public function testDebug()
|
53 |
-
{
|
54 |
-
$ravenClient = $this->getRavenClient();
|
55 |
-
$handler = $this->getHandler($ravenClient);
|
56 |
-
|
57 |
-
$record = $this->getRecord(Logger::DEBUG, 'A test debug message');
|
58 |
-
$handler->handle($record);
|
59 |
-
|
60 |
-
$this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
|
61 |
-
$this->assertContains($record['message'], $ravenClient->lastData['message']);
|
62 |
-
}
|
63 |
-
|
64 |
-
public function testWarning()
|
65 |
-
{
|
66 |
-
$ravenClient = $this->getRavenClient();
|
67 |
-
$handler = $this->getHandler($ravenClient);
|
68 |
-
|
69 |
-
$record = $this->getRecord(Logger::WARNING, 'A test warning message');
|
70 |
-
$handler->handle($record);
|
71 |
-
|
72 |
-
$this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
|
73 |
-
$this->assertContains($record['message'], $ravenClient->lastData['message']);
|
74 |
-
}
|
75 |
-
|
76 |
-
public function testTag()
|
77 |
-
{
|
78 |
-
$ravenClient = $this->getRavenClient();
|
79 |
-
$handler = $this->getHandler($ravenClient);
|
80 |
-
|
81 |
-
$tags = array(1, 2, 'foo');
|
82 |
-
$record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags));
|
83 |
-
$handler->handle($record);
|
84 |
-
|
85 |
-
$this->assertEquals($tags, $ravenClient->lastData['tags']);
|
86 |
-
}
|
87 |
-
|
88 |
-
public function testExtraParameters()
|
89 |
-
{
|
90 |
-
$ravenClient = $this->getRavenClient();
|
91 |
-
$handler = $this->getHandler($ravenClient);
|
92 |
-
|
93 |
-
$checksum = '098f6bcd4621d373cade4e832627b4f6';
|
94 |
-
$release = '05a671c66aefea124cc08b76ea6d30bb';
|
95 |
-
$eventId = '31423';
|
96 |
-
$record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum, 'release' => $release, 'event_id' => $eventId));
|
97 |
-
$handler->handle($record);
|
98 |
-
|
99 |
-
$this->assertEquals($checksum, $ravenClient->lastData['checksum']);
|
100 |
-
$this->assertEquals($release, $ravenClient->lastData['release']);
|
101 |
-
$this->assertEquals($eventId, $ravenClient->lastData['event_id']);
|
102 |
-
}
|
103 |
-
|
104 |
-
public function testFingerprint()
|
105 |
-
{
|
106 |
-
$ravenClient = $this->getRavenClient();
|
107 |
-
$handler = $this->getHandler($ravenClient);
|
108 |
-
|
109 |
-
$fingerprint = array('{{ default }}', 'other value');
|
110 |
-
$record = $this->getRecord(Logger::INFO, 'test', array('fingerprint' => $fingerprint));
|
111 |
-
$handler->handle($record);
|
112 |
-
|
113 |
-
$this->assertEquals($fingerprint, $ravenClient->lastData['fingerprint']);
|
114 |
-
}
|
115 |
-
|
116 |
-
public function testUserContext()
|
117 |
-
{
|
118 |
-
$ravenClient = $this->getRavenClient();
|
119 |
-
$handler = $this->getHandler($ravenClient);
|
120 |
-
|
121 |
-
$recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
|
122 |
-
// set user context 'externally'
|
123 |
-
|
124 |
-
$user = array(
|
125 |
-
'id' => '123',
|
126 |
-
'email' => 'test@test.com',
|
127 |
-
);
|
128 |
-
|
129 |
-
$recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
|
130 |
-
|
131 |
-
$ravenClient->user_context(array('id' => 'test_user_id'));
|
132 |
-
// handle context
|
133 |
-
$handler->handle($recordWithContext);
|
134 |
-
$this->assertEquals($user, $ravenClient->lastData['user']);
|
135 |
-
|
136 |
-
// check to see if its reset
|
137 |
-
$handler->handle($recordWithNoContext);
|
138 |
-
$this->assertInternalType('array', $ravenClient->context->user);
|
139 |
-
$this->assertSame('test_user_id', $ravenClient->context->user['id']);
|
140 |
-
|
141 |
-
// handle with null context
|
142 |
-
$ravenClient->user_context(null);
|
143 |
-
$handler->handle($recordWithContext);
|
144 |
-
$this->assertEquals($user, $ravenClient->lastData['user']);
|
145 |
-
|
146 |
-
// check to see if its reset
|
147 |
-
$handler->handle($recordWithNoContext);
|
148 |
-
$this->assertNull($ravenClient->context->user);
|
149 |
-
}
|
150 |
-
|
151 |
-
public function testException()
|
152 |
-
{
|
153 |
-
$ravenClient = $this->getRavenClient();
|
154 |
-
$handler = $this->getHandler($ravenClient);
|
155 |
-
|
156 |
-
try {
|
157 |
-
$this->methodThatThrowsAnException();
|
158 |
-
} catch (\Exception $e) {
|
159 |
-
$record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
|
160 |
-
$handler->handle($record);
|
161 |
-
}
|
162 |
-
|
163 |
-
$this->assertEquals($record['message'], $ravenClient->lastData['message']);
|
164 |
-
}
|
165 |
-
|
166 |
-
public function testHandleBatch()
|
167 |
-
{
|
168 |
-
$records = $this->getMultipleRecords();
|
169 |
-
$records[] = $this->getRecord(Logger::WARNING, 'warning');
|
170 |
-
$records[] = $this->getRecord(Logger::WARNING, 'warning');
|
171 |
-
|
172 |
-
$logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
173 |
-
$logFormatter->expects($this->once())->method('formatBatch');
|
174 |
-
|
175 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
176 |
-
$formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
|
177 |
-
return $record['level'] == 400;
|
178 |
-
}));
|
179 |
-
|
180 |
-
$handler = $this->getHandler($this->getRavenClient());
|
181 |
-
$handler->setBatchFormatter($logFormatter);
|
182 |
-
$handler->setFormatter($formatter);
|
183 |
-
$handler->handleBatch($records);
|
184 |
-
}
|
185 |
-
|
186 |
-
public function testHandleBatchDoNothingIfRecordsAreBelowLevel()
|
187 |
-
{
|
188 |
-
$records = array(
|
189 |
-
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
190 |
-
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
191 |
-
$this->getRecord(Logger::INFO, 'information'),
|
192 |
-
);
|
193 |
-
|
194 |
-
$handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
|
195 |
-
$handler->expects($this->never())->method('handle');
|
196 |
-
$handler->setLevel(Logger::ERROR);
|
197 |
-
$handler->handleBatch($records);
|
198 |
-
}
|
199 |
-
|
200 |
-
public function testHandleBatchPicksProperMessage()
|
201 |
-
{
|
202 |
-
$records = array(
|
203 |
-
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
204 |
-
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
205 |
-
$this->getRecord(Logger::INFO, 'information 1'),
|
206 |
-
$this->getRecord(Logger::ERROR, 'error 1'),
|
207 |
-
$this->getRecord(Logger::WARNING, 'warning'),
|
208 |
-
$this->getRecord(Logger::ERROR, 'error 2'),
|
209 |
-
$this->getRecord(Logger::INFO, 'information 2'),
|
210 |
-
);
|
211 |
-
|
212 |
-
$logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
213 |
-
$logFormatter->expects($this->once())->method('formatBatch');
|
214 |
-
|
215 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
216 |
-
$formatter->expects($this->once())->method('format')->with($this->callback(function ($record) use ($records) {
|
217 |
-
return $record['message'] == 'error 1';
|
218 |
-
}));
|
219 |
-
|
220 |
-
$handler = $this->getHandler($this->getRavenClient());
|
221 |
-
$handler->setBatchFormatter($logFormatter);
|
222 |
-
$handler->setFormatter($formatter);
|
223 |
-
$handler->handleBatch($records);
|
224 |
-
}
|
225 |
-
|
226 |
-
public function testGetSetBatchFormatter()
|
227 |
-
{
|
228 |
-
$ravenClient = $this->getRavenClient();
|
229 |
-
$handler = $this->getHandler($ravenClient);
|
230 |
-
|
231 |
-
$handler->setBatchFormatter($formatter = new LineFormatter());
|
232 |
-
$this->assertSame($formatter, $handler->getBatchFormatter());
|
233 |
-
}
|
234 |
-
|
235 |
-
public function testRelease()
|
236 |
-
{
|
237 |
-
$ravenClient = $this->getRavenClient();
|
238 |
-
$handler = $this->getHandler($ravenClient);
|
239 |
-
$release = 'v42.42.42';
|
240 |
-
$handler->setRelease($release);
|
241 |
-
$record = $this->getRecord(Logger::INFO, 'test');
|
242 |
-
$handler->handle($record);
|
243 |
-
$this->assertEquals($release, $ravenClient->lastData['release']);
|
244 |
-
|
245 |
-
$localRelease = 'v41.41.41';
|
246 |
-
$record = $this->getRecord(Logger::INFO, 'test', array('release' => $localRelease));
|
247 |
-
$handler->handle($record);
|
248 |
-
$this->assertEquals($localRelease, $ravenClient->lastData['release']);
|
249 |
-
}
|
250 |
-
|
251 |
-
private function methodThatThrowsAnException()
|
252 |
-
{
|
253 |
-
throw new \Exception('This is an exception');
|
254 |
-
}
|
255 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
|
18 |
-
class RedisHandlerTest extends TestCase
|
19 |
-
{
|
20 |
-
/**
|
21 |
-
* @expectedException InvalidArgumentException
|
22 |
-
*/
|
23 |
-
public function testConstructorShouldThrowExceptionForInvalidRedis()
|
24 |
-
{
|
25 |
-
new RedisHandler(new \stdClass(), 'key');
|
26 |
-
}
|
27 |
-
|
28 |
-
public function testConstructorShouldWorkWithPredis()
|
29 |
-
{
|
30 |
-
$redis = $this->getMock('Predis\Client');
|
31 |
-
$this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
|
32 |
-
}
|
33 |
-
|
34 |
-
public function testConstructorShouldWorkWithRedis()
|
35 |
-
{
|
36 |
-
$redis = $this->getMock('Redis');
|
37 |
-
$this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
|
38 |
-
}
|
39 |
-
|
40 |
-
public function testPredisHandle()
|
41 |
-
{
|
42 |
-
$redis = $this->getMock('Predis\Client', array('rpush'));
|
43 |
-
|
44 |
-
// Predis\Client uses rpush
|
45 |
-
$redis->expects($this->once())
|
46 |
-
->method('rpush')
|
47 |
-
->with('key', 'test');
|
48 |
-
|
49 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
50 |
-
|
51 |
-
$handler = new RedisHandler($redis, 'key');
|
52 |
-
$handler->setFormatter(new LineFormatter("%message%"));
|
53 |
-
$handler->handle($record);
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testRedisHandle()
|
57 |
-
{
|
58 |
-
$redis = $this->getMock('Redis', array('rpush'));
|
59 |
-
|
60 |
-
// Redis uses rPush
|
61 |
-
$redis->expects($this->once())
|
62 |
-
->method('rPush')
|
63 |
-
->with('key', 'test');
|
64 |
-
|
65 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
66 |
-
|
67 |
-
$handler = new RedisHandler($redis, 'key');
|
68 |
-
$handler->setFormatter(new LineFormatter("%message%"));
|
69 |
-
$handler->handle($record);
|
70 |
-
}
|
71 |
-
|
72 |
-
public function testRedisHandleCapped()
|
73 |
-
{
|
74 |
-
$redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'exec'));
|
75 |
-
|
76 |
-
// Redis uses multi
|
77 |
-
$redis->expects($this->once())
|
78 |
-
->method('multi')
|
79 |
-
->will($this->returnSelf());
|
80 |
-
|
81 |
-
$redis->expects($this->once())
|
82 |
-
->method('rpush')
|
83 |
-
->will($this->returnSelf());
|
84 |
-
|
85 |
-
$redis->expects($this->once())
|
86 |
-
->method('ltrim')
|
87 |
-
->will($this->returnSelf());
|
88 |
-
|
89 |
-
$redis->expects($this->once())
|
90 |
-
->method('exec')
|
91 |
-
->will($this->returnSelf());
|
92 |
-
|
93 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
94 |
-
|
95 |
-
$handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
|
96 |
-
$handler->setFormatter(new LineFormatter("%message%"));
|
97 |
-
$handler->handle($record);
|
98 |
-
}
|
99 |
-
|
100 |
-
public function testPredisHandleCapped()
|
101 |
-
{
|
102 |
-
$redis = $this->getMock('Predis\Client', array('transaction'));
|
103 |
-
|
104 |
-
$redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim'));
|
105 |
-
|
106 |
-
$redisTransaction->expects($this->once())
|
107 |
-
->method('rpush')
|
108 |
-
->will($this->returnSelf());
|
109 |
-
|
110 |
-
$redisTransaction->expects($this->once())
|
111 |
-
->method('ltrim')
|
112 |
-
->will($this->returnSelf());
|
113 |
-
|
114 |
-
// Redis uses multi
|
115 |
-
$redis->expects($this->once())
|
116 |
-
->method('transaction')
|
117 |
-
->will($this->returnCallback(function ($cb) use ($redisTransaction) {
|
118 |
-
$cb($redisTransaction);
|
119 |
-
}));
|
120 |
-
|
121 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
122 |
-
|
123 |
-
$handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
|
124 |
-
$handler->setFormatter(new LineFormatter("%message%"));
|
125 |
-
$handler->handle($record);
|
126 |
-
}
|
127 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/RollbarHandlerTest.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Exception;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @author Erik Johansson <erik.pm.johansson@gmail.com>
|
21 |
-
* @see https://rollbar.com/docs/notifier/rollbar-php/
|
22 |
-
*
|
23 |
-
* @coversDefaultClass Monolog\Handler\RollbarHandler
|
24 |
-
*/
|
25 |
-
class RollbarHandlerTest extends TestCase
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* @var MockObject
|
29 |
-
*/
|
30 |
-
private $rollbarNotifier;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
public $reportedExceptionArguments = null;
|
36 |
-
|
37 |
-
protected function setUp()
|
38 |
-
{
|
39 |
-
parent::setUp();
|
40 |
-
|
41 |
-
$this->setupRollbarNotifierMock();
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* When reporting exceptions to Rollbar the
|
46 |
-
* level has to be set in the payload data
|
47 |
-
*/
|
48 |
-
public function testExceptionLogLevel()
|
49 |
-
{
|
50 |
-
$handler = $this->createHandler();
|
51 |
-
|
52 |
-
$handler->handle($this->createExceptionRecord(Logger::DEBUG));
|
53 |
-
|
54 |
-
$this->assertEquals('debug', $this->reportedExceptionArguments['payload']['level']);
|
55 |
-
}
|
56 |
-
|
57 |
-
private function setupRollbarNotifierMock()
|
58 |
-
{
|
59 |
-
$this->rollbarNotifier = $this->getMockBuilder('RollbarNotifier')
|
60 |
-
->setMethods(array('report_message', 'report_exception', 'flush'))
|
61 |
-
->getMock();
|
62 |
-
|
63 |
-
$that = $this;
|
64 |
-
|
65 |
-
$this->rollbarNotifier
|
66 |
-
->expects($this->any())
|
67 |
-
->method('report_exception')
|
68 |
-
->willReturnCallback(function ($exception, $context, $payload) use ($that) {
|
69 |
-
$that->reportedExceptionArguments = compact('exception', 'context', 'payload');
|
70 |
-
});
|
71 |
-
}
|
72 |
-
|
73 |
-
private function createHandler()
|
74 |
-
{
|
75 |
-
return new RollbarHandler($this->rollbarNotifier, Logger::DEBUG);
|
76 |
-
}
|
77 |
-
|
78 |
-
private function createExceptionRecord($level = Logger::DEBUG, $message = 'test', $exception = null)
|
79 |
-
{
|
80 |
-
return $this->getRecord($level, $message, array(
|
81 |
-
'exception' => $exception ?: new Exception()
|
82 |
-
));
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
DELETED
@@ -1,245 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use PHPUnit_Framework_Error_Deprecated;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\RotatingFileHandler
|
19 |
-
*/
|
20 |
-
class RotatingFileHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* This var should be private but then the anonymous function
|
24 |
-
* in the `setUp` method won't be able to set it. `$this` cant't
|
25 |
-
* be used in the anonymous function in `setUp` because PHP 5.3
|
26 |
-
* does not support it.
|
27 |
-
*/
|
28 |
-
public $lastError;
|
29 |
-
|
30 |
-
public function setUp()
|
31 |
-
{
|
32 |
-
$dir = __DIR__.'/Fixtures';
|
33 |
-
chmod($dir, 0777);
|
34 |
-
if (!is_writable($dir)) {
|
35 |
-
$this->markTestSkipped($dir.' must be writable to test the RotatingFileHandler.');
|
36 |
-
}
|
37 |
-
$this->lastError = null;
|
38 |
-
$self = $this;
|
39 |
-
// workaround with &$self used for PHP 5.3
|
40 |
-
set_error_handler(function($code, $message) use (&$self) {
|
41 |
-
$self->lastError = array(
|
42 |
-
'code' => $code,
|
43 |
-
'message' => $message,
|
44 |
-
);
|
45 |
-
});
|
46 |
-
}
|
47 |
-
|
48 |
-
private function assertErrorWasTriggered($code, $message)
|
49 |
-
{
|
50 |
-
if (empty($this->lastError)) {
|
51 |
-
$this->fail(
|
52 |
-
sprintf(
|
53 |
-
'Failed asserting that error with code `%d` and message `%s` was triggered',
|
54 |
-
$code,
|
55 |
-
$message
|
56 |
-
)
|
57 |
-
);
|
58 |
-
}
|
59 |
-
$this->assertEquals($code, $this->lastError['code'], sprintf('Expected an error with code %d to be triggered, got `%s` instead', $code, $this->lastError['code']));
|
60 |
-
$this->assertEquals($message, $this->lastError['message'], sprintf('Expected an error with message `%d` to be triggered, got `%s` instead', $message, $this->lastError['message']));
|
61 |
-
}
|
62 |
-
|
63 |
-
public function testRotationCreatesNewFile()
|
64 |
-
{
|
65 |
-
touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
|
66 |
-
|
67 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
|
68 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
69 |
-
$handler->handle($this->getRecord());
|
70 |
-
|
71 |
-
$log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
|
72 |
-
$this->assertTrue(file_exists($log));
|
73 |
-
$this->assertEquals('test', file_get_contents($log));
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @dataProvider rotationTests
|
78 |
-
*/
|
79 |
-
public function testRotation($createFile, $dateFormat, $timeCallback)
|
80 |
-
{
|
81 |
-
touch($old1 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-1)).'.rot');
|
82 |
-
touch($old2 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-2)).'.rot');
|
83 |
-
touch($old3 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-3)).'.rot');
|
84 |
-
touch($old4 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-4)).'.rot');
|
85 |
-
|
86 |
-
$log = __DIR__.'/Fixtures/foo-'.date($dateFormat).'.rot';
|
87 |
-
|
88 |
-
if ($createFile) {
|
89 |
-
touch($log);
|
90 |
-
}
|
91 |
-
|
92 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
93 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
94 |
-
$handler->setFilenameFormat('{filename}-{date}', $dateFormat);
|
95 |
-
$handler->handle($this->getRecord());
|
96 |
-
|
97 |
-
$handler->close();
|
98 |
-
|
99 |
-
$this->assertTrue(file_exists($log));
|
100 |
-
$this->assertTrue(file_exists($old1));
|
101 |
-
$this->assertEquals($createFile, file_exists($old2));
|
102 |
-
$this->assertEquals($createFile, file_exists($old3));
|
103 |
-
$this->assertEquals($createFile, file_exists($old4));
|
104 |
-
$this->assertEquals('test', file_get_contents($log));
|
105 |
-
}
|
106 |
-
|
107 |
-
public function rotationTests()
|
108 |
-
{
|
109 |
-
$now = time();
|
110 |
-
$dayCallback = function($ago) use ($now) {
|
111 |
-
return $now + 86400 * $ago;
|
112 |
-
};
|
113 |
-
$monthCallback = function($ago) {
|
114 |
-
return gmmktime(0, 0, 0, date('n') + $ago, 1, date('Y'));
|
115 |
-
};
|
116 |
-
$yearCallback = function($ago) {
|
117 |
-
return gmmktime(0, 0, 0, 1, 1, date('Y') + $ago);
|
118 |
-
};
|
119 |
-
|
120 |
-
return array(
|
121 |
-
'Rotation is triggered when the file of the current day is not present'
|
122 |
-
=> array(true, RotatingFileHandler::FILE_PER_DAY, $dayCallback),
|
123 |
-
'Rotation is not triggered when the file of the current day is already present'
|
124 |
-
=> array(false, RotatingFileHandler::FILE_PER_DAY, $dayCallback),
|
125 |
-
|
126 |
-
'Rotation is triggered when the file of the current month is not present'
|
127 |
-
=> array(true, RotatingFileHandler::FILE_PER_MONTH, $monthCallback),
|
128 |
-
'Rotation is not triggered when the file of the current month is already present'
|
129 |
-
=> array(false, RotatingFileHandler::FILE_PER_MONTH, $monthCallback),
|
130 |
-
|
131 |
-
'Rotation is triggered when the file of the current year is not present'
|
132 |
-
=> array(true, RotatingFileHandler::FILE_PER_YEAR, $yearCallback),
|
133 |
-
'Rotation is not triggered when the file of the current year is already present'
|
134 |
-
=> array(false, RotatingFileHandler::FILE_PER_YEAR, $yearCallback),
|
135 |
-
);
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* @dataProvider dateFormatProvider
|
140 |
-
*/
|
141 |
-
public function testAllowOnlyFixedDefinedDateFormats($dateFormat, $valid)
|
142 |
-
{
|
143 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
144 |
-
$handler->setFilenameFormat('{filename}-{date}', $dateFormat);
|
145 |
-
if (!$valid) {
|
146 |
-
$this->assertErrorWasTriggered(
|
147 |
-
E_USER_DEPRECATED,
|
148 |
-
'Invalid date format - format must be one of RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), '.
|
149 |
-
'RotatingFileHandler::FILE_PER_MONTH ("Y-m") or RotatingFileHandler::FILE_PER_YEAR ("Y"), '.
|
150 |
-
'or you can set one of the date formats using slashes, underscores and/or dots instead of dashes.'
|
151 |
-
);
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
public function dateFormatProvider()
|
156 |
-
{
|
157 |
-
return array(
|
158 |
-
array(RotatingFileHandler::FILE_PER_DAY, true),
|
159 |
-
array(RotatingFileHandler::FILE_PER_MONTH, true),
|
160 |
-
array(RotatingFileHandler::FILE_PER_YEAR, true),
|
161 |
-
array('m-d-Y', false),
|
162 |
-
array('Y-m-d-h-i', false)
|
163 |
-
);
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* @dataProvider filenameFormatProvider
|
168 |
-
*/
|
169 |
-
public function testDisallowFilenameFormatsWithoutDate($filenameFormat, $valid)
|
170 |
-
{
|
171 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
172 |
-
$handler->setFilenameFormat($filenameFormat, RotatingFileHandler::FILE_PER_DAY);
|
173 |
-
if (!$valid) {
|
174 |
-
$this->assertErrorWasTriggered(
|
175 |
-
E_USER_DEPRECATED,
|
176 |
-
'Invalid filename format - format should contain at least `{date}`, because otherwise rotating is impossible.'
|
177 |
-
);
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
public function filenameFormatProvider()
|
182 |
-
{
|
183 |
-
return array(
|
184 |
-
array('{filename}', false),
|
185 |
-
array('{filename}-{date}', true),
|
186 |
-
array('{date}', true),
|
187 |
-
array('foobar-{date}', true),
|
188 |
-
array('foo-{date}-bar', true),
|
189 |
-
array('{date}-foobar', true),
|
190 |
-
array('foobar', false),
|
191 |
-
);
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* @dataProvider rotationWhenSimilarFilesExistTests
|
196 |
-
*/
|
197 |
-
public function testRotationWhenSimilarFileNamesExist($dateFormat)
|
198 |
-
{
|
199 |
-
touch($old1 = __DIR__.'/Fixtures/foo-foo-'.date($dateFormat).'.rot');
|
200 |
-
touch($old2 = __DIR__.'/Fixtures/foo-bar-'.date($dateFormat).'.rot');
|
201 |
-
|
202 |
-
$log = __DIR__.'/Fixtures/foo-'.date($dateFormat).'.rot';
|
203 |
-
|
204 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
|
205 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
206 |
-
$handler->setFilenameFormat('{filename}-{date}', $dateFormat);
|
207 |
-
$handler->handle($this->getRecord());
|
208 |
-
$handler->close();
|
209 |
-
|
210 |
-
$this->assertTrue(file_exists($log));
|
211 |
-
}
|
212 |
-
|
213 |
-
public function rotationWhenSimilarFilesExistTests()
|
214 |
-
{
|
215 |
-
|
216 |
-
return array(
|
217 |
-
'Rotation is triggered when the file of the current day is not present but similar exists'
|
218 |
-
=> array(RotatingFileHandler::FILE_PER_DAY),
|
219 |
-
|
220 |
-
'Rotation is triggered when the file of the current month is not present but similar exists'
|
221 |
-
=> array(RotatingFileHandler::FILE_PER_MONTH),
|
222 |
-
|
223 |
-
'Rotation is triggered when the file of the current year is not present but similar exists'
|
224 |
-
=> array(RotatingFileHandler::FILE_PER_YEAR),
|
225 |
-
);
|
226 |
-
}
|
227 |
-
|
228 |
-
public function testReuseCurrentFile()
|
229 |
-
{
|
230 |
-
$log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
|
231 |
-
file_put_contents($log, "foo");
|
232 |
-
$handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
|
233 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
234 |
-
$handler->handle($this->getRecord());
|
235 |
-
$this->assertEquals('footest', file_get_contents($log));
|
236 |
-
}
|
237 |
-
|
238 |
-
public function tearDown()
|
239 |
-
{
|
240 |
-
foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) {
|
241 |
-
unlink($file);
|
242 |
-
}
|
243 |
-
restore_error_handler();
|
244 |
-
}
|
245 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @covers Monolog\Handler\SamplingHandler::handle
|
18 |
-
*/
|
19 |
-
class SamplingHandlerTest extends TestCase
|
20 |
-
{
|
21 |
-
public function testHandle()
|
22 |
-
{
|
23 |
-
$testHandler = new TestHandler();
|
24 |
-
$handler = new SamplingHandler($testHandler, 2);
|
25 |
-
for ($i = 0; $i < 10000; $i++) {
|
26 |
-
$handler->handle($this->getRecord());
|
27 |
-
}
|
28 |
-
$count = count($testHandler->getRecords());
|
29 |
-
// $count should be half of 10k, so between 4k and 6k
|
30 |
-
$this->assertLessThan(6000, $count);
|
31 |
-
$this->assertGreaterThan(4000, $count);
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php
DELETED
@@ -1,395 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\Slack;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @coversDefaultClass Monolog\Handler\Slack\SlackRecord
|
19 |
-
*/
|
20 |
-
class SlackRecordTest extends TestCase
|
21 |
-
{
|
22 |
-
private $jsonPrettyPrintFlag;
|
23 |
-
|
24 |
-
protected function setUp()
|
25 |
-
{
|
26 |
-
$this->jsonPrettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
|
27 |
-
}
|
28 |
-
|
29 |
-
public function dataGetAttachmentColor()
|
30 |
-
{
|
31 |
-
return array(
|
32 |
-
array(Logger::DEBUG, SlackRecord::COLOR_DEFAULT),
|
33 |
-
array(Logger::INFO, SlackRecord::COLOR_GOOD),
|
34 |
-
array(Logger::NOTICE, SlackRecord::COLOR_GOOD),
|
35 |
-
array(Logger::WARNING, SlackRecord::COLOR_WARNING),
|
36 |
-
array(Logger::ERROR, SlackRecord::COLOR_DANGER),
|
37 |
-
array(Logger::CRITICAL, SlackRecord::COLOR_DANGER),
|
38 |
-
array(Logger::ALERT, SlackRecord::COLOR_DANGER),
|
39 |
-
array(Logger::EMERGENCY, SlackRecord::COLOR_DANGER),
|
40 |
-
);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @dataProvider dataGetAttachmentColor
|
45 |
-
* @param int $logLevel
|
46 |
-
* @param string $expectedColour RGB hex color or name of Slack color
|
47 |
-
* @covers ::getAttachmentColor
|
48 |
-
*/
|
49 |
-
public function testGetAttachmentColor($logLevel, $expectedColour)
|
50 |
-
{
|
51 |
-
$slackRecord = new SlackRecord();
|
52 |
-
$this->assertSame(
|
53 |
-
$expectedColour,
|
54 |
-
$slackRecord->getAttachmentColor($logLevel)
|
55 |
-
);
|
56 |
-
}
|
57 |
-
|
58 |
-
public function testAddsChannel()
|
59 |
-
{
|
60 |
-
$channel = '#test';
|
61 |
-
$record = new SlackRecord($channel);
|
62 |
-
$data = $record->getSlackData($this->getRecord());
|
63 |
-
|
64 |
-
$this->assertArrayHasKey('channel', $data);
|
65 |
-
$this->assertSame($channel, $data['channel']);
|
66 |
-
}
|
67 |
-
|
68 |
-
public function testNoUsernameByDefault()
|
69 |
-
{
|
70 |
-
$record = new SlackRecord();
|
71 |
-
$data = $record->getSlackData($this->getRecord());
|
72 |
-
|
73 |
-
$this->assertArrayNotHasKey('username', $data);
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @return array
|
78 |
-
*/
|
79 |
-
public function dataStringify()
|
80 |
-
{
|
81 |
-
$jsonPrettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
|
82 |
-
|
83 |
-
$multipleDimensions = array(array(1, 2));
|
84 |
-
$numericKeys = array('library' => 'monolog');
|
85 |
-
$singleDimension = array(1, 'Hello', 'Jordi');
|
86 |
-
|
87 |
-
return array(
|
88 |
-
array(array(), '[]'),
|
89 |
-
array($multipleDimensions, json_encode($multipleDimensions, $jsonPrettyPrintFlag)),
|
90 |
-
array($numericKeys, json_encode($numericKeys, $jsonPrettyPrintFlag)),
|
91 |
-
array($singleDimension, json_encode($singleDimension))
|
92 |
-
);
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @dataProvider dataStringify
|
97 |
-
*/
|
98 |
-
public function testStringify($fields, $expectedResult)
|
99 |
-
{
|
100 |
-
$slackRecord = new SlackRecord(
|
101 |
-
'#test',
|
102 |
-
'test',
|
103 |
-
true,
|
104 |
-
null,
|
105 |
-
true,
|
106 |
-
true
|
107 |
-
);
|
108 |
-
|
109 |
-
$this->assertSame($expectedResult, $slackRecord->stringify($fields));
|
110 |
-
}
|
111 |
-
|
112 |
-
public function testAddsCustomUsername()
|
113 |
-
{
|
114 |
-
$username = 'Monolog bot';
|
115 |
-
$record = new SlackRecord(null, $username);
|
116 |
-
$data = $record->getSlackData($this->getRecord());
|
117 |
-
|
118 |
-
$this->assertArrayHasKey('username', $data);
|
119 |
-
$this->assertSame($username, $data['username']);
|
120 |
-
}
|
121 |
-
|
122 |
-
public function testNoIcon()
|
123 |
-
{
|
124 |
-
$record = new SlackRecord();
|
125 |
-
$data = $record->getSlackData($this->getRecord());
|
126 |
-
|
127 |
-
$this->assertArrayNotHasKey('icon_emoji', $data);
|
128 |
-
}
|
129 |
-
|
130 |
-
public function testAddsIcon()
|
131 |
-
{
|
132 |
-
$record = $this->getRecord();
|
133 |
-
$slackRecord = new SlackRecord(null, null, false, 'ghost');
|
134 |
-
$data = $slackRecord->getSlackData($record);
|
135 |
-
|
136 |
-
$slackRecord2 = new SlackRecord(null, null, false, 'http://github.com/Seldaek/monolog');
|
137 |
-
$data2 = $slackRecord2->getSlackData($record);
|
138 |
-
|
139 |
-
$this->assertArrayHasKey('icon_emoji', $data);
|
140 |
-
$this->assertSame(':ghost:', $data['icon_emoji']);
|
141 |
-
$this->assertArrayHasKey('icon_url', $data2);
|
142 |
-
$this->assertSame('http://github.com/Seldaek/monolog', $data2['icon_url']);
|
143 |
-
}
|
144 |
-
|
145 |
-
public function testAttachmentsNotPresentIfNoAttachment()
|
146 |
-
{
|
147 |
-
$record = new SlackRecord(null, null, false);
|
148 |
-
$data = $record->getSlackData($this->getRecord());
|
149 |
-
|
150 |
-
$this->assertArrayNotHasKey('attachments', $data);
|
151 |
-
}
|
152 |
-
|
153 |
-
public function testAddsOneAttachment()
|
154 |
-
{
|
155 |
-
$record = new SlackRecord();
|
156 |
-
$data = $record->getSlackData($this->getRecord());
|
157 |
-
|
158 |
-
$this->assertArrayHasKey('attachments', $data);
|
159 |
-
$this->assertArrayHasKey(0, $data['attachments']);
|
160 |
-
$this->assertInternalType('array', $data['attachments'][0]);
|
161 |
-
}
|
162 |
-
|
163 |
-
public function testTextEqualsMessageIfNoAttachment()
|
164 |
-
{
|
165 |
-
$message = 'Test message';
|
166 |
-
$record = new SlackRecord(null, null, false);
|
167 |
-
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
|
168 |
-
|
169 |
-
$this->assertArrayHasKey('text', $data);
|
170 |
-
$this->assertSame($message, $data['text']);
|
171 |
-
}
|
172 |
-
|
173 |
-
public function testTextEqualsFormatterOutput()
|
174 |
-
{
|
175 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
176 |
-
$formatter
|
177 |
-
->expects($this->any())
|
178 |
-
->method('format')
|
179 |
-
->will($this->returnCallback(function ($record) { return $record['message'] . 'test'; }));
|
180 |
-
|
181 |
-
$formatter2 = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
182 |
-
$formatter2
|
183 |
-
->expects($this->any())
|
184 |
-
->method('format')
|
185 |
-
->will($this->returnCallback(function ($record) { return $record['message'] . 'test1'; }));
|
186 |
-
|
187 |
-
$message = 'Test message';
|
188 |
-
$record = new SlackRecord(null, null, false, null, false, false, array(), $formatter);
|
189 |
-
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
|
190 |
-
|
191 |
-
$this->assertArrayHasKey('text', $data);
|
192 |
-
$this->assertSame($message . 'test', $data['text']);
|
193 |
-
|
194 |
-
$record->setFormatter($formatter2);
|
195 |
-
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
|
196 |
-
|
197 |
-
$this->assertArrayHasKey('text', $data);
|
198 |
-
$this->assertSame($message . 'test1', $data['text']);
|
199 |
-
}
|
200 |
-
|
201 |
-
public function testAddsFallbackAndTextToAttachment()
|
202 |
-
{
|
203 |
-
$message = 'Test message';
|
204 |
-
$record = new SlackRecord(null);
|
205 |
-
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
|
206 |
-
|
207 |
-
$this->assertSame($message, $data['attachments'][0]['text']);
|
208 |
-
$this->assertSame($message, $data['attachments'][0]['fallback']);
|
209 |
-
}
|
210 |
-
|
211 |
-
public function testMapsLevelToColorAttachmentColor()
|
212 |
-
{
|
213 |
-
$record = new SlackRecord(null);
|
214 |
-
$errorLoggerRecord = $this->getRecord(Logger::ERROR);
|
215 |
-
$emergencyLoggerRecord = $this->getRecord(Logger::EMERGENCY);
|
216 |
-
$warningLoggerRecord = $this->getRecord(Logger::WARNING);
|
217 |
-
$infoLoggerRecord = $this->getRecord(Logger::INFO);
|
218 |
-
$debugLoggerRecord = $this->getRecord(Logger::DEBUG);
|
219 |
-
|
220 |
-
$data = $record->getSlackData($errorLoggerRecord);
|
221 |
-
$this->assertSame(SlackRecord::COLOR_DANGER, $data['attachments'][0]['color']);
|
222 |
-
|
223 |
-
$data = $record->getSlackData($emergencyLoggerRecord);
|
224 |
-
$this->assertSame(SlackRecord::COLOR_DANGER, $data['attachments'][0]['color']);
|
225 |
-
|
226 |
-
$data = $record->getSlackData($warningLoggerRecord);
|
227 |
-
$this->assertSame(SlackRecord::COLOR_WARNING, $data['attachments'][0]['color']);
|
228 |
-
|
229 |
-
$data = $record->getSlackData($infoLoggerRecord);
|
230 |
-
$this->assertSame(SlackRecord::COLOR_GOOD, $data['attachments'][0]['color']);
|
231 |
-
|
232 |
-
$data = $record->getSlackData($debugLoggerRecord);
|
233 |
-
$this->assertSame(SlackRecord::COLOR_DEFAULT, $data['attachments'][0]['color']);
|
234 |
-
}
|
235 |
-
|
236 |
-
public function testAddsShortAttachmentWithoutContextAndExtra()
|
237 |
-
{
|
238 |
-
$level = Logger::ERROR;
|
239 |
-
$levelName = Logger::getLevelName($level);
|
240 |
-
$record = new SlackRecord(null, null, true, null, true);
|
241 |
-
$data = $record->getSlackData($this->getRecord($level, 'test', array('test' => 1)));
|
242 |
-
|
243 |
-
$attachment = $data['attachments'][0];
|
244 |
-
$this->assertArrayHasKey('title', $attachment);
|
245 |
-
$this->assertArrayHasKey('fields', $attachment);
|
246 |
-
$this->assertSame($levelName, $attachment['title']);
|
247 |
-
$this->assertSame(array(), $attachment['fields']);
|
248 |
-
}
|
249 |
-
|
250 |
-
public function testAddsShortAttachmentWithContextAndExtra()
|
251 |
-
{
|
252 |
-
$level = Logger::ERROR;
|
253 |
-
$levelName = Logger::getLevelName($level);
|
254 |
-
$context = array('test' => 1);
|
255 |
-
$extra = array('tags' => array('web'));
|
256 |
-
$record = new SlackRecord(null, null, true, null, true, true);
|
257 |
-
$loggerRecord = $this->getRecord($level, 'test', $context);
|
258 |
-
$loggerRecord['extra'] = $extra;
|
259 |
-
$data = $record->getSlackData($loggerRecord);
|
260 |
-
|
261 |
-
$attachment = $data['attachments'][0];
|
262 |
-
$this->assertArrayHasKey('title', $attachment);
|
263 |
-
$this->assertArrayHasKey('fields', $attachment);
|
264 |
-
$this->assertCount(2, $attachment['fields']);
|
265 |
-
$this->assertSame($levelName, $attachment['title']);
|
266 |
-
$this->assertSame(
|
267 |
-
array(
|
268 |
-
array(
|
269 |
-
'title' => 'Extra',
|
270 |
-
'value' => sprintf('```%s```', json_encode($extra, $this->jsonPrettyPrintFlag)),
|
271 |
-
'short' => false
|
272 |
-
),
|
273 |
-
array(
|
274 |
-
'title' => 'Context',
|
275 |
-
'value' => sprintf('```%s```', json_encode($context, $this->jsonPrettyPrintFlag)),
|
276 |
-
'short' => false
|
277 |
-
)
|
278 |
-
),
|
279 |
-
$attachment['fields']
|
280 |
-
);
|
281 |
-
}
|
282 |
-
|
283 |
-
public function testAddsLongAttachmentWithoutContextAndExtra()
|
284 |
-
{
|
285 |
-
$level = Logger::ERROR;
|
286 |
-
$levelName = Logger::getLevelName($level);
|
287 |
-
$record = new SlackRecord(null, null, true, null);
|
288 |
-
$data = $record->getSlackData($this->getRecord($level, 'test', array('test' => 1)));
|
289 |
-
|
290 |
-
$attachment = $data['attachments'][0];
|
291 |
-
$this->assertArrayHasKey('title', $attachment);
|
292 |
-
$this->assertArrayHasKey('fields', $attachment);
|
293 |
-
$this->assertCount(1, $attachment['fields']);
|
294 |
-
$this->assertSame('Message', $attachment['title']);
|
295 |
-
$this->assertSame(
|
296 |
-
array(array(
|
297 |
-
'title' => 'Level',
|
298 |
-
'value' => $levelName,
|
299 |
-
'short' => false
|
300 |
-
)),
|
301 |
-
$attachment['fields']
|
302 |
-
);
|
303 |
-
}
|
304 |
-
|
305 |
-
public function testAddsLongAttachmentWithContextAndExtra()
|
306 |
-
{
|
307 |
-
$level = Logger::ERROR;
|
308 |
-
$levelName = Logger::getLevelName($level);
|
309 |
-
$context = array('test' => 1);
|
310 |
-
$extra = array('tags' => array('web'));
|
311 |
-
$record = new SlackRecord(null, null, true, null, false, true);
|
312 |
-
$loggerRecord = $this->getRecord($level, 'test', $context);
|
313 |
-
$loggerRecord['extra'] = $extra;
|
314 |
-
$data = $record->getSlackData($loggerRecord);
|
315 |
-
|
316 |
-
$expectedFields = array(
|
317 |
-
array(
|
318 |
-
'title' => 'Level',
|
319 |
-
'value' => $levelName,
|
320 |
-
'short' => false,
|
321 |
-
),
|
322 |
-
array(
|
323 |
-
'title' => 'Tags',
|
324 |
-
'value' => sprintf('```%s```', json_encode($extra['tags'])),
|
325 |
-
'short' => false
|
326 |
-
),
|
327 |
-
array(
|
328 |
-
'title' => 'Test',
|
329 |
-
'value' => $context['test'],
|
330 |
-
'short' => false
|
331 |
-
)
|
332 |
-
);
|
333 |
-
|
334 |
-
$attachment = $data['attachments'][0];
|
335 |
-
$this->assertArrayHasKey('title', $attachment);
|
336 |
-
$this->assertArrayHasKey('fields', $attachment);
|
337 |
-
$this->assertCount(3, $attachment['fields']);
|
338 |
-
$this->assertSame('Message', $attachment['title']);
|
339 |
-
$this->assertSame(
|
340 |
-
$expectedFields,
|
341 |
-
$attachment['fields']
|
342 |
-
);
|
343 |
-
}
|
344 |
-
|
345 |
-
public function testAddsTimestampToAttachment()
|
346 |
-
{
|
347 |
-
$record = $this->getRecord();
|
348 |
-
$slackRecord = new SlackRecord();
|
349 |
-
$data = $slackRecord->getSlackData($this->getRecord());
|
350 |
-
|
351 |
-
$attachment = $data['attachments'][0];
|
352 |
-
$this->assertArrayHasKey('ts', $attachment);
|
353 |
-
$this->assertSame($record['datetime']->getTimestamp(), $attachment['ts']);
|
354 |
-
}
|
355 |
-
|
356 |
-
public function testContextHasException()
|
357 |
-
{
|
358 |
-
$record = $this->getRecord(Logger::CRITICAL, 'This is a critical message.', array('exception' => new \Exception()));
|
359 |
-
$slackRecord = new SlackRecord(null, null, true, null, false, true);
|
360 |
-
$data = $slackRecord->getSlackData($record);
|
361 |
-
$this->assertInternalType('string', $data['attachments'][0]['fields'][1]['value']);
|
362 |
-
}
|
363 |
-
|
364 |
-
public function testExcludeExtraAndContextFields()
|
365 |
-
{
|
366 |
-
$record = $this->getRecord(
|
367 |
-
Logger::WARNING,
|
368 |
-
'test',
|
369 |
-
array('info' => array('library' => 'monolog', 'author' => 'Jordi'))
|
370 |
-
);
|
371 |
-
$record['extra'] = array('tags' => array('web', 'cli'));
|
372 |
-
|
373 |
-
$slackRecord = new SlackRecord(null, null, true, null, false, true, array('context.info.library', 'extra.tags.1'));
|
374 |
-
$data = $slackRecord->getSlackData($record);
|
375 |
-
$attachment = $data['attachments'][0];
|
376 |
-
|
377 |
-
$expected = array(
|
378 |
-
array(
|
379 |
-
'title' => 'Info',
|
380 |
-
'value' => sprintf('```%s```', json_encode(array('author' => 'Jordi'), $this->jsonPrettyPrintFlag)),
|
381 |
-
'short' => false
|
382 |
-
),
|
383 |
-
array(
|
384 |
-
'title' => 'Tags',
|
385 |
-
'value' => sprintf('```%s```', json_encode(array('web'))),
|
386 |
-
'short' => false
|
387 |
-
),
|
388 |
-
);
|
389 |
-
|
390 |
-
foreach ($expected as $field) {
|
391 |
-
$this->assertNotFalse(array_search($field, $attachment['fields']));
|
392 |
-
break;
|
393 |
-
}
|
394 |
-
}
|
395 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php
DELETED
@@ -1,155 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
use Monolog\Handler\Slack\SlackRecord;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @author Greg Kedzierski <greg@gregkedzierski.com>
|
21 |
-
* @see https://api.slack.com/
|
22 |
-
*/
|
23 |
-
class SlackHandlerTest extends TestCase
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* @var resource
|
27 |
-
*/
|
28 |
-
private $res;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var SlackHandler
|
32 |
-
*/
|
33 |
-
private $handler;
|
34 |
-
|
35 |
-
public function setUp()
|
36 |
-
{
|
37 |
-
if (!extension_loaded('openssl')) {
|
38 |
-
$this->markTestSkipped('This test requires openssl to run');
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
public function testWriteHeader()
|
43 |
-
{
|
44 |
-
$this->createHandler();
|
45 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
46 |
-
fseek($this->res, 0);
|
47 |
-
$content = fread($this->res, 1024);
|
48 |
-
|
49 |
-
$this->assertRegexp('/POST \/api\/chat.postMessage HTTP\/1.1\\r\\nHost: slack.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
50 |
-
}
|
51 |
-
|
52 |
-
public function testWriteContent()
|
53 |
-
{
|
54 |
-
$this->createHandler();
|
55 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
56 |
-
fseek($this->res, 0);
|
57 |
-
$content = fread($this->res, 1024);
|
58 |
-
|
59 |
-
$this->assertRegExp('/username=Monolog/', $content);
|
60 |
-
$this->assertRegExp('/channel=channel1/', $content);
|
61 |
-
$this->assertRegExp('/token=myToken/', $content);
|
62 |
-
$this->assertRegExp('/attachments/', $content);
|
63 |
-
}
|
64 |
-
|
65 |
-
public function testWriteContentUsesFormatterIfProvided()
|
66 |
-
{
|
67 |
-
$this->createHandler('myToken', 'channel1', 'Monolog', false);
|
68 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
69 |
-
fseek($this->res, 0);
|
70 |
-
$content = fread($this->res, 1024);
|
71 |
-
|
72 |
-
$this->createHandler('myToken', 'channel1', 'Monolog', false);
|
73 |
-
$this->handler->setFormatter(new LineFormatter('foo--%message%'));
|
74 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test2'));
|
75 |
-
fseek($this->res, 0);
|
76 |
-
$content2 = fread($this->res, 1024);
|
77 |
-
|
78 |
-
$this->assertRegexp('/text=test1/', $content);
|
79 |
-
$this->assertRegexp('/text=foo--test2/', $content2);
|
80 |
-
}
|
81 |
-
|
82 |
-
public function testWriteContentWithEmoji()
|
83 |
-
{
|
84 |
-
$this->createHandler('myToken', 'channel1', 'Monolog', true, 'alien');
|
85 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
86 |
-
fseek($this->res, 0);
|
87 |
-
$content = fread($this->res, 1024);
|
88 |
-
|
89 |
-
$this->assertRegexp('/icon_emoji=%3Aalien%3A/', $content);
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @dataProvider provideLevelColors
|
94 |
-
*/
|
95 |
-
public function testWriteContentWithColors($level, $expectedColor)
|
96 |
-
{
|
97 |
-
$this->createHandler();
|
98 |
-
$this->handler->handle($this->getRecord($level, 'test1'));
|
99 |
-
fseek($this->res, 0);
|
100 |
-
$content = fread($this->res, 1024);
|
101 |
-
|
102 |
-
$this->assertRegexp('/%22color%22%3A%22'.$expectedColor.'/', $content);
|
103 |
-
}
|
104 |
-
|
105 |
-
public function testWriteContentWithPlainTextMessage()
|
106 |
-
{
|
107 |
-
$this->createHandler('myToken', 'channel1', 'Monolog', false);
|
108 |
-
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
109 |
-
fseek($this->res, 0);
|
110 |
-
$content = fread($this->res, 1024);
|
111 |
-
|
112 |
-
$this->assertRegexp('/text=test1/', $content);
|
113 |
-
}
|
114 |
-
|
115 |
-
public function provideLevelColors()
|
116 |
-
{
|
117 |
-
return array(
|
118 |
-
array(Logger::DEBUG, urlencode(SlackRecord::COLOR_DEFAULT)),
|
119 |
-
array(Logger::INFO, SlackRecord::COLOR_GOOD),
|
120 |
-
array(Logger::NOTICE, SlackRecord::COLOR_GOOD),
|
121 |
-
array(Logger::WARNING, SlackRecord::COLOR_WARNING),
|
122 |
-
array(Logger::ERROR, SlackRecord::COLOR_DANGER),
|
123 |
-
array(Logger::CRITICAL, SlackRecord::COLOR_DANGER),
|
124 |
-
array(Logger::ALERT, SlackRecord::COLOR_DANGER),
|
125 |
-
array(Logger::EMERGENCY,SlackRecord::COLOR_DANGER),
|
126 |
-
);
|
127 |
-
}
|
128 |
-
|
129 |
-
private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeExtra = false)
|
130 |
-
{
|
131 |
-
$constructorArgs = array($token, $channel, $username, $useAttachment, $iconEmoji, Logger::DEBUG, true, $useShortAttachment, $includeExtra);
|
132 |
-
$this->res = fopen('php://memory', 'a');
|
133 |
-
$this->handler = $this->getMock(
|
134 |
-
'\Monolog\Handler\SlackHandler',
|
135 |
-
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
136 |
-
$constructorArgs
|
137 |
-
);
|
138 |
-
|
139 |
-
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
140 |
-
$reflectionProperty->setAccessible(true);
|
141 |
-
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
142 |
-
|
143 |
-
$this->handler->expects($this->any())
|
144 |
-
->method('fsockopen')
|
145 |
-
->will($this->returnValue($this->res));
|
146 |
-
$this->handler->expects($this->any())
|
147 |
-
->method('streamSetTimeout')
|
148 |
-
->will($this->returnValue(true));
|
149 |
-
$this->handler->expects($this->any())
|
150 |
-
->method('closeSocket')
|
151 |
-
->will($this->returnValue(true));
|
152 |
-
|
153 |
-
$this->handler->setFormatter($this->getIdentityFormatter());
|
154 |
-
}
|
155 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SlackWebhookHandlerTest.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
use Monolog\Handler\Slack\SlackRecord;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @author Haralan Dobrev <hkdobrev@gmail.com>
|
21 |
-
* @see https://api.slack.com/incoming-webhooks
|
22 |
-
* @coversDefaultClass Monolog\Handler\SlackWebhookHandler
|
23 |
-
*/
|
24 |
-
class SlackWebhookHandlerTest extends TestCase
|
25 |
-
{
|
26 |
-
const WEBHOOK_URL = 'https://hooks.slack.com/services/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E';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @covers ::__construct
|
30 |
-
* @covers ::getSlackRecord
|
31 |
-
*/
|
32 |
-
public function testConstructorMinimal()
|
33 |
-
{
|
34 |
-
$handler = new SlackWebhookHandler(self::WEBHOOK_URL);
|
35 |
-
$record = $this->getRecord();
|
36 |
-
$slackRecord = $handler->getSlackRecord();
|
37 |
-
$this->assertInstanceOf('Monolog\Handler\Slack\SlackRecord', $slackRecord);
|
38 |
-
$this->assertEquals(array(
|
39 |
-
'attachments' => array(
|
40 |
-
array(
|
41 |
-
'fallback' => 'test',
|
42 |
-
'text' => 'test',
|
43 |
-
'color' => SlackRecord::COLOR_WARNING,
|
44 |
-
'fields' => array(
|
45 |
-
array(
|
46 |
-
'title' => 'Level',
|
47 |
-
'value' => 'WARNING',
|
48 |
-
'short' => false,
|
49 |
-
),
|
50 |
-
),
|
51 |
-
'title' => 'Message',
|
52 |
-
'mrkdwn_in' => array('fields'),
|
53 |
-
'ts' => $record['datetime']->getTimestamp(),
|
54 |
-
),
|
55 |
-
),
|
56 |
-
), $slackRecord->getSlackData($record));
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @covers ::__construct
|
61 |
-
* @covers ::getSlackRecord
|
62 |
-
*/
|
63 |
-
public function testConstructorFull()
|
64 |
-
{
|
65 |
-
$handler = new SlackWebhookHandler(
|
66 |
-
self::WEBHOOK_URL,
|
67 |
-
'test-channel',
|
68 |
-
'test-username',
|
69 |
-
false,
|
70 |
-
':ghost:',
|
71 |
-
false,
|
72 |
-
false,
|
73 |
-
Logger::DEBUG,
|
74 |
-
false
|
75 |
-
);
|
76 |
-
|
77 |
-
$slackRecord = $handler->getSlackRecord();
|
78 |
-
$this->assertInstanceOf('Monolog\Handler\Slack\SlackRecord', $slackRecord);
|
79 |
-
$this->assertEquals(array(
|
80 |
-
'username' => 'test-username',
|
81 |
-
'text' => 'test',
|
82 |
-
'channel' => 'test-channel',
|
83 |
-
'icon_emoji' => ':ghost:',
|
84 |
-
), $slackRecord->getSlackData($this->getRecord()));
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @covers ::getFormatter
|
89 |
-
*/
|
90 |
-
public function testGetFormatter()
|
91 |
-
{
|
92 |
-
$handler = new SlackWebhookHandler(self::WEBHOOK_URL);
|
93 |
-
$formatter = $handler->getFormatter();
|
94 |
-
$this->assertInstanceOf('Monolog\Formatter\FormatterInterface', $formatter);
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @covers ::setFormatter
|
99 |
-
*/
|
100 |
-
public function testSetFormatter()
|
101 |
-
{
|
102 |
-
$handler = new SlackWebhookHandler(self::WEBHOOK_URL);
|
103 |
-
$formatter = new LineFormatter();
|
104 |
-
$handler->setFormatter($formatter);
|
105 |
-
$this->assertSame($formatter, $handler->getFormatter());
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SlackbotHandlerTest.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Haralan Dobrev <hkdobrev@gmail.com>
|
19 |
-
* @see https://slack.com/apps/A0F81R8ET-slackbot
|
20 |
-
* @coversDefaultClass Monolog\Handler\SlackbotHandler
|
21 |
-
*/
|
22 |
-
class SlackbotHandlerTest extends TestCase
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @covers ::__construct
|
26 |
-
*/
|
27 |
-
public function testConstructorMinimal()
|
28 |
-
{
|
29 |
-
$handler = new SlackbotHandler('test-team', 'test-token', 'test-channel');
|
30 |
-
$this->assertInstanceOf('Monolog\Handler\AbstractProcessingHandler', $handler);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @covers ::__construct
|
35 |
-
*/
|
36 |
-
public function testConstructorFull()
|
37 |
-
{
|
38 |
-
$handler = new SlackbotHandler(
|
39 |
-
'test-team',
|
40 |
-
'test-token',
|
41 |
-
'test-channel',
|
42 |
-
Logger::DEBUG,
|
43 |
-
false
|
44 |
-
);
|
45 |
-
$this->assertInstanceOf('Monolog\Handler\AbstractProcessingHandler', $handler);
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
DELETED
@@ -1,335 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @author Pablo de Leon Belloc <pablolb@gmail.com>
|
19 |
-
*/
|
20 |
-
class SocketHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @var Monolog\Handler\SocketHandler
|
24 |
-
*/
|
25 |
-
private $handler;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var resource
|
29 |
-
*/
|
30 |
-
private $res;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @expectedException UnexpectedValueException
|
34 |
-
*/
|
35 |
-
public function testInvalidHostname()
|
36 |
-
{
|
37 |
-
$this->createHandler('garbage://here');
|
38 |
-
$this->writeRecord('data');
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @expectedException \InvalidArgumentException
|
43 |
-
*/
|
44 |
-
public function testBadConnectionTimeout()
|
45 |
-
{
|
46 |
-
$this->createHandler('localhost:1234');
|
47 |
-
$this->handler->setConnectionTimeout(-1);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function testSetConnectionTimeout()
|
51 |
-
{
|
52 |
-
$this->createHandler('localhost:1234');
|
53 |
-
$this->handler->setConnectionTimeout(10.1);
|
54 |
-
$this->assertEquals(10.1, $this->handler->getConnectionTimeout());
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @expectedException \InvalidArgumentException
|
59 |
-
*/
|
60 |
-
public function testBadTimeout()
|
61 |
-
{
|
62 |
-
$this->createHandler('localhost:1234');
|
63 |
-
$this->handler->setTimeout(-1);
|
64 |
-
}
|
65 |
-
|
66 |
-
public function testSetTimeout()
|
67 |
-
{
|
68 |
-
$this->createHandler('localhost:1234');
|
69 |
-
$this->handler->setTimeout(10.25);
|
70 |
-
$this->assertEquals(10.25, $this->handler->getTimeout());
|
71 |
-
}
|
72 |
-
|
73 |
-
public function testSetWritingTimeout()
|
74 |
-
{
|
75 |
-
$this->createHandler('localhost:1234');
|
76 |
-
$this->handler->setWritingTimeout(10.25);
|
77 |
-
$this->assertEquals(10.25, $this->handler->getWritingTimeout());
|
78 |
-
}
|
79 |
-
|
80 |
-
public function testSetChunkSize()
|
81 |
-
{
|
82 |
-
$this->createHandler('localhost:1234');
|
83 |
-
$this->handler->setChunkSize(1025);
|
84 |
-
$this->assertEquals(1025, $this->handler->getChunkSize());
|
85 |
-
}
|
86 |
-
|
87 |
-
public function testSetConnectionString()
|
88 |
-
{
|
89 |
-
$this->createHandler('tcp://localhost:9090');
|
90 |
-
$this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @expectedException UnexpectedValueException
|
95 |
-
*/
|
96 |
-
public function testExceptionIsThrownOnFsockopenError()
|
97 |
-
{
|
98 |
-
$this->setMockHandler(array('fsockopen'));
|
99 |
-
$this->handler->expects($this->once())
|
100 |
-
->method('fsockopen')
|
101 |
-
->will($this->returnValue(false));
|
102 |
-
$this->writeRecord('Hello world');
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @expectedException UnexpectedValueException
|
107 |
-
*/
|
108 |
-
public function testExceptionIsThrownOnPfsockopenError()
|
109 |
-
{
|
110 |
-
$this->setMockHandler(array('pfsockopen'));
|
111 |
-
$this->handler->expects($this->once())
|
112 |
-
->method('pfsockopen')
|
113 |
-
->will($this->returnValue(false));
|
114 |
-
$this->handler->setPersistent(true);
|
115 |
-
$this->writeRecord('Hello world');
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* @expectedException UnexpectedValueException
|
120 |
-
*/
|
121 |
-
public function testExceptionIsThrownIfCannotSetTimeout()
|
122 |
-
{
|
123 |
-
$this->setMockHandler(array('streamSetTimeout'));
|
124 |
-
$this->handler->expects($this->once())
|
125 |
-
->method('streamSetTimeout')
|
126 |
-
->will($this->returnValue(false));
|
127 |
-
$this->writeRecord('Hello world');
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* @expectedException UnexpectedValueException
|
132 |
-
*/
|
133 |
-
public function testExceptionIsThrownIfCannotSetChunkSize()
|
134 |
-
{
|
135 |
-
$this->setMockHandler(array('streamSetChunkSize'));
|
136 |
-
$this->handler->setChunkSize(8192);
|
137 |
-
$this->handler->expects($this->once())
|
138 |
-
->method('streamSetChunkSize')
|
139 |
-
->will($this->returnValue(false));
|
140 |
-
$this->writeRecord('Hello world');
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @expectedException RuntimeException
|
145 |
-
*/
|
146 |
-
public function testWriteFailsOnIfFwriteReturnsFalse()
|
147 |
-
{
|
148 |
-
$this->setMockHandler(array('fwrite'));
|
149 |
-
|
150 |
-
$callback = function ($arg) {
|
151 |
-
$map = array(
|
152 |
-
'Hello world' => 6,
|
153 |
-
'world' => false,
|
154 |
-
);
|
155 |
-
|
156 |
-
return $map[$arg];
|
157 |
-
};
|
158 |
-
|
159 |
-
$this->handler->expects($this->exactly(2))
|
160 |
-
->method('fwrite')
|
161 |
-
->will($this->returnCallback($callback));
|
162 |
-
|
163 |
-
$this->writeRecord('Hello world');
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* @expectedException RuntimeException
|
168 |
-
*/
|
169 |
-
public function testWriteFailsIfStreamTimesOut()
|
170 |
-
{
|
171 |
-
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
172 |
-
|
173 |
-
$callback = function ($arg) {
|
174 |
-
$map = array(
|
175 |
-
'Hello world' => 6,
|
176 |
-
'world' => 5,
|
177 |
-
);
|
178 |
-
|
179 |
-
return $map[$arg];
|
180 |
-
};
|
181 |
-
|
182 |
-
$this->handler->expects($this->exactly(1))
|
183 |
-
->method('fwrite')
|
184 |
-
->will($this->returnCallback($callback));
|
185 |
-
$this->handler->expects($this->exactly(1))
|
186 |
-
->method('streamGetMetadata')
|
187 |
-
->will($this->returnValue(array('timed_out' => true)));
|
188 |
-
|
189 |
-
$this->writeRecord('Hello world');
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* @expectedException RuntimeException
|
194 |
-
*/
|
195 |
-
public function testWriteFailsOnIncompleteWrite()
|
196 |
-
{
|
197 |
-
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
198 |
-
|
199 |
-
$res = $this->res;
|
200 |
-
$callback = function ($string) use ($res) {
|
201 |
-
fclose($res);
|
202 |
-
|
203 |
-
return strlen('Hello');
|
204 |
-
};
|
205 |
-
|
206 |
-
$this->handler->expects($this->exactly(1))
|
207 |
-
->method('fwrite')
|
208 |
-
->will($this->returnCallback($callback));
|
209 |
-
$this->handler->expects($this->exactly(1))
|
210 |
-
->method('streamGetMetadata')
|
211 |
-
->will($this->returnValue(array('timed_out' => false)));
|
212 |
-
|
213 |
-
$this->writeRecord('Hello world');
|
214 |
-
}
|
215 |
-
|
216 |
-
public function testWriteWithMemoryFile()
|
217 |
-
{
|
218 |
-
$this->setMockHandler();
|
219 |
-
$this->writeRecord('test1');
|
220 |
-
$this->writeRecord('test2');
|
221 |
-
$this->writeRecord('test3');
|
222 |
-
fseek($this->res, 0);
|
223 |
-
$this->assertEquals('test1test2test3', fread($this->res, 1024));
|
224 |
-
}
|
225 |
-
|
226 |
-
public function testWriteWithMock()
|
227 |
-
{
|
228 |
-
$this->setMockHandler(array('fwrite'));
|
229 |
-
|
230 |
-
$callback = function ($arg) {
|
231 |
-
$map = array(
|
232 |
-
'Hello world' => 6,
|
233 |
-
'world' => 5,
|
234 |
-
);
|
235 |
-
|
236 |
-
return $map[$arg];
|
237 |
-
};
|
238 |
-
|
239 |
-
$this->handler->expects($this->exactly(2))
|
240 |
-
->method('fwrite')
|
241 |
-
->will($this->returnCallback($callback));
|
242 |
-
|
243 |
-
$this->writeRecord('Hello world');
|
244 |
-
}
|
245 |
-
|
246 |
-
public function testClose()
|
247 |
-
{
|
248 |
-
$this->setMockHandler();
|
249 |
-
$this->writeRecord('Hello world');
|
250 |
-
$this->assertInternalType('resource', $this->res);
|
251 |
-
$this->handler->close();
|
252 |
-
$this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler");
|
253 |
-
}
|
254 |
-
|
255 |
-
public function testCloseDoesNotClosePersistentSocket()
|
256 |
-
{
|
257 |
-
$this->setMockHandler();
|
258 |
-
$this->handler->setPersistent(true);
|
259 |
-
$this->writeRecord('Hello world');
|
260 |
-
$this->assertTrue(is_resource($this->res));
|
261 |
-
$this->handler->close();
|
262 |
-
$this->assertTrue(is_resource($this->res));
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* @expectedException \RuntimeException
|
267 |
-
*/
|
268 |
-
public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
|
269 |
-
{
|
270 |
-
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
271 |
-
|
272 |
-
$this->handler->expects($this->any())
|
273 |
-
->method('fwrite')
|
274 |
-
->will($this->returnValue(0));
|
275 |
-
|
276 |
-
$this->handler->expects($this->any())
|
277 |
-
->method('streamGetMetadata')
|
278 |
-
->will($this->returnValue(array('timed_out' => false)));
|
279 |
-
|
280 |
-
$this->handler->setWritingTimeout(1);
|
281 |
-
|
282 |
-
$this->writeRecord('Hello world');
|
283 |
-
}
|
284 |
-
|
285 |
-
private function createHandler($connectionString)
|
286 |
-
{
|
287 |
-
$this->handler = new SocketHandler($connectionString);
|
288 |
-
$this->handler->setFormatter($this->getIdentityFormatter());
|
289 |
-
}
|
290 |
-
|
291 |
-
private function writeRecord($string)
|
292 |
-
{
|
293 |
-
$this->handler->handle($this->getRecord(Logger::WARNING, $string));
|
294 |
-
}
|
295 |
-
|
296 |
-
private function setMockHandler(array $methods = array())
|
297 |
-
{
|
298 |
-
$this->res = fopen('php://memory', 'a');
|
299 |
-
|
300 |
-
$defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
|
301 |
-
$newMethods = array_diff($methods, $defaultMethods);
|
302 |
-
|
303 |
-
$finalMethods = array_merge($defaultMethods, $newMethods);
|
304 |
-
|
305 |
-
$this->handler = $this->getMock(
|
306 |
-
'\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234')
|
307 |
-
);
|
308 |
-
|
309 |
-
if (!in_array('fsockopen', $methods)) {
|
310 |
-
$this->handler->expects($this->any())
|
311 |
-
->method('fsockopen')
|
312 |
-
->will($this->returnValue($this->res));
|
313 |
-
}
|
314 |
-
|
315 |
-
if (!in_array('pfsockopen', $methods)) {
|
316 |
-
$this->handler->expects($this->any())
|
317 |
-
->method('pfsockopen')
|
318 |
-
->will($this->returnValue($this->res));
|
319 |
-
}
|
320 |
-
|
321 |
-
if (!in_array('streamSetTimeout', $methods)) {
|
322 |
-
$this->handler->expects($this->any())
|
323 |
-
->method('streamSetTimeout')
|
324 |
-
->will($this->returnValue(true));
|
325 |
-
}
|
326 |
-
|
327 |
-
if (!in_array('streamSetChunkSize', $methods)) {
|
328 |
-
$this->handler->expects($this->any())
|
329 |
-
->method('streamSetChunkSize')
|
330 |
-
->will($this->returnValue(8192));
|
331 |
-
}
|
332 |
-
|
333 |
-
$this->handler->setFormatter($this->getIdentityFormatter());
|
334 |
-
}
|
335 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
DELETED
@@ -1,184 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class StreamHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
21 |
-
* @covers Monolog\Handler\StreamHandler::write
|
22 |
-
*/
|
23 |
-
public function testWrite()
|
24 |
-
{
|
25 |
-
$handle = fopen('php://memory', 'a+');
|
26 |
-
$handler = new StreamHandler($handle);
|
27 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
28 |
-
$handler->handle($this->getRecord(Logger::WARNING, 'test'));
|
29 |
-
$handler->handle($this->getRecord(Logger::WARNING, 'test2'));
|
30 |
-
$handler->handle($this->getRecord(Logger::WARNING, 'test3'));
|
31 |
-
fseek($handle, 0);
|
32 |
-
$this->assertEquals('testtest2test3', fread($handle, 100));
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @covers Monolog\Handler\StreamHandler::close
|
37 |
-
*/
|
38 |
-
public function testCloseKeepsExternalHandlersOpen()
|
39 |
-
{
|
40 |
-
$handle = fopen('php://memory', 'a+');
|
41 |
-
$handler = new StreamHandler($handle);
|
42 |
-
$this->assertTrue(is_resource($handle));
|
43 |
-
$handler->close();
|
44 |
-
$this->assertTrue(is_resource($handle));
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @covers Monolog\Handler\StreamHandler::close
|
49 |
-
*/
|
50 |
-
public function testClose()
|
51 |
-
{
|
52 |
-
$handler = new StreamHandler('php://memory');
|
53 |
-
$handler->handle($this->getRecord(Logger::WARNING, 'test'));
|
54 |
-
$streamProp = new \ReflectionProperty('Monolog\Handler\StreamHandler', 'stream');
|
55 |
-
$streamProp->setAccessible(true);
|
56 |
-
$handle = $streamProp->getValue($handler);
|
57 |
-
|
58 |
-
$this->assertTrue(is_resource($handle));
|
59 |
-
$handler->close();
|
60 |
-
$this->assertFalse(is_resource($handle));
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @covers Monolog\Handler\StreamHandler::write
|
65 |
-
*/
|
66 |
-
public function testWriteCreatesTheStreamResource()
|
67 |
-
{
|
68 |
-
$handler = new StreamHandler('php://memory');
|
69 |
-
$handler->handle($this->getRecord());
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
74 |
-
* @covers Monolog\Handler\StreamHandler::write
|
75 |
-
*/
|
76 |
-
public function testWriteLocking()
|
77 |
-
{
|
78 |
-
$temp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'monolog_locked_log';
|
79 |
-
$handler = new StreamHandler($temp, Logger::DEBUG, true, null, true);
|
80 |
-
$handler->handle($this->getRecord());
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @expectedException LogicException
|
85 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
86 |
-
* @covers Monolog\Handler\StreamHandler::write
|
87 |
-
*/
|
88 |
-
public function testWriteMissingResource()
|
89 |
-
{
|
90 |
-
$handler = new StreamHandler(null);
|
91 |
-
$handler->handle($this->getRecord());
|
92 |
-
}
|
93 |
-
|
94 |
-
public function invalidArgumentProvider()
|
95 |
-
{
|
96 |
-
return array(
|
97 |
-
array(1),
|
98 |
-
array(array()),
|
99 |
-
array(array('bogus://url')),
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @dataProvider invalidArgumentProvider
|
105 |
-
* @expectedException InvalidArgumentException
|
106 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
107 |
-
*/
|
108 |
-
public function testWriteInvalidArgument($invalidArgument)
|
109 |
-
{
|
110 |
-
$handler = new StreamHandler($invalidArgument);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @expectedException UnexpectedValueException
|
115 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
116 |
-
* @covers Monolog\Handler\StreamHandler::write
|
117 |
-
*/
|
118 |
-
public function testWriteInvalidResource()
|
119 |
-
{
|
120 |
-
$handler = new StreamHandler('bogus://url');
|
121 |
-
$handler->handle($this->getRecord());
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @expectedException UnexpectedValueException
|
126 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
127 |
-
* @covers Monolog\Handler\StreamHandler::write
|
128 |
-
*/
|
129 |
-
public function testWriteNonExistingResource()
|
130 |
-
{
|
131 |
-
$handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000));
|
132 |
-
$handler->handle($this->getRecord());
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
137 |
-
* @covers Monolog\Handler\StreamHandler::write
|
138 |
-
*/
|
139 |
-
public function testWriteNonExistingPath()
|
140 |
-
{
|
141 |
-
$handler = new StreamHandler(sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
142 |
-
$handler->handle($this->getRecord());
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
147 |
-
* @covers Monolog\Handler\StreamHandler::write
|
148 |
-
*/
|
149 |
-
public function testWriteNonExistingFileResource()
|
150 |
-
{
|
151 |
-
$handler = new StreamHandler('file://'.sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
152 |
-
$handler->handle($this->getRecord());
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @expectedException Exception
|
157 |
-
* @expectedExceptionMessageRegExp /There is no existing directory at/
|
158 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
159 |
-
* @covers Monolog\Handler\StreamHandler::write
|
160 |
-
*/
|
161 |
-
public function testWriteNonExistingAndNotCreatablePath()
|
162 |
-
{
|
163 |
-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
164 |
-
$this->markTestSkipped('Permissions checks can not run on windows');
|
165 |
-
}
|
166 |
-
$handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
167 |
-
$handler->handle($this->getRecord());
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @expectedException Exception
|
172 |
-
* @expectedExceptionMessageRegExp /There is no existing directory at/
|
173 |
-
* @covers Monolog\Handler\StreamHandler::__construct
|
174 |
-
* @covers Monolog\Handler\StreamHandler::write
|
175 |
-
*/
|
176 |
-
public function testWriteNonExistingAndNotCreatableFileResource()
|
177 |
-
{
|
178 |
-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
179 |
-
$this->markTestSkipped('Permissions checks can not run on windows');
|
180 |
-
}
|
181 |
-
$handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
|
182 |
-
$handler->handle($this->getRecord());
|
183 |
-
}
|
184 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\TestCase;
|
16 |
-
|
17 |
-
class SwiftMailerHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/** @var \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject */
|
20 |
-
private $mailer;
|
21 |
-
|
22 |
-
public function setUp()
|
23 |
-
{
|
24 |
-
$this->mailer = $this
|
25 |
-
->getMockBuilder('Swift_Mailer')
|
26 |
-
->disableOriginalConstructor()
|
27 |
-
->getMock();
|
28 |
-
}
|
29 |
-
|
30 |
-
public function testMessageCreationIsLazyWhenUsingCallback()
|
31 |
-
{
|
32 |
-
$this->mailer->expects($this->never())
|
33 |
-
->method('send');
|
34 |
-
|
35 |
-
$callback = function () {
|
36 |
-
throw new \RuntimeException('Swift_Message creation callback should not have been called in this test');
|
37 |
-
};
|
38 |
-
$handler = new SwiftMailerHandler($this->mailer, $callback);
|
39 |
-
|
40 |
-
$records = array(
|
41 |
-
$this->getRecord(Logger::DEBUG),
|
42 |
-
$this->getRecord(Logger::INFO),
|
43 |
-
);
|
44 |
-
$handler->handleBatch($records);
|
45 |
-
}
|
46 |
-
|
47 |
-
public function testMessageCanBeCustomizedGivenLoggedData()
|
48 |
-
{
|
49 |
-
// Wire Mailer to expect a specific Swift_Message with a customized Subject
|
50 |
-
$expectedMessage = new \Swift_Message();
|
51 |
-
$this->mailer->expects($this->once())
|
52 |
-
->method('send')
|
53 |
-
->with($this->callback(function ($value) use ($expectedMessage) {
|
54 |
-
return $value instanceof \Swift_Message
|
55 |
-
&& $value->getSubject() === 'Emergency'
|
56 |
-
&& $value === $expectedMessage;
|
57 |
-
}));
|
58 |
-
|
59 |
-
// Callback dynamically changes subject based on number of logged records
|
60 |
-
$callback = function ($content, array $records) use ($expectedMessage) {
|
61 |
-
$subject = count($records) > 0 ? 'Emergency' : 'Normal';
|
62 |
-
$expectedMessage->setSubject($subject);
|
63 |
-
|
64 |
-
return $expectedMessage;
|
65 |
-
};
|
66 |
-
$handler = new SwiftMailerHandler($this->mailer, $callback);
|
67 |
-
|
68 |
-
// Logging 1 record makes this an Emergency
|
69 |
-
$records = array(
|
70 |
-
$this->getRecord(Logger::EMERGENCY),
|
71 |
-
);
|
72 |
-
$handler->handleBatch($records);
|
73 |
-
}
|
74 |
-
|
75 |
-
public function testMessageSubjectFormatting()
|
76 |
-
{
|
77 |
-
// Wire Mailer to expect a specific Swift_Message with a customized Subject
|
78 |
-
$messageTemplate = new \Swift_Message();
|
79 |
-
$messageTemplate->setSubject('Alert: %level_name% %message%');
|
80 |
-
$receivedMessage = null;
|
81 |
-
|
82 |
-
$this->mailer->expects($this->once())
|
83 |
-
->method('send')
|
84 |
-
->with($this->callback(function ($value) use (&$receivedMessage) {
|
85 |
-
$receivedMessage = $value;
|
86 |
-
return true;
|
87 |
-
}));
|
88 |
-
|
89 |
-
$handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
|
90 |
-
|
91 |
-
$records = array(
|
92 |
-
$this->getRecord(Logger::EMERGENCY),
|
93 |
-
);
|
94 |
-
$handler->handleBatch($records);
|
95 |
-
|
96 |
-
$this->assertEquals('Alert: EMERGENCY test', $receivedMessage->getSubject());
|
97 |
-
}
|
98 |
-
|
99 |
-
public function testMessageHaveUniqueId()
|
100 |
-
{
|
101 |
-
$messageTemplate = new \Swift_Message();
|
102 |
-
$handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
|
103 |
-
|
104 |
-
$method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage');
|
105 |
-
$method->setAccessible(true);
|
106 |
-
$method->invokeArgs($handler, array($messageTemplate, array()));
|
107 |
-
|
108 |
-
$builtMessage1 = $method->invoke($handler, $messageTemplate, array());
|
109 |
-
$builtMessage2 = $method->invoke($handler, $messageTemplate, array());
|
110 |
-
|
111 |
-
$this->assertFalse($builtMessage1->getId() === $builtMessage2->getId(), 'Two different messages have the same id');
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Handler\SyslogHandler::__construct
|
20 |
-
*/
|
21 |
-
public function testConstruct()
|
22 |
-
{
|
23 |
-
$handler = new SyslogHandler('test');
|
24 |
-
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
25 |
-
|
26 |
-
$handler = new SyslogHandler('test', LOG_USER);
|
27 |
-
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
28 |
-
|
29 |
-
$handler = new SyslogHandler('test', 'user');
|
30 |
-
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
31 |
-
|
32 |
-
$handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
|
33 |
-
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @covers Monolog\Handler\SyslogHandler::__construct
|
38 |
-
*/
|
39 |
-
public function testConstructInvalidFacility()
|
40 |
-
{
|
41 |
-
$this->setExpectedException('UnexpectedValueException');
|
42 |
-
$handler = new SyslogHandler('test', 'unknown');
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @requires extension sockets
|
18 |
-
*/
|
19 |
-
class SyslogUdpHandlerTest extends TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @expectedException UnexpectedValueException
|
23 |
-
*/
|
24 |
-
public function testWeValidateFacilities()
|
25 |
-
{
|
26 |
-
$handler = new SyslogUdpHandler("ip", null, "invalidFacility");
|
27 |
-
}
|
28 |
-
|
29 |
-
public function testWeSplitIntoLines()
|
30 |
-
{
|
31 |
-
$time = '2014-01-07T12:34';
|
32 |
-
$pid = getmypid();
|
33 |
-
$host = gethostname();
|
34 |
-
|
35 |
-
$handler = $this->getMockBuilder('\Monolog\Handler\SyslogUdpHandler')
|
36 |
-
->setConstructorArgs(array("127.0.0.1", 514, "authpriv"))
|
37 |
-
->setMethods(array('getDateTime'))
|
38 |
-
->getMock();
|
39 |
-
|
40 |
-
$handler->method('getDateTime')
|
41 |
-
->willReturn($time);
|
42 |
-
|
43 |
-
$handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
|
44 |
-
|
45 |
-
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
|
46 |
-
$socket->expects($this->at(0))
|
47 |
-
->method('write')
|
48 |
-
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
|
49 |
-
$socket->expects($this->at(1))
|
50 |
-
->method('write')
|
51 |
-
->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 $time $host php $pid - - ");
|
52 |
-
|
53 |
-
$handler->setSocket($socket);
|
54 |
-
|
55 |
-
$handler->handle($this->getRecordWithMessage("hej\nlol"));
|
56 |
-
}
|
57 |
-
|
58 |
-
public function testSplitWorksOnEmptyMsg()
|
59 |
-
{
|
60 |
-
$handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
|
61 |
-
$handler->setFormatter($this->getIdentityFormatter());
|
62 |
-
|
63 |
-
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
|
64 |
-
$socket->expects($this->never())
|
65 |
-
->method('write');
|
66 |
-
|
67 |
-
$handler->setSocket($socket);
|
68 |
-
|
69 |
-
$handler->handle($this->getRecordWithMessage(null));
|
70 |
-
}
|
71 |
-
|
72 |
-
protected function getRecordWithMessage($msg)
|
73 |
-
{
|
74 |
-
return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
|
75 |
-
}
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @covers Monolog\Handler\TestHandler
|
19 |
-
*/
|
20 |
-
class TestHandlerTest extends TestCase
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @dataProvider methodProvider
|
24 |
-
*/
|
25 |
-
public function testHandler($method, $level)
|
26 |
-
{
|
27 |
-
$handler = new TestHandler;
|
28 |
-
$record = $this->getRecord($level, 'test'.$method);
|
29 |
-
$this->assertFalse($handler->hasRecords($level));
|
30 |
-
$this->assertFalse($handler->hasRecord($record, $level));
|
31 |
-
$this->assertFalse($handler->{'has'.$method}($record), 'has'.$method);
|
32 |
-
$this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
|
33 |
-
$this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
|
34 |
-
return true;
|
35 |
-
}), 'has'.$method.'ThatPasses');
|
36 |
-
$this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
|
37 |
-
$this->assertFalse($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
|
38 |
-
$handler->handle($record);
|
39 |
-
|
40 |
-
$this->assertFalse($handler->{'has'.$method}('bar'), 'has'.$method);
|
41 |
-
$this->assertTrue($handler->hasRecords($level));
|
42 |
-
$this->assertTrue($handler->hasRecord($record, $level));
|
43 |
-
$this->assertTrue($handler->{'has'.$method}($record), 'has'.$method);
|
44 |
-
$this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method);
|
45 |
-
$this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
|
46 |
-
$this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
|
47 |
-
return true;
|
48 |
-
}), 'has'.$method.'ThatPasses');
|
49 |
-
$this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
|
50 |
-
$this->assertTrue($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
|
51 |
-
|
52 |
-
$records = $handler->getRecords();
|
53 |
-
unset($records[0]['formatted']);
|
54 |
-
$this->assertEquals(array($record), $records);
|
55 |
-
}
|
56 |
-
|
57 |
-
public function testHandlerAssertEmptyContext() {
|
58 |
-
$handler = new TestHandler;
|
59 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array());
|
60 |
-
$this->assertFalse($handler->hasWarning(array(
|
61 |
-
'message' => 'test',
|
62 |
-
'context' => array(),
|
63 |
-
)));
|
64 |
-
|
65 |
-
$handler->handle($record);
|
66 |
-
|
67 |
-
$this->assertTrue($handler->hasWarning(array(
|
68 |
-
'message' => 'test',
|
69 |
-
'context' => array(),
|
70 |
-
)));
|
71 |
-
$this->assertFalse($handler->hasWarning(array(
|
72 |
-
'message' => 'test',
|
73 |
-
'context' => array(
|
74 |
-
'foo' => 'bar'
|
75 |
-
),
|
76 |
-
)));
|
77 |
-
}
|
78 |
-
|
79 |
-
public function testHandlerAssertNonEmptyContext() {
|
80 |
-
$handler = new TestHandler;
|
81 |
-
$record = $this->getRecord(Logger::WARNING, 'test', array('foo' => 'bar'));
|
82 |
-
$this->assertFalse($handler->hasWarning(array(
|
83 |
-
'message' => 'test',
|
84 |
-
'context' => array(
|
85 |
-
'foo' => 'bar'
|
86 |
-
),
|
87 |
-
)));
|
88 |
-
|
89 |
-
$handler->handle($record);
|
90 |
-
|
91 |
-
$this->assertTrue($handler->hasWarning(array(
|
92 |
-
'message' => 'test',
|
93 |
-
'context' => array(
|
94 |
-
'foo' => 'bar'
|
95 |
-
),
|
96 |
-
)));
|
97 |
-
$this->assertFalse($handler->hasWarning(array(
|
98 |
-
'message' => 'test',
|
99 |
-
'context' => array(),
|
100 |
-
)));
|
101 |
-
}
|
102 |
-
|
103 |
-
public function methodProvider()
|
104 |
-
{
|
105 |
-
return array(
|
106 |
-
array('Emergency', Logger::EMERGENCY),
|
107 |
-
array('Alert' , Logger::ALERT),
|
108 |
-
array('Critical' , Logger::CRITICAL),
|
109 |
-
array('Error' , Logger::ERROR),
|
110 |
-
array('Warning' , Logger::WARNING),
|
111 |
-
array('Info' , Logger::INFO),
|
112 |
-
array('Notice' , Logger::NOTICE),
|
113 |
-
array('Debug' , Logger::DEBUG),
|
114 |
-
);
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Handler\SyslogUdp\UdpSocket;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @requires extension sockets
|
19 |
-
*/
|
20 |
-
class UdpSocketTest extends TestCase
|
21 |
-
{
|
22 |
-
public function testWeDoNotTruncateShortMessages()
|
23 |
-
{
|
24 |
-
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
25 |
-
|
26 |
-
$socket->expects($this->at(0))
|
27 |
-
->method('send')
|
28 |
-
->with("HEADER: The quick brown fox jumps over the lazy dog");
|
29 |
-
|
30 |
-
$socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testLongMessagesAreTruncated()
|
34 |
-
{
|
35 |
-
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
36 |
-
|
37 |
-
$truncatedString = str_repeat("derp", 16254).'d';
|
38 |
-
|
39 |
-
$socket->expects($this->exactly(1))
|
40 |
-
->method('send')
|
41 |
-
->with("HEADER" . $truncatedString);
|
42 |
-
|
43 |
-
$longString = str_repeat("derp", 20000);
|
44 |
-
|
45 |
-
$socket->write($longString, "HEADER");
|
46 |
-
}
|
47 |
-
|
48 |
-
public function testDoubleCloseDoesNotError()
|
49 |
-
{
|
50 |
-
$socket = new UdpSocket('127.0.0.1', 514);
|
51 |
-
$socket->close();
|
52 |
-
$socket->close();
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @expectedException LogicException
|
57 |
-
*/
|
58 |
-
public function testWriteAfterCloseErrors()
|
59 |
-
{
|
60 |
-
$socket = new UdpSocket('127.0.0.1', 514);
|
61 |
-
$socket->close();
|
62 |
-
$socket->write('foo', "HEADER");
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
class WhatFailureGroupHandlerTest extends TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::__construct
|
21 |
-
* @expectedException InvalidArgumentException
|
22 |
-
*/
|
23 |
-
public function testConstructorOnlyTakesHandler()
|
24 |
-
{
|
25 |
-
new WhatFailureGroupHandler(array(new TestHandler(), "foo"));
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::__construct
|
30 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::handle
|
31 |
-
*/
|
32 |
-
public function testHandle()
|
33 |
-
{
|
34 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
35 |
-
$handler = new WhatFailureGroupHandler($testHandlers);
|
36 |
-
$handler->handle($this->getRecord(Logger::DEBUG));
|
37 |
-
$handler->handle($this->getRecord(Logger::INFO));
|
38 |
-
foreach ($testHandlers as $test) {
|
39 |
-
$this->assertTrue($test->hasDebugRecords());
|
40 |
-
$this->assertTrue($test->hasInfoRecords());
|
41 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch
|
47 |
-
*/
|
48 |
-
public function testHandleBatch()
|
49 |
-
{
|
50 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
51 |
-
$handler = new WhatFailureGroupHandler($testHandlers);
|
52 |
-
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
53 |
-
foreach ($testHandlers as $test) {
|
54 |
-
$this->assertTrue($test->hasDebugRecords());
|
55 |
-
$this->assertTrue($test->hasInfoRecords());
|
56 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::isHandling
|
62 |
-
*/
|
63 |
-
public function testIsHandling()
|
64 |
-
{
|
65 |
-
$testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
|
66 |
-
$handler = new WhatFailureGroupHandler($testHandlers);
|
67 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
|
68 |
-
$this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
|
69 |
-
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::handle
|
74 |
-
*/
|
75 |
-
public function testHandleUsesProcessors()
|
76 |
-
{
|
77 |
-
$test = new TestHandler();
|
78 |
-
$handler = new WhatFailureGroupHandler(array($test));
|
79 |
-
$handler->pushProcessor(function ($record) {
|
80 |
-
$record['extra']['foo'] = true;
|
81 |
-
|
82 |
-
return $record;
|
83 |
-
});
|
84 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
85 |
-
$this->assertTrue($test->hasWarningRecords());
|
86 |
-
$records = $test->getRecords();
|
87 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch
|
92 |
-
*/
|
93 |
-
public function testHandleBatchUsesProcessors()
|
94 |
-
{
|
95 |
-
$testHandlers = array(new TestHandler(), new TestHandler());
|
96 |
-
$handler = new WhatFailureGroupHandler($testHandlers);
|
97 |
-
$handler->pushProcessor(function ($record) {
|
98 |
-
$record['extra']['foo'] = true;
|
99 |
-
|
100 |
-
return $record;
|
101 |
-
});
|
102 |
-
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
103 |
-
foreach ($testHandlers as $test) {
|
104 |
-
$this->assertTrue($test->hasDebugRecords());
|
105 |
-
$this->assertTrue($test->hasInfoRecords());
|
106 |
-
$this->assertTrue(count($test->getRecords()) === 2);
|
107 |
-
$records = $test->getRecords();
|
108 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
109 |
-
$this->assertTrue($records[1]['extra']['foo']);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @covers Monolog\Handler\WhatFailureGroupHandler::handle
|
115 |
-
*/
|
116 |
-
public function testHandleException()
|
117 |
-
{
|
118 |
-
$test = new TestHandler();
|
119 |
-
$exception = new ExceptionTestHandler();
|
120 |
-
$handler = new WhatFailureGroupHandler(array($exception, $test, $exception));
|
121 |
-
$handler->pushProcessor(function ($record) {
|
122 |
-
$record['extra']['foo'] = true;
|
123 |
-
|
124 |
-
return $record;
|
125 |
-
});
|
126 |
-
$handler->handle($this->getRecord(Logger::WARNING));
|
127 |
-
$this->assertTrue($test->hasWarningRecords());
|
128 |
-
$records = $test->getRecords();
|
129 |
-
$this->assertTrue($records[0]['extra']['foo']);
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
class ExceptionTestHandler extends TestHandler
|
134 |
-
{
|
135 |
-
/**
|
136 |
-
* {@inheritdoc}
|
137 |
-
*/
|
138 |
-
public function handle(array $record)
|
139 |
-
{
|
140 |
-
parent::handle($record);
|
141 |
-
|
142 |
-
throw new \Exception("ExceptionTestHandler::handle");
|
143 |
-
}
|
144 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* This file is part of the Monolog package.
|
4 |
-
*
|
5 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
6 |
-
*
|
7 |
-
* For the full copyright and license information, please view the LICENSE
|
8 |
-
* file that was distributed with this source code.
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace Monolog\Handler;
|
12 |
-
|
13 |
-
use Monolog\TestCase;
|
14 |
-
|
15 |
-
class ZendMonitorHandlerTest extends TestCase
|
16 |
-
{
|
17 |
-
protected $zendMonitorHandler;
|
18 |
-
|
19 |
-
public function setUp()
|
20 |
-
{
|
21 |
-
if (!function_exists('zend_monitor_custom_event')) {
|
22 |
-
$this->markTestSkipped('ZendServer is not installed');
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @covers Monolog\Handler\ZendMonitorHandler::write
|
28 |
-
*/
|
29 |
-
public function testWrite()
|
30 |
-
{
|
31 |
-
$record = $this->getRecord();
|
32 |
-
$formatterResult = array(
|
33 |
-
'message' => $record['message'],
|
34 |
-
);
|
35 |
-
|
36 |
-
$zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
|
37 |
-
->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
|
38 |
-
->getMock();
|
39 |
-
|
40 |
-
$formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
|
41 |
-
->disableOriginalConstructor()
|
42 |
-
->getMock();
|
43 |
-
|
44 |
-
$formatterMock->expects($this->once())
|
45 |
-
->method('format')
|
46 |
-
->will($this->returnValue($formatterResult));
|
47 |
-
|
48 |
-
$zendMonitor->expects($this->once())
|
49 |
-
->method('getDefaultFormatter')
|
50 |
-
->will($this->returnValue($formatterMock));
|
51 |
-
|
52 |
-
$levelMap = $zendMonitor->getLevelMap();
|
53 |
-
|
54 |
-
$zendMonitor->expects($this->once())
|
55 |
-
->method('writeZendMonitorCustomEvent')
|
56 |
-
->with($levelMap[$record['level']], $record['message'], $formatterResult);
|
57 |
-
|
58 |
-
$zendMonitor->handle($record);
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
|
63 |
-
*/
|
64 |
-
public function testGetDefaultFormatterReturnsNormalizerFormatter()
|
65 |
-
{
|
66 |
-
$zendMonitor = new ZendMonitorHandler();
|
67 |
-
$this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
|
68 |
-
}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/LoggerTest.php
DELETED
@@ -1,690 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Monolog\Processor\WebProcessor;
|
15 |
-
use Monolog\Handler\TestHandler;
|
16 |
-
|
17 |
-
class LoggerTest extends \PHPUnit_Framework_TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @covers Monolog\Logger::getName
|
21 |
-
*/
|
22 |
-
public function testGetName()
|
23 |
-
{
|
24 |
-
$logger = new Logger('foo');
|
25 |
-
$this->assertEquals('foo', $logger->getName());
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @covers Monolog\Logger::getLevelName
|
30 |
-
*/
|
31 |
-
public function testGetLevelName()
|
32 |
-
{
|
33 |
-
$this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @covers Monolog\Logger::withName
|
38 |
-
*/
|
39 |
-
public function testWithName()
|
40 |
-
{
|
41 |
-
$first = new Logger('first', array($handler = new TestHandler()));
|
42 |
-
$second = $first->withName('second');
|
43 |
-
|
44 |
-
$this->assertSame('first', $first->getName());
|
45 |
-
$this->assertSame('second', $second->getName());
|
46 |
-
$this->assertSame($handler, $second->popHandler());
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @covers Monolog\Logger::toMonologLevel
|
51 |
-
*/
|
52 |
-
public function testConvertPSR3ToMonologLevel()
|
53 |
-
{
|
54 |
-
$this->assertEquals(Logger::toMonologLevel('debug'), 100);
|
55 |
-
$this->assertEquals(Logger::toMonologLevel('info'), 200);
|
56 |
-
$this->assertEquals(Logger::toMonologLevel('notice'), 250);
|
57 |
-
$this->assertEquals(Logger::toMonologLevel('warning'), 300);
|
58 |
-
$this->assertEquals(Logger::toMonologLevel('error'), 400);
|
59 |
-
$this->assertEquals(Logger::toMonologLevel('critical'), 500);
|
60 |
-
$this->assertEquals(Logger::toMonologLevel('alert'), 550);
|
61 |
-
$this->assertEquals(Logger::toMonologLevel('emergency'), 600);
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @covers Monolog\Logger::getLevelName
|
66 |
-
* @expectedException InvalidArgumentException
|
67 |
-
*/
|
68 |
-
public function testGetLevelNameThrows()
|
69 |
-
{
|
70 |
-
Logger::getLevelName(5);
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* @covers Monolog\Logger::__construct
|
75 |
-
*/
|
76 |
-
public function testChannel()
|
77 |
-
{
|
78 |
-
$logger = new Logger('foo');
|
79 |
-
$handler = new TestHandler;
|
80 |
-
$logger->pushHandler($handler);
|
81 |
-
$logger->addWarning('test');
|
82 |
-
list($record) = $handler->getRecords();
|
83 |
-
$this->assertEquals('foo', $record['channel']);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @covers Monolog\Logger::addRecord
|
88 |
-
*/
|
89 |
-
public function testLog()
|
90 |
-
{
|
91 |
-
$logger = new Logger(__METHOD__);
|
92 |
-
|
93 |
-
$handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'));
|
94 |
-
$handler->expects($this->once())
|
95 |
-
->method('handle');
|
96 |
-
$logger->pushHandler($handler);
|
97 |
-
|
98 |
-
$this->assertTrue($logger->addWarning('test'));
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @covers Monolog\Logger::addRecord
|
103 |
-
*/
|
104 |
-
public function testLogNotHandled()
|
105 |
-
{
|
106 |
-
$logger = new Logger(__METHOD__);
|
107 |
-
|
108 |
-
$handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR));
|
109 |
-
$handler->expects($this->never())
|
110 |
-
->method('handle');
|
111 |
-
$logger->pushHandler($handler);
|
112 |
-
|
113 |
-
$this->assertFalse($logger->addWarning('test'));
|
114 |
-
}
|
115 |
-
|
116 |
-
public function testHandlersInCtor()
|
117 |
-
{
|
118 |
-
$handler1 = new TestHandler;
|
119 |
-
$handler2 = new TestHandler;
|
120 |
-
$logger = new Logger(__METHOD__, array($handler1, $handler2));
|
121 |
-
|
122 |
-
$this->assertEquals($handler1, $logger->popHandler());
|
123 |
-
$this->assertEquals($handler2, $logger->popHandler());
|
124 |
-
}
|
125 |
-
|
126 |
-
public function testProcessorsInCtor()
|
127 |
-
{
|
128 |
-
$processor1 = new WebProcessor;
|
129 |
-
$processor2 = new WebProcessor;
|
130 |
-
$logger = new Logger(__METHOD__, array(), array($processor1, $processor2));
|
131 |
-
|
132 |
-
$this->assertEquals($processor1, $logger->popProcessor());
|
133 |
-
$this->assertEquals($processor2, $logger->popProcessor());
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @covers Monolog\Logger::pushHandler
|
138 |
-
* @covers Monolog\Logger::popHandler
|
139 |
-
* @expectedException LogicException
|
140 |
-
*/
|
141 |
-
public function testPushPopHandler()
|
142 |
-
{
|
143 |
-
$logger = new Logger(__METHOD__);
|
144 |
-
$handler1 = new TestHandler;
|
145 |
-
$handler2 = new TestHandler;
|
146 |
-
|
147 |
-
$logger->pushHandler($handler1);
|
148 |
-
$logger->pushHandler($handler2);
|
149 |
-
|
150 |
-
$this->assertEquals($handler2, $logger->popHandler());
|
151 |
-
$this->assertEquals($handler1, $logger->popHandler());
|
152 |
-
$logger->popHandler();
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @covers Monolog\Logger::setHandlers
|
157 |
-
*/
|
158 |
-
public function testSetHandlers()
|
159 |
-
{
|
160 |
-
$logger = new Logger(__METHOD__);
|
161 |
-
$handler1 = new TestHandler;
|
162 |
-
$handler2 = new TestHandler;
|
163 |
-
|
164 |
-
$logger->pushHandler($handler1);
|
165 |
-
$logger->setHandlers(array($handler2));
|
166 |
-
|
167 |
-
// handler1 has been removed
|
168 |
-
$this->assertEquals(array($handler2), $logger->getHandlers());
|
169 |
-
|
170 |
-
$logger->setHandlers(array(
|
171 |
-
"AMapKey" => $handler1,
|
172 |
-
"Woop" => $handler2,
|
173 |
-
));
|
174 |
-
|
175 |
-
// Keys have been scrubbed
|
176 |
-
$this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* @covers Monolog\Logger::pushProcessor
|
181 |
-
* @covers Monolog\Logger::popProcessor
|
182 |
-
* @expectedException LogicException
|
183 |
-
*/
|
184 |
-
public function testPushPopProcessor()
|
185 |
-
{
|
186 |
-
$logger = new Logger(__METHOD__);
|
187 |
-
$processor1 = new WebProcessor;
|
188 |
-
$processor2 = new WebProcessor;
|
189 |
-
|
190 |
-
$logger->pushProcessor($processor1);
|
191 |
-
$logger->pushProcessor($processor2);
|
192 |
-
|
193 |
-
$this->assertEquals($processor2, $logger->popProcessor());
|
194 |
-
$this->assertEquals($processor1, $logger->popProcessor());
|
195 |
-
$logger->popProcessor();
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* @covers Monolog\Logger::pushProcessor
|
200 |
-
* @expectedException InvalidArgumentException
|
201 |
-
*/
|
202 |
-
public function testPushProcessorWithNonCallable()
|
203 |
-
{
|
204 |
-
$logger = new Logger(__METHOD__);
|
205 |
-
|
206 |
-
$logger->pushProcessor(new \stdClass());
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* @covers Monolog\Logger::addRecord
|
211 |
-
*/
|
212 |
-
public function testProcessorsAreExecuted()
|
213 |
-
{
|
214 |
-
$logger = new Logger(__METHOD__);
|
215 |
-
$handler = new TestHandler;
|
216 |
-
$logger->pushHandler($handler);
|
217 |
-
$logger->pushProcessor(function ($record) {
|
218 |
-
$record['extra']['win'] = true;
|
219 |
-
|
220 |
-
return $record;
|
221 |
-
});
|
222 |
-
$logger->addError('test');
|
223 |
-
list($record) = $handler->getRecords();
|
224 |
-
$this->assertTrue($record['extra']['win']);
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* @covers Monolog\Logger::addRecord
|
229 |
-
*/
|
230 |
-
public function testProcessorsAreCalledOnlyOnce()
|
231 |
-
{
|
232 |
-
$logger = new Logger(__METHOD__);
|
233 |
-
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
234 |
-
$handler->expects($this->any())
|
235 |
-
->method('isHandling')
|
236 |
-
->will($this->returnValue(true))
|
237 |
-
;
|
238 |
-
$handler->expects($this->any())
|
239 |
-
->method('handle')
|
240 |
-
->will($this->returnValue(true))
|
241 |
-
;
|
242 |
-
$logger->pushHandler($handler);
|
243 |
-
|
244 |
-
$processor = $this->getMockBuilder('Monolog\Processor\WebProcessor')
|
245 |
-
->disableOriginalConstructor()
|
246 |
-
->setMethods(array('__invoke'))
|
247 |
-
->getMock()
|
248 |
-
;
|
249 |
-
$processor->expects($this->once())
|
250 |
-
->method('__invoke')
|
251 |
-
->will($this->returnArgument(0))
|
252 |
-
;
|
253 |
-
$logger->pushProcessor($processor);
|
254 |
-
|
255 |
-
$logger->addError('test');
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* @covers Monolog\Logger::addRecord
|
260 |
-
*/
|
261 |
-
public function testProcessorsNotCalledWhenNotHandled()
|
262 |
-
{
|
263 |
-
$logger = new Logger(__METHOD__);
|
264 |
-
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
265 |
-
$handler->expects($this->once())
|
266 |
-
->method('isHandling')
|
267 |
-
->will($this->returnValue(false))
|
268 |
-
;
|
269 |
-
$logger->pushHandler($handler);
|
270 |
-
$that = $this;
|
271 |
-
$logger->pushProcessor(function ($record) use ($that) {
|
272 |
-
$that->fail('The processor should not be called');
|
273 |
-
});
|
274 |
-
$logger->addAlert('test');
|
275 |
-
}
|
276 |
-
|
277 |
-
/**
|
278 |
-
* @covers Monolog\Logger::addRecord
|
279 |
-
*/
|
280 |
-
public function testHandlersNotCalledBeforeFirstHandling()
|
281 |
-
{
|
282 |
-
$logger = new Logger(__METHOD__);
|
283 |
-
|
284 |
-
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
285 |
-
$handler1->expects($this->never())
|
286 |
-
->method('isHandling')
|
287 |
-
->will($this->returnValue(false))
|
288 |
-
;
|
289 |
-
$handler1->expects($this->once())
|
290 |
-
->method('handle')
|
291 |
-
->will($this->returnValue(false))
|
292 |
-
;
|
293 |
-
$logger->pushHandler($handler1);
|
294 |
-
|
295 |
-
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
296 |
-
$handler2->expects($this->once())
|
297 |
-
->method('isHandling')
|
298 |
-
->will($this->returnValue(true))
|
299 |
-
;
|
300 |
-
$handler2->expects($this->once())
|
301 |
-
->method('handle')
|
302 |
-
->will($this->returnValue(false))
|
303 |
-
;
|
304 |
-
$logger->pushHandler($handler2);
|
305 |
-
|
306 |
-
$handler3 = $this->getMock('Monolog\Handler\HandlerInterface');
|
307 |
-
$handler3->expects($this->once())
|
308 |
-
->method('isHandling')
|
309 |
-
->will($this->returnValue(false))
|
310 |
-
;
|
311 |
-
$handler3->expects($this->never())
|
312 |
-
->method('handle')
|
313 |
-
;
|
314 |
-
$logger->pushHandler($handler3);
|
315 |
-
|
316 |
-
$logger->debug('test');
|
317 |
-
}
|
318 |
-
|
319 |
-
/**
|
320 |
-
* @covers Monolog\Logger::addRecord
|
321 |
-
*/
|
322 |
-
public function testHandlersNotCalledBeforeFirstHandlingWithAssocArray()
|
323 |
-
{
|
324 |
-
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
325 |
-
$handler1->expects($this->never())
|
326 |
-
->method('isHandling')
|
327 |
-
->will($this->returnValue(false))
|
328 |
-
;
|
329 |
-
$handler1->expects($this->once())
|
330 |
-
->method('handle')
|
331 |
-
->will($this->returnValue(false))
|
332 |
-
;
|
333 |
-
|
334 |
-
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
335 |
-
$handler2->expects($this->once())
|
336 |
-
->method('isHandling')
|
337 |
-
->will($this->returnValue(true))
|
338 |
-
;
|
339 |
-
$handler2->expects($this->once())
|
340 |
-
->method('handle')
|
341 |
-
->will($this->returnValue(false))
|
342 |
-
;
|
343 |
-
|
344 |
-
$handler3 = $this->getMock('Monolog\Handler\HandlerInterface');
|
345 |
-
$handler3->expects($this->once())
|
346 |
-
->method('isHandling')
|
347 |
-
->will($this->returnValue(false))
|
348 |
-
;
|
349 |
-
$handler3->expects($this->never())
|
350 |
-
->method('handle')
|
351 |
-
;
|
352 |
-
|
353 |
-
$logger = new Logger(__METHOD__, array('last' => $handler3, 'second' => $handler2, 'first' => $handler1));
|
354 |
-
|
355 |
-
$logger->debug('test');
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* @covers Monolog\Logger::addRecord
|
360 |
-
*/
|
361 |
-
public function testBubblingWhenTheHandlerReturnsFalse()
|
362 |
-
{
|
363 |
-
$logger = new Logger(__METHOD__);
|
364 |
-
|
365 |
-
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
366 |
-
$handler1->expects($this->any())
|
367 |
-
->method('isHandling')
|
368 |
-
->will($this->returnValue(true))
|
369 |
-
;
|
370 |
-
$handler1->expects($this->once())
|
371 |
-
->method('handle')
|
372 |
-
->will($this->returnValue(false))
|
373 |
-
;
|
374 |
-
$logger->pushHandler($handler1);
|
375 |
-
|
376 |
-
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
377 |
-
$handler2->expects($this->any())
|
378 |
-
->method('isHandling')
|
379 |
-
->will($this->returnValue(true))
|
380 |
-
;
|
381 |
-
$handler2->expects($this->once())
|
382 |
-
->method('handle')
|
383 |
-
->will($this->returnValue(false))
|
384 |
-
;
|
385 |
-
$logger->pushHandler($handler2);
|
386 |
-
|
387 |
-
$logger->debug('test');
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
* @covers Monolog\Logger::addRecord
|
392 |
-
*/
|
393 |
-
public function testNotBubblingWhenTheHandlerReturnsTrue()
|
394 |
-
{
|
395 |
-
$logger = new Logger(__METHOD__);
|
396 |
-
|
397 |
-
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
398 |
-
$handler1->expects($this->any())
|
399 |
-
->method('isHandling')
|
400 |
-
->will($this->returnValue(true))
|
401 |
-
;
|
402 |
-
$handler1->expects($this->never())
|
403 |
-
->method('handle')
|
404 |
-
;
|
405 |
-
$logger->pushHandler($handler1);
|
406 |
-
|
407 |
-
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
408 |
-
$handler2->expects($this->any())
|
409 |
-
->method('isHandling')
|
410 |
-
->will($this->returnValue(true))
|
411 |
-
;
|
412 |
-
$handler2->expects($this->once())
|
413 |
-
->method('handle')
|
414 |
-
->will($this->returnValue(true))
|
415 |
-
;
|
416 |
-
$logger->pushHandler($handler2);
|
417 |
-
|
418 |
-
$logger->debug('test');
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* @covers Monolog\Logger::isHandling
|
423 |
-
*/
|
424 |
-
public function testIsHandling()
|
425 |
-
{
|
426 |
-
$logger = new Logger(__METHOD__);
|
427 |
-
|
428 |
-
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
429 |
-
$handler1->expects($this->any())
|
430 |
-
->method('isHandling')
|
431 |
-
->will($this->returnValue(false))
|
432 |
-
;
|
433 |
-
|
434 |
-
$logger->pushHandler($handler1);
|
435 |
-
$this->assertFalse($logger->isHandling(Logger::DEBUG));
|
436 |
-
|
437 |
-
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
438 |
-
$handler2->expects($this->any())
|
439 |
-
->method('isHandling')
|
440 |
-
->will($this->returnValue(true))
|
441 |
-
;
|
442 |
-
|
443 |
-
$logger->pushHandler($handler2);
|
444 |
-
$this->assertTrue($logger->isHandling(Logger::DEBUG));
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* @dataProvider logMethodProvider
|
449 |
-
* @covers Monolog\Logger::addDebug
|
450 |
-
* @covers Monolog\Logger::addInfo
|
451 |
-
* @covers Monolog\Logger::addNotice
|
452 |
-
* @covers Monolog\Logger::addWarning
|
453 |
-
* @covers Monolog\Logger::addError
|
454 |
-
* @covers Monolog\Logger::addCritical
|
455 |
-
* @covers Monolog\Logger::addAlert
|
456 |
-
* @covers Monolog\Logger::addEmergency
|
457 |
-
* @covers Monolog\Logger::debug
|
458 |
-
* @covers Monolog\Logger::info
|
459 |
-
* @covers Monolog\Logger::notice
|
460 |
-
* @covers Monolog\Logger::warn
|
461 |
-
* @covers Monolog\Logger::err
|
462 |
-
* @covers Monolog\Logger::crit
|
463 |
-
* @covers Monolog\Logger::alert
|
464 |
-
* @covers Monolog\Logger::emerg
|
465 |
-
*/
|
466 |
-
public function testLogMethods($method, $expectedLevel)
|
467 |
-
{
|
468 |
-
$logger = new Logger('foo');
|
469 |
-
$handler = new TestHandler;
|
470 |
-
$logger->pushHandler($handler);
|
471 |
-
$logger->{$method}('test');
|
472 |
-
list($record) = $handler->getRecords();
|
473 |
-
$this->assertEquals($expectedLevel, $record['level']);
|
474 |
-
}
|
475 |
-
|
476 |
-
public function logMethodProvider()
|
477 |
-
{
|
478 |
-
return array(
|
479 |
-
// monolog methods
|
480 |
-
array('addDebug', Logger::DEBUG),
|
481 |
-
array('addInfo', Logger::INFO),
|
482 |
-
array('addNotice', Logger::NOTICE),
|
483 |
-
array('addWarning', Logger::WARNING),
|
484 |
-
array('addError', Logger::ERROR),
|
485 |
-
array('addCritical', Logger::CRITICAL),
|
486 |
-
array('addAlert', Logger::ALERT),
|
487 |
-
array('addEmergency', Logger::EMERGENCY),
|
488 |
-
|
489 |
-
// ZF/Sf2 compat methods
|
490 |
-
array('debug', Logger::DEBUG),
|
491 |
-
array('info', Logger::INFO),
|
492 |
-
array('notice', Logger::NOTICE),
|
493 |
-
array('warn', Logger::WARNING),
|
494 |
-
array('err', Logger::ERROR),
|
495 |
-
array('crit', Logger::CRITICAL),
|
496 |
-
array('alert', Logger::ALERT),
|
497 |
-
array('emerg', Logger::EMERGENCY),
|
498 |
-
);
|
499 |
-
}
|
500 |
-
|
501 |
-
/**
|
502 |
-
* @dataProvider setTimezoneProvider
|
503 |
-
* @covers Monolog\Logger::setTimezone
|
504 |
-
*/
|
505 |
-
public function testSetTimezone($tz)
|
506 |
-
{
|
507 |
-
Logger::setTimezone($tz);
|
508 |
-
$logger = new Logger('foo');
|
509 |
-
$handler = new TestHandler;
|
510 |
-
$logger->pushHandler($handler);
|
511 |
-
$logger->info('test');
|
512 |
-
list($record) = $handler->getRecords();
|
513 |
-
$this->assertEquals($tz, $record['datetime']->getTimezone());
|
514 |
-
}
|
515 |
-
|
516 |
-
public function setTimezoneProvider()
|
517 |
-
{
|
518 |
-
return array_map(
|
519 |
-
function ($tz) { return array(new \DateTimeZone($tz)); },
|
520 |
-
\DateTimeZone::listIdentifiers()
|
521 |
-
);
|
522 |
-
}
|
523 |
-
|
524 |
-
/**
|
525 |
-
* @dataProvider useMicrosecondTimestampsProvider
|
526 |
-
* @covers Monolog\Logger::useMicrosecondTimestamps
|
527 |
-
* @covers Monolog\Logger::addRecord
|
528 |
-
*/
|
529 |
-
public function testUseMicrosecondTimestamps($micro, $assert)
|
530 |
-
{
|
531 |
-
$logger = new Logger('foo');
|
532 |
-
$logger->useMicrosecondTimestamps($micro);
|
533 |
-
$handler = new TestHandler;
|
534 |
-
$logger->pushHandler($handler);
|
535 |
-
$logger->info('test');
|
536 |
-
list($record) = $handler->getRecords();
|
537 |
-
$this->{$assert}('000000', $record['datetime']->format('u'));
|
538 |
-
}
|
539 |
-
|
540 |
-
public function useMicrosecondTimestampsProvider()
|
541 |
-
{
|
542 |
-
return array(
|
543 |
-
// this has a very small chance of a false negative (1/10^6)
|
544 |
-
'with microseconds' => array(true, 'assertNotSame'),
|
545 |
-
'without microseconds' => array(false, PHP_VERSION_ID >= 70100 ? 'assertNotSame' : 'assertSame'),
|
546 |
-
);
|
547 |
-
}
|
548 |
-
|
549 |
-
/**
|
550 |
-
* @covers Monolog\Logger::setExceptionHandler
|
551 |
-
*/
|
552 |
-
public function testSetExceptionHandler()
|
553 |
-
{
|
554 |
-
$logger = new Logger(__METHOD__);
|
555 |
-
$this->assertNull($logger->getExceptionHandler());
|
556 |
-
$callback = function ($ex) {
|
557 |
-
};
|
558 |
-
$logger->setExceptionHandler($callback);
|
559 |
-
$this->assertEquals($callback, $logger->getExceptionHandler());
|
560 |
-
}
|
561 |
-
|
562 |
-
/**
|
563 |
-
* @covers Monolog\Logger::setExceptionHandler
|
564 |
-
* @expectedException InvalidArgumentException
|
565 |
-
*/
|
566 |
-
public function testBadExceptionHandlerType()
|
567 |
-
{
|
568 |
-
$logger = new Logger(__METHOD__);
|
569 |
-
$logger->setExceptionHandler(false);
|
570 |
-
}
|
571 |
-
|
572 |
-
/**
|
573 |
-
* @covers Monolog\Logger::handleException
|
574 |
-
* @expectedException Exception
|
575 |
-
*/
|
576 |
-
public function testDefaultHandleException()
|
577 |
-
{
|
578 |
-
$logger = new Logger(__METHOD__);
|
579 |
-
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
580 |
-
$handler->expects($this->any())
|
581 |
-
->method('isHandling')
|
582 |
-
->will($this->returnValue(true))
|
583 |
-
;
|
584 |
-
$handler->expects($this->any())
|
585 |
-
->method('handle')
|
586 |
-
->will($this->throwException(new \Exception('Some handler exception')))
|
587 |
-
;
|
588 |
-
$logger->pushHandler($handler);
|
589 |
-
$logger->info('test');
|
590 |
-
}
|
591 |
-
|
592 |
-
/**
|
593 |
-
* @covers Monolog\Logger::handleException
|
594 |
-
* @covers Monolog\Logger::addRecord
|
595 |
-
*/
|
596 |
-
public function testCustomHandleException()
|
597 |
-
{
|
598 |
-
$logger = new Logger(__METHOD__);
|
599 |
-
$that = $this;
|
600 |
-
$logger->setExceptionHandler(function ($e, $record) use ($that) {
|
601 |
-
$that->assertEquals($e->getMessage(), 'Some handler exception');
|
602 |
-
$that->assertTrue(is_array($record));
|
603 |
-
$that->assertEquals($record['message'], 'test');
|
604 |
-
});
|
605 |
-
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
606 |
-
$handler->expects($this->any())
|
607 |
-
->method('isHandling')
|
608 |
-
->will($this->returnValue(true))
|
609 |
-
;
|
610 |
-
$handler->expects($this->any())
|
611 |
-
->method('handle')
|
612 |
-
->will($this->throwException(new \Exception('Some handler exception')))
|
613 |
-
;
|
614 |
-
$logger->pushHandler($handler);
|
615 |
-
$logger->info('test');
|
616 |
-
}
|
617 |
-
|
618 |
-
public function testReset()
|
619 |
-
{
|
620 |
-
$logger = new Logger('app');
|
621 |
-
|
622 |
-
$testHandler = new Handler\TestHandler();
|
623 |
-
$bufferHandler = new Handler\BufferHandler($testHandler);
|
624 |
-
$groupHandler = new Handler\GroupHandler(array($bufferHandler));
|
625 |
-
$fingersCrossedHandler = new Handler\FingersCrossedHandler($groupHandler);
|
626 |
-
|
627 |
-
$logger->pushHandler($fingersCrossedHandler);
|
628 |
-
|
629 |
-
$processorUid1 = new Processor\UidProcessor(10);
|
630 |
-
$uid1 = $processorUid1->getUid();
|
631 |
-
$groupHandler->pushProcessor($processorUid1);
|
632 |
-
|
633 |
-
$processorUid2 = new Processor\UidProcessor(5);
|
634 |
-
$uid2 = $processorUid2->getUid();
|
635 |
-
$logger->pushProcessor($processorUid2);
|
636 |
-
|
637 |
-
$getProperty = function ($object, $property) {
|
638 |
-
$reflectionProperty = new \ReflectionProperty(get_class($object), $property);
|
639 |
-
$reflectionProperty->setAccessible(true);
|
640 |
-
|
641 |
-
return $reflectionProperty->getValue($object);
|
642 |
-
};
|
643 |
-
$that = $this;
|
644 |
-
$assertBufferOfBufferHandlerEmpty = function () use ($getProperty, $bufferHandler, $that) {
|
645 |
-
$that->assertEmpty($getProperty($bufferHandler, 'buffer'));
|
646 |
-
};
|
647 |
-
$assertBuffersEmpty = function() use ($assertBufferOfBufferHandlerEmpty, $getProperty, $fingersCrossedHandler, $that) {
|
648 |
-
$assertBufferOfBufferHandlerEmpty();
|
649 |
-
$that->assertEmpty($getProperty($fingersCrossedHandler, 'buffer'));
|
650 |
-
};
|
651 |
-
|
652 |
-
$logger->debug('debug');
|
653 |
-
$logger->reset();
|
654 |
-
$assertBuffersEmpty();
|
655 |
-
$this->assertFalse($testHandler->hasDebugRecords());
|
656 |
-
$this->assertFalse($testHandler->hasErrorRecords());
|
657 |
-
$this->assertNotSame($uid1, $uid1 = $processorUid1->getUid());
|
658 |
-
$this->assertNotSame($uid2, $uid2 = $processorUid2->getUid());
|
659 |
-
|
660 |
-
$logger->debug('debug');
|
661 |
-
$logger->error('error');
|
662 |
-
$logger->reset();
|
663 |
-
$assertBuffersEmpty();
|
664 |
-
$this->assertTrue($testHandler->hasDebugRecords());
|
665 |
-
$this->assertTrue($testHandler->hasErrorRecords());
|
666 |
-
$this->assertNotSame($uid1, $uid1 = $processorUid1->getUid());
|
667 |
-
$this->assertNotSame($uid2, $uid2 = $processorUid2->getUid());
|
668 |
-
|
669 |
-
$logger->info('info');
|
670 |
-
$this->assertNotEmpty($getProperty($fingersCrossedHandler, 'buffer'));
|
671 |
-
$assertBufferOfBufferHandlerEmpty();
|
672 |
-
$this->assertFalse($testHandler->hasInfoRecords());
|
673 |
-
|
674 |
-
$logger->reset();
|
675 |
-
$assertBuffersEmpty();
|
676 |
-
$this->assertFalse($testHandler->hasInfoRecords());
|
677 |
-
$this->assertNotSame($uid1, $uid1 = $processorUid1->getUid());
|
678 |
-
$this->assertNotSame($uid2, $uid2 = $processorUid2->getUid());
|
679 |
-
|
680 |
-
$logger->notice('notice');
|
681 |
-
$logger->emergency('emergency');
|
682 |
-
$logger->reset();
|
683 |
-
$assertBuffersEmpty();
|
684 |
-
$this->assertFalse($testHandler->hasInfoRecords());
|
685 |
-
$this->assertTrue($testHandler->hasNoticeRecords());
|
686 |
-
$this->assertTrue($testHandler->hasEmergencyRecords());
|
687 |
-
$this->assertNotSame($uid1, $processorUid1->getUid());
|
688 |
-
$this->assertNotSame($uid2, $processorUid2->getUid());
|
689 |
-
}
|
690 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class GitProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\GitProcessor::__invoke
|
20 |
-
*/
|
21 |
-
public function testProcessor()
|
22 |
-
{
|
23 |
-
$processor = new GitProcessor();
|
24 |
-
$record = $processor($this->getRecord());
|
25 |
-
|
26 |
-
$this->assertArrayHasKey('git', $record['extra']);
|
27 |
-
$this->assertTrue(!is_array($record['extra']['git']['branch']));
|
28 |
-
}
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Acme;
|
13 |
-
|
14 |
-
class Tester
|
15 |
-
{
|
16 |
-
public function test($handler, $record)
|
17 |
-
{
|
18 |
-
$handler->handle($record);
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
-
function tester($handler, $record)
|
23 |
-
{
|
24 |
-
$handler->handle($record);
|
25 |
-
}
|
26 |
-
|
27 |
-
namespace Monolog\Processor;
|
28 |
-
|
29 |
-
use Monolog\Logger;
|
30 |
-
use Monolog\TestCase;
|
31 |
-
use Monolog\Handler\TestHandler;
|
32 |
-
|
33 |
-
class IntrospectionProcessorTest extends TestCase
|
34 |
-
{
|
35 |
-
public function getHandler()
|
36 |
-
{
|
37 |
-
$processor = new IntrospectionProcessor();
|
38 |
-
$handler = new TestHandler();
|
39 |
-
$handler->pushProcessor($processor);
|
40 |
-
|
41 |
-
return $handler;
|
42 |
-
}
|
43 |
-
|
44 |
-
public function testProcessorFromClass()
|
45 |
-
{
|
46 |
-
$handler = $this->getHandler();
|
47 |
-
$tester = new \Acme\Tester;
|
48 |
-
$tester->test($handler, $this->getRecord());
|
49 |
-
list($record) = $handler->getRecords();
|
50 |
-
$this->assertEquals(__FILE__, $record['extra']['file']);
|
51 |
-
$this->assertEquals(18, $record['extra']['line']);
|
52 |
-
$this->assertEquals('Acme\Tester', $record['extra']['class']);
|
53 |
-
$this->assertEquals('test', $record['extra']['function']);
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testProcessorFromFunc()
|
57 |
-
{
|
58 |
-
$handler = $this->getHandler();
|
59 |
-
\Acme\tester($handler, $this->getRecord());
|
60 |
-
list($record) = $handler->getRecords();
|
61 |
-
$this->assertEquals(__FILE__, $record['extra']['file']);
|
62 |
-
$this->assertEquals(24, $record['extra']['line']);
|
63 |
-
$this->assertEquals(null, $record['extra']['class']);
|
64 |
-
$this->assertEquals('Acme\tester', $record['extra']['function']);
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testLevelTooLow()
|
68 |
-
{
|
69 |
-
$input = array(
|
70 |
-
'level' => Logger::DEBUG,
|
71 |
-
'extra' => array(),
|
72 |
-
);
|
73 |
-
|
74 |
-
$expected = $input;
|
75 |
-
|
76 |
-
$processor = new IntrospectionProcessor(Logger::CRITICAL);
|
77 |
-
$actual = $processor($input);
|
78 |
-
|
79 |
-
$this->assertEquals($expected, $actual);
|
80 |
-
}
|
81 |
-
|
82 |
-
public function testLevelEqual()
|
83 |
-
{
|
84 |
-
$input = array(
|
85 |
-
'level' => Logger::CRITICAL,
|
86 |
-
'extra' => array(),
|
87 |
-
);
|
88 |
-
|
89 |
-
$expected = $input;
|
90 |
-
$expected['extra'] = array(
|
91 |
-
'file' => null,
|
92 |
-
'line' => null,
|
93 |
-
'class' => 'ReflectionMethod',
|
94 |
-
'function' => 'invokeArgs',
|
95 |
-
);
|
96 |
-
|
97 |
-
$processor = new IntrospectionProcessor(Logger::CRITICAL);
|
98 |
-
$actual = $processor($input);
|
99 |
-
|
100 |
-
$this->assertEquals($expected, $actual);
|
101 |
-
}
|
102 |
-
|
103 |
-
public function testLevelHigher()
|
104 |
-
{
|
105 |
-
$input = array(
|
106 |
-
'level' => Logger::EMERGENCY,
|
107 |
-
'extra' => array(),
|
108 |
-
);
|
109 |
-
|
110 |
-
$expected = $input;
|
111 |
-
$expected['extra'] = array(
|
112 |
-
'file' => null,
|
113 |
-
'line' => null,
|
114 |
-
'class' => 'ReflectionMethod',
|
115 |
-
'function' => 'invokeArgs',
|
116 |
-
);
|
117 |
-
|
118 |
-
$processor = new IntrospectionProcessor(Logger::CRITICAL);
|
119 |
-
$actual = $processor($input);
|
120 |
-
|
121 |
-
$this->assertEquals($expected, $actual);
|
122 |
-
}
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class MemoryPeakUsageProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
|
20 |
-
* @covers Monolog\Processor\MemoryProcessor::formatBytes
|
21 |
-
*/
|
22 |
-
public function testProcessor()
|
23 |
-
{
|
24 |
-
$processor = new MemoryPeakUsageProcessor();
|
25 |
-
$record = $processor($this->getRecord());
|
26 |
-
$this->assertArrayHasKey('memory_peak_usage', $record['extra']);
|
27 |
-
$this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']);
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
|
32 |
-
* @covers Monolog\Processor\MemoryProcessor::formatBytes
|
33 |
-
*/
|
34 |
-
public function testProcessorWithoutFormatting()
|
35 |
-
{
|
36 |
-
$processor = new MemoryPeakUsageProcessor(true, false);
|
37 |
-
$record = $processor($this->getRecord());
|
38 |
-
$this->assertArrayHasKey('memory_peak_usage', $record['extra']);
|
39 |
-
$this->assertInternalType('int', $record['extra']['memory_peak_usage']);
|
40 |
-
$this->assertGreaterThan(0, $record['extra']['memory_peak_usage']);
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class MemoryUsageProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\MemoryUsageProcessor::__invoke
|
20 |
-
* @covers Monolog\Processor\MemoryProcessor::formatBytes
|
21 |
-
*/
|
22 |
-
public function testProcessor()
|
23 |
-
{
|
24 |
-
$processor = new MemoryUsageProcessor();
|
25 |
-
$record = $processor($this->getRecord());
|
26 |
-
$this->assertArrayHasKey('memory_usage', $record['extra']);
|
27 |
-
$this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']);
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @covers Monolog\Processor\MemoryUsageProcessor::__invoke
|
32 |
-
* @covers Monolog\Processor\MemoryProcessor::formatBytes
|
33 |
-
*/
|
34 |
-
public function testProcessorWithoutFormatting()
|
35 |
-
{
|
36 |
-
$processor = new MemoryUsageProcessor(true, false);
|
37 |
-
$record = $processor($this->getRecord());
|
38 |
-
$this->assertArrayHasKey('memory_usage', $record['extra']);
|
39 |
-
$this->assertInternalType('int', $record['extra']['memory_usage']);
|
40 |
-
$this->assertGreaterThan(0, $record['extra']['memory_usage']);
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/MercurialProcessorTest.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jonathan A. Schweder <jonathanschweder@gmail.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class MercurialProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\MercurialProcessor::__invoke
|
20 |
-
*/
|
21 |
-
public function testProcessor()
|
22 |
-
{
|
23 |
-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
24 |
-
exec("where hg 2>NUL", $output, $result);
|
25 |
-
} else {
|
26 |
-
exec("which hg 2>/dev/null >/dev/null", $output, $result);
|
27 |
-
}
|
28 |
-
if ($result != 0) {
|
29 |
-
$this->markTestSkipped('hg is missing');
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
|
33 |
-
`hg init`;
|
34 |
-
$processor = new MercurialProcessor();
|
35 |
-
$record = $processor($this->getRecord());
|
36 |
-
|
37 |
-
$this->assertArrayHasKey('hg', $record['extra']);
|
38 |
-
$this->assertTrue(!is_array($record['extra']['hg']['branch']));
|
39 |
-
$this->assertTrue(!is_array($record['extra']['hg']['revision']));
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class ProcessIdProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\ProcessIdProcessor::__invoke
|
20 |
-
*/
|
21 |
-
public function testProcessor()
|
22 |
-
{
|
23 |
-
$processor = new ProcessIdProcessor();
|
24 |
-
$record = $processor($this->getRecord());
|
25 |
-
$this->assertArrayHasKey('process_id', $record['extra']);
|
26 |
-
$this->assertInternalType('int', $record['extra']['process_id']);
|
27 |
-
$this->assertGreaterThan(0, $record['extra']['process_id']);
|
28 |
-
$this->assertEquals(getmypid(), $record['extra']['process_id']);
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @dataProvider getPairs
|
18 |
-
*/
|
19 |
-
public function testReplacement($val, $expected)
|
20 |
-
{
|
21 |
-
$proc = new PsrLogMessageProcessor;
|
22 |
-
|
23 |
-
$message = $proc(array(
|
24 |
-
'message' => '{foo}',
|
25 |
-
'context' => array('foo' => $val),
|
26 |
-
));
|
27 |
-
$this->assertEquals($expected, $message['message']);
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getPairs()
|
31 |
-
{
|
32 |
-
return array(
|
33 |
-
array('foo', 'foo'),
|
34 |
-
array('3', '3'),
|
35 |
-
array(3, '3'),
|
36 |
-
array(null, ''),
|
37 |
-
array(true, '1'),
|
38 |
-
array(false, ''),
|
39 |
-
array(new \stdClass, '[object stdClass]'),
|
40 |
-
array(array(), '[array]'),
|
41 |
-
);
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class TagProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\TagProcessor::__invoke
|
20 |
-
*/
|
21 |
-
public function testProcessor()
|
22 |
-
{
|
23 |
-
$tags = array(1, 2, 3);
|
24 |
-
$processor = new TagProcessor($tags);
|
25 |
-
$record = $processor($this->getRecord());
|
26 |
-
|
27 |
-
$this->assertEquals($tags, $record['extra']['tags']);
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @covers Monolog\Processor\TagProcessor::__invoke
|
32 |
-
*/
|
33 |
-
public function testProcessorTagModification()
|
34 |
-
{
|
35 |
-
$tags = array(1, 2, 3);
|
36 |
-
$processor = new TagProcessor($tags);
|
37 |
-
|
38 |
-
$record = $processor($this->getRecord());
|
39 |
-
$this->assertEquals($tags, $record['extra']['tags']);
|
40 |
-
|
41 |
-
$processor->setTags(array('a', 'b'));
|
42 |
-
$record = $processor($this->getRecord());
|
43 |
-
$this->assertEquals(array('a', 'b'), $record['extra']['tags']);
|
44 |
-
|
45 |
-
$processor->addTags(array('a', 'c', 'foo' => 'bar'));
|
46 |
-
$record = $processor($this->getRecord());
|
47 |
-
$this->assertEquals(array('a', 'b', 'a', 'c', 'foo' => 'bar'), $record['extra']['tags']);
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class UidProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @covers Monolog\Processor\UidProcessor::__invoke
|
20 |
-
*/
|
21 |
-
public function testProcessor()
|
22 |
-
{
|
23 |
-
$processor = new UidProcessor();
|
24 |
-
$record = $processor($this->getRecord());
|
25 |
-
$this->assertArrayHasKey('uid', $record['extra']);
|
26 |
-
}
|
27 |
-
|
28 |
-
public function testGetUid()
|
29 |
-
{
|
30 |
-
$processor = new UidProcessor(10);
|
31 |
-
$this->assertEquals(10, strlen($processor->getUid()));
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\TestCase;
|
15 |
-
|
16 |
-
class WebProcessorTest extends TestCase
|
17 |
-
{
|
18 |
-
public function testProcessor()
|
19 |
-
{
|
20 |
-
$server = array(
|
21 |
-
'REQUEST_URI' => 'A',
|
22 |
-
'REMOTE_ADDR' => 'B',
|
23 |
-
'REQUEST_METHOD' => 'C',
|
24 |
-
'HTTP_REFERER' => 'D',
|
25 |
-
'SERVER_NAME' => 'F',
|
26 |
-
'UNIQUE_ID' => 'G',
|
27 |
-
);
|
28 |
-
|
29 |
-
$processor = new WebProcessor($server);
|
30 |
-
$record = $processor($this->getRecord());
|
31 |
-
$this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
|
32 |
-
$this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
|
33 |
-
$this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
|
34 |
-
$this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
|
35 |
-
$this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
|
36 |
-
$this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']);
|
37 |
-
}
|
38 |
-
|
39 |
-
public function testProcessorDoNothingIfNoRequestUri()
|
40 |
-
{
|
41 |
-
$server = array(
|
42 |
-
'REMOTE_ADDR' => 'B',
|
43 |
-
'REQUEST_METHOD' => 'C',
|
44 |
-
);
|
45 |
-
$processor = new WebProcessor($server);
|
46 |
-
$record = $processor($this->getRecord());
|
47 |
-
$this->assertEmpty($record['extra']);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function testProcessorReturnNullIfNoHttpReferer()
|
51 |
-
{
|
52 |
-
$server = array(
|
53 |
-
'REQUEST_URI' => 'A',
|
54 |
-
'REMOTE_ADDR' => 'B',
|
55 |
-
'REQUEST_METHOD' => 'C',
|
56 |
-
'SERVER_NAME' => 'F',
|
57 |
-
);
|
58 |
-
$processor = new WebProcessor($server);
|
59 |
-
$record = $processor($this->getRecord());
|
60 |
-
$this->assertNull($record['extra']['referrer']);
|
61 |
-
}
|
62 |
-
|
63 |
-
public function testProcessorDoesNotAddUniqueIdIfNotPresent()
|
64 |
-
{
|
65 |
-
$server = array(
|
66 |
-
'REQUEST_URI' => 'A',
|
67 |
-
'REMOTE_ADDR' => 'B',
|
68 |
-
'REQUEST_METHOD' => 'C',
|
69 |
-
'SERVER_NAME' => 'F',
|
70 |
-
);
|
71 |
-
$processor = new WebProcessor($server);
|
72 |
-
$record = $processor($this->getRecord());
|
73 |
-
$this->assertFalse(isset($record['extra']['unique_id']));
|
74 |
-
}
|
75 |
-
|
76 |
-
public function testProcessorAddsOnlyRequestedExtraFields()
|
77 |
-
{
|
78 |
-
$server = array(
|
79 |
-
'REQUEST_URI' => 'A',
|
80 |
-
'REMOTE_ADDR' => 'B',
|
81 |
-
'REQUEST_METHOD' => 'C',
|
82 |
-
'SERVER_NAME' => 'F',
|
83 |
-
);
|
84 |
-
|
85 |
-
$processor = new WebProcessor($server, array('url', 'http_method'));
|
86 |
-
$record = $processor($this->getRecord());
|
87 |
-
|
88 |
-
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
|
89 |
-
}
|
90 |
-
|
91 |
-
public function testProcessorConfiguringOfExtraFields()
|
92 |
-
{
|
93 |
-
$server = array(
|
94 |
-
'REQUEST_URI' => 'A',
|
95 |
-
'REMOTE_ADDR' => 'B',
|
96 |
-
'REQUEST_METHOD' => 'C',
|
97 |
-
'SERVER_NAME' => 'F',
|
98 |
-
);
|
99 |
-
|
100 |
-
$processor = new WebProcessor($server, array('url' => 'REMOTE_ADDR'));
|
101 |
-
$record = $processor($this->getRecord());
|
102 |
-
|
103 |
-
$this->assertSame(array('url' => 'B'), $record['extra']);
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* @expectedException UnexpectedValueException
|
108 |
-
*/
|
109 |
-
public function testInvalidData()
|
110 |
-
{
|
111 |
-
new WebProcessor(new \stdClass);
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Monolog\Handler\TestHandler;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
use Monolog\Processor\PsrLogMessageProcessor;
|
17 |
-
use Psr\Log\Test\LoggerInterfaceTest;
|
18 |
-
|
19 |
-
class PsrLogCompatTest extends LoggerInterfaceTest
|
20 |
-
{
|
21 |
-
private $handler;
|
22 |
-
|
23 |
-
public function getLogger()
|
24 |
-
{
|
25 |
-
$logger = new Logger('foo');
|
26 |
-
$logger->pushHandler($handler = new TestHandler);
|
27 |
-
$logger->pushProcessor(new PsrLogMessageProcessor);
|
28 |
-
$handler->setFormatter(new LineFormatter('%level_name% %message%'));
|
29 |
-
|
30 |
-
$this->handler = $handler;
|
31 |
-
|
32 |
-
return $logger;
|
33 |
-
}
|
34 |
-
|
35 |
-
public function getLogs()
|
36 |
-
{
|
37 |
-
$convert = function ($record) {
|
38 |
-
$lower = function ($match) {
|
39 |
-
return strtolower($match[0]);
|
40 |
-
};
|
41 |
-
|
42 |
-
return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']);
|
43 |
-
};
|
44 |
-
|
45 |
-
return array_map($convert, $this->handler->getRecords());
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/RegistryTest.php
DELETED
@@ -1,153 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
class RegistryTest extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
protected function setUp()
|
17 |
-
{
|
18 |
-
Registry::clear();
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @dataProvider hasLoggerProvider
|
23 |
-
* @covers Monolog\Registry::hasLogger
|
24 |
-
*/
|
25 |
-
public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
|
26 |
-
{
|
27 |
-
foreach ($loggersToAdd as $loggerToAdd) {
|
28 |
-
Registry::addLogger($loggerToAdd);
|
29 |
-
}
|
30 |
-
foreach ($loggersToCheck as $index => $loggerToCheck) {
|
31 |
-
$this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck));
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
public function hasLoggerProvider()
|
36 |
-
{
|
37 |
-
$logger1 = new Logger('test1');
|
38 |
-
$logger2 = new Logger('test2');
|
39 |
-
$logger3 = new Logger('test3');
|
40 |
-
|
41 |
-
return array(
|
42 |
-
// only instances
|
43 |
-
array(
|
44 |
-
array($logger1),
|
45 |
-
array($logger1, $logger2),
|
46 |
-
array(true, false),
|
47 |
-
),
|
48 |
-
// only names
|
49 |
-
array(
|
50 |
-
array($logger1),
|
51 |
-
array('test1', 'test2'),
|
52 |
-
array(true, false),
|
53 |
-
),
|
54 |
-
// mixed case
|
55 |
-
array(
|
56 |
-
array($logger1, $logger2),
|
57 |
-
array('test1', $logger2, 'test3', $logger3),
|
58 |
-
array(true, true, false, false),
|
59 |
-
),
|
60 |
-
);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @covers Monolog\Registry::clear
|
65 |
-
*/
|
66 |
-
public function testClearClears()
|
67 |
-
{
|
68 |
-
Registry::addLogger(new Logger('test1'), 'log');
|
69 |
-
Registry::clear();
|
70 |
-
|
71 |
-
$this->setExpectedException('\InvalidArgumentException');
|
72 |
-
Registry::getInstance('log');
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @dataProvider removedLoggerProvider
|
77 |
-
* @covers Monolog\Registry::addLogger
|
78 |
-
* @covers Monolog\Registry::removeLogger
|
79 |
-
*/
|
80 |
-
public function testRemovesLogger($loggerToAdd, $remove)
|
81 |
-
{
|
82 |
-
Registry::addLogger($loggerToAdd);
|
83 |
-
Registry::removeLogger($remove);
|
84 |
-
|
85 |
-
$this->setExpectedException('\InvalidArgumentException');
|
86 |
-
Registry::getInstance($loggerToAdd->getName());
|
87 |
-
}
|
88 |
-
|
89 |
-
public function removedLoggerProvider()
|
90 |
-
{
|
91 |
-
$logger1 = new Logger('test1');
|
92 |
-
|
93 |
-
return array(
|
94 |
-
array($logger1, $logger1),
|
95 |
-
array($logger1, 'test1'),
|
96 |
-
);
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @covers Monolog\Registry::addLogger
|
101 |
-
* @covers Monolog\Registry::getInstance
|
102 |
-
* @covers Monolog\Registry::__callStatic
|
103 |
-
*/
|
104 |
-
public function testGetsSameLogger()
|
105 |
-
{
|
106 |
-
$logger1 = new Logger('test1');
|
107 |
-
$logger2 = new Logger('test2');
|
108 |
-
|
109 |
-
Registry::addLogger($logger1, 'test1');
|
110 |
-
Registry::addLogger($logger2);
|
111 |
-
|
112 |
-
$this->assertSame($logger1, Registry::getInstance('test1'));
|
113 |
-
$this->assertSame($logger2, Registry::test2());
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* @expectedException \InvalidArgumentException
|
118 |
-
* @covers Monolog\Registry::getInstance
|
119 |
-
*/
|
120 |
-
public function testFailsOnNonExistantLogger()
|
121 |
-
{
|
122 |
-
Registry::getInstance('test1');
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @covers Monolog\Registry::addLogger
|
127 |
-
*/
|
128 |
-
public function testReplacesLogger()
|
129 |
-
{
|
130 |
-
$log1 = new Logger('test1');
|
131 |
-
$log2 = new Logger('test2');
|
132 |
-
|
133 |
-
Registry::addLogger($log1, 'log');
|
134 |
-
|
135 |
-
Registry::addLogger($log2, 'log', true);
|
136 |
-
|
137 |
-
$this->assertSame($log2, Registry::getInstance('log'));
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* @expectedException \InvalidArgumentException
|
142 |
-
* @covers Monolog\Registry::addLogger
|
143 |
-
*/
|
144 |
-
public function testFailsOnUnspecifiedReplacement()
|
145 |
-
{
|
146 |
-
$log1 = new Logger('test1');
|
147 |
-
$log2 = new Logger('test2');
|
148 |
-
|
149 |
-
Registry::addLogger($log1, 'log');
|
150 |
-
|
151 |
-
Registry::addLogger($log2, 'log');
|
152 |
-
}
|
153 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php
DELETED
@@ -1,287 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Monolog\Handler\StreamHandler;
|
15 |
-
use Monolog\Handler\TestHandler;
|
16 |
-
use Psr\Log\LogLevel;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @author Robert Gust-Bardon <robert@gust-bardon.org>
|
20 |
-
* @covers Monolog\SignalHandler
|
21 |
-
*/
|
22 |
-
class SignalHandlerTest extends TestCase
|
23 |
-
{
|
24 |
-
|
25 |
-
private $asyncSignalHandling;
|
26 |
-
private $blockedSignals;
|
27 |
-
private $signalHandlers;
|
28 |
-
|
29 |
-
protected function setUp()
|
30 |
-
{
|
31 |
-
$this->signalHandlers = array();
|
32 |
-
if (extension_loaded('pcntl')) {
|
33 |
-
if (function_exists('pcntl_async_signals')) {
|
34 |
-
$this->asyncSignalHandling = pcntl_async_signals();
|
35 |
-
}
|
36 |
-
if (function_exists('pcntl_sigprocmask')) {
|
37 |
-
pcntl_sigprocmask(SIG_BLOCK, array(), $this->blockedSignals);
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
protected function tearDown()
|
43 |
-
{
|
44 |
-
if ($this->asyncSignalHandling !== null) {
|
45 |
-
pcntl_async_signals($this->asyncSignalHandling);
|
46 |
-
}
|
47 |
-
if ($this->blockedSignals !== null) {
|
48 |
-
pcntl_sigprocmask(SIG_SETMASK, $this->blockedSignals);
|
49 |
-
}
|
50 |
-
if ($this->signalHandlers) {
|
51 |
-
pcntl_signal_dispatch();
|
52 |
-
foreach ($this->signalHandlers as $signo => $handler) {
|
53 |
-
pcntl_signal($signo, $handler);
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
private function setSignalHandler($signo, $handler = SIG_DFL) {
|
59 |
-
if (function_exists('pcntl_signal_get_handler')) {
|
60 |
-
$this->signalHandlers[$signo] = pcntl_signal_get_handler($signo);
|
61 |
-
} else {
|
62 |
-
$this->signalHandlers[$signo] = SIG_DFL;
|
63 |
-
}
|
64 |
-
$this->assertTrue(pcntl_signal($signo, $handler));
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testHandleSignal()
|
68 |
-
{
|
69 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
70 |
-
$errHandler = new SignalHandler($logger);
|
71 |
-
$signo = 2; // SIGINT.
|
72 |
-
$siginfo = array('signo' => $signo, 'errno' => 0, 'code' => 0);
|
73 |
-
$errHandler->handleSignal($signo, $siginfo);
|
74 |
-
$this->assertCount(1, $handler->getRecords());
|
75 |
-
$this->assertTrue($handler->hasCriticalRecords());
|
76 |
-
$records = $handler->getRecords();
|
77 |
-
$this->assertSame($siginfo, $records[0]['context']);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* @depends testHandleSignal
|
82 |
-
* @requires extension pcntl
|
83 |
-
* @requires extension posix
|
84 |
-
* @requires function pcntl_signal
|
85 |
-
* @requires function pcntl_signal_dispatch
|
86 |
-
* @requires function posix_getpid
|
87 |
-
* @requires function posix_kill
|
88 |
-
*/
|
89 |
-
public function testRegisterSignalHandler()
|
90 |
-
{
|
91 |
-
// SIGCONT and SIGURG should be ignored by default.
|
92 |
-
if (!defined('SIGCONT') || !defined('SIGURG')) {
|
93 |
-
$this->markTestSkipped('This test requires the SIGCONT and SIGURG pcntl constants.');
|
94 |
-
}
|
95 |
-
|
96 |
-
$this->setSignalHandler(SIGCONT, SIG_IGN);
|
97 |
-
$this->setSignalHandler(SIGURG, SIG_IGN);
|
98 |
-
|
99 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
100 |
-
$errHandler = new SignalHandler($logger);
|
101 |
-
$pid = posix_getpid();
|
102 |
-
|
103 |
-
$this->assertTrue(posix_kill($pid, SIGURG));
|
104 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
105 |
-
$this->assertCount(0, $handler->getRecords());
|
106 |
-
|
107 |
-
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, false, false);
|
108 |
-
|
109 |
-
$this->assertTrue(posix_kill($pid, SIGCONT));
|
110 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
111 |
-
$this->assertCount(0, $handler->getRecords());
|
112 |
-
|
113 |
-
$this->assertTrue(posix_kill($pid, SIGURG));
|
114 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
115 |
-
$this->assertCount(1, $handler->getRecords());
|
116 |
-
$this->assertTrue($handler->hasInfoThatContains('SIGURG'));
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* @dataProvider defaultPreviousProvider
|
121 |
-
* @depends testRegisterSignalHandler
|
122 |
-
* @requires function pcntl_fork
|
123 |
-
* @requires function pcntl_sigprocmask
|
124 |
-
* @requires function pcntl_waitpid
|
125 |
-
*/
|
126 |
-
public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected)
|
127 |
-
{
|
128 |
-
$this->setSignalHandler($signo, SIG_DFL);
|
129 |
-
|
130 |
-
$path = tempnam(sys_get_temp_dir(), 'monolog-');
|
131 |
-
$this->assertNotFalse($path);
|
132 |
-
|
133 |
-
$pid = pcntl_fork();
|
134 |
-
if ($pid === 0) { // Child.
|
135 |
-
$streamHandler = new StreamHandler($path);
|
136 |
-
$streamHandler->setFormatter($this->getIdentityFormatter());
|
137 |
-
$logger = new Logger('test', array($streamHandler));
|
138 |
-
$errHandler = new SignalHandler($logger);
|
139 |
-
$errHandler->registerSignalHandler($signo, LogLevel::INFO, $callPrevious, false, false);
|
140 |
-
pcntl_sigprocmask(SIG_SETMASK, array(SIGCONT));
|
141 |
-
posix_kill(posix_getpid(), $signo);
|
142 |
-
pcntl_signal_dispatch();
|
143 |
-
// If $callPrevious is true, SIGINT should terminate by this line.
|
144 |
-
pcntl_sigprocmask(SIG_BLOCK, array(), $oldset);
|
145 |
-
file_put_contents($path, implode(' ', $oldset), FILE_APPEND);
|
146 |
-
posix_kill(posix_getpid(), $signo);
|
147 |
-
pcntl_signal_dispatch();
|
148 |
-
exit();
|
149 |
-
}
|
150 |
-
|
151 |
-
$this->assertNotSame(-1, $pid);
|
152 |
-
$this->assertNotSame(-1, pcntl_waitpid($pid, $status));
|
153 |
-
$this->assertNotSame(-1, $status);
|
154 |
-
$this->assertSame($expected, file_get_contents($path));
|
155 |
-
}
|
156 |
-
|
157 |
-
public function defaultPreviousProvider()
|
158 |
-
{
|
159 |
-
if (!defined('SIGCONT') || !defined('SIGINT') || !defined('SIGURG')) {
|
160 |
-
return array();
|
161 |
-
}
|
162 |
-
|
163 |
-
return array(
|
164 |
-
array(SIGINT, false, 'Program received signal SIGINT'.SIGCONT.'Program received signal SIGINT'),
|
165 |
-
array(SIGINT, true, 'Program received signal SIGINT'),
|
166 |
-
array(SIGURG, false, 'Program received signal SIGURG'.SIGCONT.'Program received signal SIGURG'),
|
167 |
-
array(SIGURG, true, 'Program received signal SIGURG'.SIGCONT.'Program received signal SIGURG'),
|
168 |
-
);
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* @dataProvider callablePreviousProvider
|
173 |
-
* @depends testRegisterSignalHandler
|
174 |
-
* @requires function pcntl_signal_get_handler
|
175 |
-
*/
|
176 |
-
public function testRegisterCallablePreviousSignalHandler($callPrevious)
|
177 |
-
{
|
178 |
-
$this->setSignalHandler(SIGURG, SIG_IGN);
|
179 |
-
|
180 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
181 |
-
$errHandler = new SignalHandler($logger);
|
182 |
-
$previousCalled = 0;
|
183 |
-
pcntl_signal(SIGURG, function ($signo, array $siginfo = null) use (&$previousCalled) {
|
184 |
-
++$previousCalled;
|
185 |
-
});
|
186 |
-
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, $callPrevious, false, false);
|
187 |
-
$this->assertTrue(posix_kill(posix_getpid(), SIGURG));
|
188 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
189 |
-
$this->assertCount(1, $handler->getRecords());
|
190 |
-
$this->assertTrue($handler->hasInfoThatContains('SIGURG'));
|
191 |
-
$this->assertSame($callPrevious ? 1 : 0, $previousCalled);
|
192 |
-
}
|
193 |
-
|
194 |
-
public function callablePreviousProvider()
|
195 |
-
{
|
196 |
-
return array(
|
197 |
-
array(false),
|
198 |
-
array(true),
|
199 |
-
);
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* @dataProvider restartSyscallsProvider
|
204 |
-
* @depends testRegisterDefaultPreviousSignalHandler
|
205 |
-
* @requires function pcntl_fork
|
206 |
-
* @requires function pcntl_waitpid
|
207 |
-
*/
|
208 |
-
public function testRegisterSyscallRestartingSignalHandler($restartSyscalls)
|
209 |
-
{
|
210 |
-
$this->setSignalHandler(SIGURG, SIG_IGN);
|
211 |
-
|
212 |
-
$parentPid = posix_getpid();
|
213 |
-
$microtime = microtime(true);
|
214 |
-
|
215 |
-
$pid = pcntl_fork();
|
216 |
-
if ($pid === 0) { // Child.
|
217 |
-
usleep(100000);
|
218 |
-
posix_kill($parentPid, SIGURG);
|
219 |
-
usleep(100000);
|
220 |
-
exit();
|
221 |
-
}
|
222 |
-
|
223 |
-
$this->assertNotSame(-1, $pid);
|
224 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
225 |
-
$errHandler = new SignalHandler($logger);
|
226 |
-
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, $restartSyscalls, false);
|
227 |
-
if ($restartSyscalls) {
|
228 |
-
// pcntl_wait is expected to be restarted after the signal handler.
|
229 |
-
$this->assertNotSame(-1, pcntl_waitpid($pid, $status));
|
230 |
-
} else {
|
231 |
-
// pcntl_wait is expected to be interrupted when the signal handler is invoked.
|
232 |
-
$this->assertSame(-1, pcntl_waitpid($pid, $status));
|
233 |
-
}
|
234 |
-
$this->assertSame($restartSyscalls, microtime(true) - $microtime > 0.15);
|
235 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
236 |
-
$this->assertCount(1, $handler->getRecords());
|
237 |
-
if ($restartSyscalls) {
|
238 |
-
// The child has already exited.
|
239 |
-
$this->assertSame(-1, pcntl_waitpid($pid, $status));
|
240 |
-
} else {
|
241 |
-
// The child has not exited yet.
|
242 |
-
$this->assertNotSame(-1, pcntl_waitpid($pid, $status));
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
public function restartSyscallsProvider()
|
247 |
-
{
|
248 |
-
return array(
|
249 |
-
array(false),
|
250 |
-
array(true),
|
251 |
-
array(false),
|
252 |
-
array(true),
|
253 |
-
);
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* @dataProvider asyncProvider
|
258 |
-
* @depends testRegisterDefaultPreviousSignalHandler
|
259 |
-
* @requires function pcntl_async_signals
|
260 |
-
*/
|
261 |
-
public function testRegisterAsyncSignalHandler($initialAsync, $desiredAsync, $expectedBefore, $expectedAfter)
|
262 |
-
{
|
263 |
-
$this->setSignalHandler(SIGURG, SIG_IGN);
|
264 |
-
pcntl_async_signals($initialAsync);
|
265 |
-
|
266 |
-
$logger = new Logger('test', array($handler = new TestHandler));
|
267 |
-
$errHandler = new SignalHandler($logger);
|
268 |
-
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, false, $desiredAsync);
|
269 |
-
$this->assertTrue(posix_kill(posix_getpid(), SIGURG));
|
270 |
-
$this->assertCount($expectedBefore, $handler->getRecords());
|
271 |
-
$this->assertTrue(pcntl_signal_dispatch());
|
272 |
-
$this->assertCount($expectedAfter, $handler->getRecords());
|
273 |
-
}
|
274 |
-
|
275 |
-
public function asyncProvider()
|
276 |
-
{
|
277 |
-
return array(
|
278 |
-
array(false, false, 0, 1),
|
279 |
-
array(false, null, 0, 1),
|
280 |
-
array(false, true, 1, 1),
|
281 |
-
array(true, false, 0, 1),
|
282 |
-
array(true, null, 1, 1),
|
283 |
-
array(true, true, 1, 1),
|
284 |
-
);
|
285 |
-
}
|
286 |
-
|
287 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/tests/Monolog/TestCase.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
class TestCase extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @return array Record
|
18 |
-
*/
|
19 |
-
protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
|
20 |
-
{
|
21 |
-
return array(
|
22 |
-
'message' => $message,
|
23 |
-
'context' => $context,
|
24 |
-
'level' => $level,
|
25 |
-
'level_name' => Logger::getLevelName($level),
|
26 |
-
'channel' => 'test',
|
27 |
-
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
|
28 |
-
'extra' => array(),
|
29 |
-
);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
protected function getMultipleRecords()
|
36 |
-
{
|
37 |
-
return array(
|
38 |
-
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
39 |
-
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
40 |
-
$this->getRecord(Logger::INFO, 'information'),
|
41 |
-
$this->getRecord(Logger::WARNING, 'warning'),
|
42 |
-
$this->getRecord(Logger::ERROR, 'error'),
|
43 |
-
);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @return Monolog\Formatter\FormatterInterface
|
48 |
-
*/
|
49 |
-
protected function getIdentityFormatter()
|
50 |
-
{
|
51 |
-
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
|
52 |
-
$formatter->expects($this->any())
|
53 |
-
->method('format')
|
54 |
-
->will($this->returnCallback(function ($record) { return $record['message']; }));
|
55 |
-
|
56 |
-
return $formatter;
|
57 |
-
}
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/composer.json
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "psr/log",
|
3 |
-
"description": "Common interface for logging libraries",
|
4 |
-
"keywords": ["psr", "psr-3", "log"],
|
5 |
-
"homepage": "https://github.com/php-fig/log",
|
6 |
-
"license": "MIT",
|
7 |
-
"authors": [
|
8 |
-
{
|
9 |
-
"name": "PHP-FIG",
|
10 |
-
"homepage": "http://www.php-fig.org/"
|
11 |
-
}
|
12 |
-
],
|
13 |
-
"require": {
|
14 |
-
"php": ">=5.3.0"
|
15 |
-
},
|
16 |
-
"autoload": {
|
17 |
-
"psr-4": {
|
18 |
-
"Psr\\Log\\": "Psr/Log/"
|
19 |
-
}
|
20 |
-
},
|
21 |
-
"extra": {
|
22 |
-
"branch-alias": {
|
23 |
-
"dev-master": "1.0.x-dev"
|
24 |
-
}
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|