Version Description
If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible-shipping) make sure to completely delete the old version first. If you install the new version without deleting the old one you may break your WordPress installation.
Download this release
Release Info
Developer | jablonowski |
Plugin | Flexible Shipping for WooCommerce |
Version | 3.3.8 |
Comparing to | |
See all releases |
Code changes from version 3.3.7 to 3.3.8
- composer.lock +10 -6
- flexible-shipping.php +2 -2
- vendor/autoload.php +1 -1
- vendor/composer/LICENSE +0 -21
- vendor/composer/autoload_classmap.php +3 -0
- vendor/composer/autoload_files.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +8 -5
- vendor/composer/installed.json +11 -7
- vendor/moneyphp/money/LICENSE +0 -21
- vendor/moneyphp/money/README.md +0 -116
- vendor/monolog/monolog/LICENSE +0 -19
- vendor/monolog/monolog/README.md +0 -94
- 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/Fixtures/.gitkeep +0 -0
- 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/LICENSE +0 -19
- vendor/psr/log/README.md +0 -52
- vendor/psr/simple-cache/README.md +0 -8
- vendor/wpdesk/wp-abtesting/README.md +0 -45
- vendor/wpdesk/wp-autoloader/.gitlab-ci.yml +0 -310
- vendor/wpdesk/wp-autoloader/LICENSE +0 -21
- vendor/wpdesk/wp-autoloader/tests/docker-compose.yaml +0 -172
- vendor/wpdesk/wp-autoloader/tests/integration/bootstrap.php +0 -28
- vendor/wpdesk/wp-autoloader/tests/unit/bootstrap.php +0 -9
- vendor/wpdesk/wp-basic-requirements/.gitlab-ci.yml +0 -154
- vendor/wpdesk/wp-basic-requirements/LICENSE +0 -21
- vendor/wpdesk/wp-basic-requirements/README.md +0 -12
- vendor/wpdesk/wp-basic-requirements/tests/integration/bootstrap.php +0 -16
- vendor/wpdesk/wp-basic-requirements/tests/unit/Test_Basic_Requirement_Checker.php +0 -167
- vendor/wpdesk/wp-basic-requirements/tests/unit/bootstrap.php +0 -23
- vendor/wpdesk/wp-builder/.gitlab-ci.yml +0 -310
- vendor/wpdesk/wp-builder/LICENSE +0 -21
- vendor/wpdesk/wp-builder/tests/integration/bootstrap.php +0 -27
- vendor/wpdesk/wp-builder/tests/unit/bootstrap.php +0 -23
- vendor/wpdesk/wp-logs/CHANGELOG.md +18 -0
- vendor/wpdesk/wp-logs/README.md +0 -81
- vendor/wpdesk/wp-logs/composer.json +3 -1
- vendor/wpdesk/wp-logs/src/LoggerFacade.php +2 -0
- vendor/wpdesk/wp-logs/src/WP/WPCapture.php +140 -0
- vendor/wpdesk/wp-logs/src/WPDeskLoggerFactory.php +59 -31
- vendor/wpdesk/wp-logs/src/deprecated/wpdesk-logger-factory.php +95 -0
- vendor/wpdesk/wp-logs/src/deprecated/wpdesk-logger.php +116 -0
- vendor/wpdesk/wp-notice/README.md +0 -64
- vendor/wpdesk/wp-persistence/README.md +0 -45
- vendor/wpdesk/wp-pointer/README.md +0 -14
- vendor/wpdesk/wp-saas-platform-client/README.md +0 -6
- vendor/wpdesk/wp-view/.gitlab-ci.yml +0 -74
- vendor/wpdesk/wp-view/tests/integration/bootstrap.php +0 -28
- vendor/wpdesk/wp-view/tests/unit/Renderer/TestSimplePhpRenderer.php +0 -20
- vendor/wpdesk/wp-view/tests/unit/Renderer/templates/some_template.php +0 -2
- vendor/wpdesk/wp-view/tests/unit/Resolver/TestChainResolver.php +0 -53
- vendor/wpdesk/wp-view/tests/unit/Resolver/TestDirResolver.php +0 -29
- vendor/wpdesk/wp-view/tests/unit/Resolver/TestWpThemeResolver.php +0 -69
- vendor/wpdesk/wp-view/tests/unit/Resolver/templates/some_template.php +0 -1
- vendor/wpdesk/wp-view/tests/unit/bootstrap.php +0 -6
composer.lock
CHANGED
@@ -416,22 +416,23 @@
|
|
416 |
},
|
417 |
{
|
418 |
"name": "wpdesk/wp-logs",
|
419 |
-
"version": "1.
|
420 |
"source": {
|
421 |
"type": "git",
|
422 |
"url": "https://gitlab.com/wpdesk/wp-logs.git",
|
423 |
-
"reference": "
|
424 |
},
|
425 |
"dist": {
|
426 |
"type": "zip",
|
427 |
-
"url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-logs/repository/archive.zip?sha=
|
428 |
-
"reference": "
|
429 |
"shasum": ""
|
430 |
},
|
431 |
"require": {
|
432 |
"monolog/monolog": "^1.23",
|
433 |
"php": ">=5.6",
|
434 |
-
"psr/log": "^1.0.1"
|
|
|
435 |
},
|
436 |
"require-dev": {
|
437 |
"phpunit/phpunit": "^5",
|
@@ -441,6 +442,9 @@
|
|
441 |
},
|
442 |
"type": "library",
|
443 |
"autoload": {
|
|
|
|
|
|
|
444 |
"psr-4": {
|
445 |
"WPDesk\\Logger\\": "src/"
|
446 |
}
|
@@ -452,7 +456,7 @@
|
|
452 |
"email": "krzysiek@wpdesk.pl"
|
453 |
}
|
454 |
],
|
455 |
-
"time": "2019-
|
456 |
},
|
457 |
{
|
458 |
"name": "wpdesk/wp-mutex",
|
416 |
},
|
417 |
{
|
418 |
"name": "wpdesk/wp-logs",
|
419 |
+
"version": "1.5.2",
|
420 |
"source": {
|
421 |
"type": "git",
|
422 |
"url": "https://gitlab.com/wpdesk/wp-logs.git",
|
423 |
+
"reference": "9ae82e9a2e98a770c801232250ecba6b1d2fe12f"
|
424 |
},
|
425 |
"dist": {
|
426 |
"type": "zip",
|
427 |
+
"url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-logs/repository/archive.zip?sha=9ae82e9a2e98a770c801232250ecba6b1d2fe12f",
|
428 |
+
"reference": "9ae82e9a2e98a770c801232250ecba6b1d2fe12f",
|
429 |
"shasum": ""
|
430 |
},
|
431 |
"require": {
|
432 |
"monolog/monolog": "^1.23",
|
433 |
"php": ">=5.6",
|
434 |
+
"psr/log": "^1.0.1",
|
435 |
+
"wpdesk/wp-notice": "^3.0"
|
436 |
},
|
437 |
"require-dev": {
|
438 |
"phpunit/phpunit": "^5",
|
442 |
},
|
443 |
"type": "library",
|
444 |
"autoload": {
|
445 |
+
"classmap": [
|
446 |
+
"src/deprecated"
|
447 |
+
],
|
448 |
"psr-4": {
|
449 |
"WPDesk\\Logger\\": "src/"
|
450 |
}
|
456 |
"email": "krzysiek@wpdesk.pl"
|
457 |
}
|
458 |
],
|
459 |
+
"time": "2019-04-25T09:27:47+00:00"
|
460 |
},
|
461 |
{
|
462 |
"name": "wpdesk/wp-mutex",
|
flexible-shipping.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Flexible Shipping
|
4 |
Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
-
Version: 3.3.
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-shipping
|
@@ -43,7 +43,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
|
|
43 |
}
|
44 |
|
45 |
/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
|
46 |
-
$plugin_version = '3.3.
|
47 |
$plugin_release_timestamp = '2019-04-23';
|
48 |
|
49 |
$plugin_name = 'Flexible Shipping';
|
3 |
Plugin Name: Flexible Shipping
|
4 |
Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
+
Version: 3.3.8
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-shipping
|
43 |
}
|
44 |
|
45 |
/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
|
46 |
+
$plugin_version = '3.3.8';
|
47 |
$plugin_release_timestamp = '2019-04-23';
|
48 |
|
49 |
$plugin_name = 'Flexible Shipping';
|
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 ComposerAutoloaderInita97b87dd7235b0a9b6760d91c9cdaa28::getLoader();
|
vendor/composer/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
|
2 |
-
Copyright (c) Nils Adermann, Jordi Boggiano
|
3 |
-
|
4 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
-
of this software and associated documentation files (the "Software"), to deal
|
6 |
-
in the Software without restriction, including without limitation the rights
|
7 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
9 |
-
to do so, subject to the following conditions:
|
10 |
-
|
11 |
-
The above copyright notice and this permission notice shall be included in all
|
12 |
-
copies or substantial portions of the Software.
|
13 |
-
|
14 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20 |
-
THE SOFTWARE.
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -166,6 +166,7 @@ return array(
|
|
166 |
'WPDesk\\Logger\\WC\\WooCommerceHandler' => $vendorDir . '/wpdesk/wp-logs/src/WC/WooCommerceHandler.php',
|
167 |
'WPDesk\\Logger\\WC\\WooCommerceMonologPlugin' => $vendorDir . '/wpdesk/wp-logs/src/WC/WooCommerceMonologPlugin.php',
|
168 |
'WPDesk\\Logger\\WPDeskLoggerFactory' => $vendorDir . '/wpdesk/wp-logs/src/WPDeskLoggerFactory.php',
|
|
|
169 |
'WPDesk\\Mutex\\Mutex' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/Mutex.php',
|
170 |
'WPDesk\\Mutex\\MutexNotFoundInStorage' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexNotFoundInStorage.php',
|
171 |
'WPDesk\\Mutex\\MutexStorage' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexStorage.php',
|
@@ -443,6 +444,8 @@ return array(
|
|
443 |
'WPDesk_Flexible_Shipping_Tracker' => $baseDir . '/classes/tracker.php',
|
444 |
'WPDesk_Flexible_Shipping_UK_States' => $baseDir . '/classes/class-uk-states.php',
|
445 |
'WPDesk_Flexible_Shipping_WooCommerce_Context_Logger' => $baseDir . '/classes/logger/class-woocommerce-context-logger.php',
|
|
|
|
|
446 |
'WPDesk_Tracker' => $baseDir . '/inc/wpdesk-tracker/class-wpdesk-tracker.php',
|
447 |
'WPDesk_Tracker_Data_Provider' => $baseDir . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider.php',
|
448 |
'WPDesk_Tracker_Data_Provider_Gateways' => $baseDir . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider-gateways.php',
|
166 |
'WPDesk\\Logger\\WC\\WooCommerceHandler' => $vendorDir . '/wpdesk/wp-logs/src/WC/WooCommerceHandler.php',
|
167 |
'WPDesk\\Logger\\WC\\WooCommerceMonologPlugin' => $vendorDir . '/wpdesk/wp-logs/src/WC/WooCommerceMonologPlugin.php',
|
168 |
'WPDesk\\Logger\\WPDeskLoggerFactory' => $vendorDir . '/wpdesk/wp-logs/src/WPDeskLoggerFactory.php',
|
169 |
+
'WPDesk\\Logger\\WP\\WPCapture' => $vendorDir . '/wpdesk/wp-logs/src/WP/WPCapture.php',
|
170 |
'WPDesk\\Mutex\\Mutex' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/Mutex.php',
|
171 |
'WPDesk\\Mutex\\MutexNotFoundInStorage' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexNotFoundInStorage.php',
|
172 |
'WPDesk\\Mutex\\MutexStorage' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexStorage.php',
|
444 |
'WPDesk_Flexible_Shipping_Tracker' => $baseDir . '/classes/tracker.php',
|
445 |
'WPDesk_Flexible_Shipping_UK_States' => $baseDir . '/classes/class-uk-states.php',
|
446 |
'WPDesk_Flexible_Shipping_WooCommerce_Context_Logger' => $baseDir . '/classes/logger/class-woocommerce-context-logger.php',
|
447 |
+
'WPDesk_Logger' => $vendorDir . '/wpdesk/wp-logs/src/deprecated/wpdesk-logger.php',
|
448 |
+
'WPDesk_Logger_Factory' => $vendorDir . '/wpdesk/wp-logs/src/deprecated/wpdesk-logger-factory.php',
|
449 |
'WPDesk_Tracker' => $baseDir . '/inc/wpdesk-tracker/class-wpdesk-tracker.php',
|
450 |
'WPDesk_Tracker_Data_Provider' => $baseDir . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider.php',
|
451 |
'WPDesk_Tracker_Data_Provider_Gateways' => $baseDir . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider-gateways.php',
|
vendor/composer/autoload_files.php
CHANGED
@@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
-
'46ae4ad8c3479aabff48f598a0e4b93f' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
10 |
'0509b34a4bd7aebefeac629c9dc8a978' => $vendorDir . '/wpdesk/wp-notice/src/WPDesk/notice-functions.php',
|
|
|
11 |
);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
|
|
9 |
'0509b34a4bd7aebefeac629c9dc8a978' => $vendorDir . '/wpdesk/wp-notice/src/WPDesk/notice-functions.php',
|
10 |
+
'46ae4ad8c3479aabff48f598a0e4b93f' => $vendorDir . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
11 |
);
|
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,15 +19,15 @@ class ComposerAutoloaderInit26eb88ae979f0be0a5d1b2f7bfc783a9
|
|
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 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit26eb88ae979f0be0a5d1b2f7bfc783a9
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInita97b87dd7235b0a9b6760d91c9cdaa28
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInita97b87dd7235b0a9b6760d91c9cdaa28', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInita97b87dd7235b0a9b6760d91c9cdaa28', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequirea97b87dd7235b0a9b6760d91c9cdaa28($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequirea97b87dd7235b0a9b6760d91c9cdaa28($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
-
'46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
11 |
'0509b34a4bd7aebefeac629c9dc8a978' => __DIR__ . '/..' . '/wpdesk/wp-notice/src/WPDesk/notice-functions.php',
|
|
|
12 |
);
|
13 |
|
14 |
public static $prefixLengthsPsr4 = array (
|
@@ -252,6 +252,7 @@ class ComposerStaticInit26eb88ae979f0be0a5d1b2f7bfc783a9
|
|
252 |
'WPDesk\\Logger\\WC\\WooCommerceHandler' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WC/WooCommerceHandler.php',
|
253 |
'WPDesk\\Logger\\WC\\WooCommerceMonologPlugin' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WC/WooCommerceMonologPlugin.php',
|
254 |
'WPDesk\\Logger\\WPDeskLoggerFactory' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WPDeskLoggerFactory.php',
|
|
|
255 |
'WPDesk\\Mutex\\Mutex' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/Mutex.php',
|
256 |
'WPDesk\\Mutex\\MutexNotFoundInStorage' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexNotFoundInStorage.php',
|
257 |
'WPDesk\\Mutex\\MutexStorage' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexStorage.php',
|
@@ -529,6 +530,8 @@ class ComposerStaticInit26eb88ae979f0be0a5d1b2f7bfc783a9
|
|
529 |
'WPDesk_Flexible_Shipping_Tracker' => __DIR__ . '/../..' . '/classes/tracker.php',
|
530 |
'WPDesk_Flexible_Shipping_UK_States' => __DIR__ . '/../..' . '/classes/class-uk-states.php',
|
531 |
'WPDesk_Flexible_Shipping_WooCommerce_Context_Logger' => __DIR__ . '/../..' . '/classes/logger/class-woocommerce-context-logger.php',
|
|
|
|
|
532 |
'WPDesk_Tracker' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/class-wpdesk-tracker.php',
|
533 |
'WPDesk_Tracker_Data_Provider' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider.php',
|
534 |
'WPDesk_Tracker_Data_Provider_Gateways' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider-gateways.php',
|
@@ -562,9 +565,9 @@ class ComposerStaticInit26eb88ae979f0be0a5d1b2f7bfc783a9
|
|
562 |
public static function getInitializer(ClassLoader $loader)
|
563 |
{
|
564 |
return \Closure::bind(function () use ($loader) {
|
565 |
-
$loader->prefixLengthsPsr4 =
|
566 |
-
$loader->prefixDirsPsr4 =
|
567 |
-
$loader->classMap =
|
568 |
|
569 |
}, null, ClassLoader::class);
|
570 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28
|
8 |
{
|
9 |
public static $files = array (
|
|
|
10 |
'0509b34a4bd7aebefeac629c9dc8a978' => __DIR__ . '/..' . '/wpdesk/wp-notice/src/WPDesk/notice-functions.php',
|
11 |
+
'46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
12 |
);
|
13 |
|
14 |
public static $prefixLengthsPsr4 = array (
|
252 |
'WPDesk\\Logger\\WC\\WooCommerceHandler' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WC/WooCommerceHandler.php',
|
253 |
'WPDesk\\Logger\\WC\\WooCommerceMonologPlugin' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WC/WooCommerceMonologPlugin.php',
|
254 |
'WPDesk\\Logger\\WPDeskLoggerFactory' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WPDeskLoggerFactory.php',
|
255 |
+
'WPDesk\\Logger\\WP\\WPCapture' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/WP/WPCapture.php',
|
256 |
'WPDesk\\Mutex\\Mutex' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/Mutex.php',
|
257 |
'WPDesk\\Mutex\\MutexNotFoundInStorage' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexNotFoundInStorage.php',
|
258 |
'WPDesk\\Mutex\\MutexStorage' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/Mutex/MutexStorage.php',
|
530 |
'WPDesk_Flexible_Shipping_Tracker' => __DIR__ . '/../..' . '/classes/tracker.php',
|
531 |
'WPDesk_Flexible_Shipping_UK_States' => __DIR__ . '/../..' . '/classes/class-uk-states.php',
|
532 |
'WPDesk_Flexible_Shipping_WooCommerce_Context_Logger' => __DIR__ . '/../..' . '/classes/logger/class-woocommerce-context-logger.php',
|
533 |
+
'WPDesk_Logger' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/deprecated/wpdesk-logger.php',
|
534 |
+
'WPDesk_Logger_Factory' => __DIR__ . '/..' . '/wpdesk/wp-logs/src/deprecated/wpdesk-logger-factory.php',
|
535 |
'WPDesk_Tracker' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/class-wpdesk-tracker.php',
|
536 |
'WPDesk_Tracker_Data_Provider' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider.php',
|
537 |
'WPDesk_Tracker_Data_Provider_Gateways' => __DIR__ . '/../..' . '/inc/wpdesk-tracker/data_provider/class-wpdesk-tracker-data-provider-gateways.php',
|
565 |
public static function getInitializer(ClassLoader $loader)
|
566 |
{
|
567 |
return \Closure::bind(function () use ($loader) {
|
568 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28::$prefixLengthsPsr4;
|
569 |
+
$loader->prefixDirsPsr4 = ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28::$prefixDirsPsr4;
|
570 |
+
$loader->classMap = ComposerStaticInita97b87dd7235b0a9b6760d91c9cdaa28::$classMap;
|
571 |
|
572 |
}, null, ClassLoader::class);
|
573 |
}
|
vendor/composer/installed.json
CHANGED
@@ -425,23 +425,24 @@
|
|
425 |
},
|
426 |
{
|
427 |
"name": "wpdesk/wp-logs",
|
428 |
-
"version": "1.
|
429 |
-
"version_normalized": "1.
|
430 |
"source": {
|
431 |
"type": "git",
|
432 |
"url": "https://gitlab.com/wpdesk/wp-logs.git",
|
433 |
-
"reference": "
|
434 |
},
|
435 |
"dist": {
|
436 |
"type": "zip",
|
437 |
-
"url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-logs/repository/archive.zip?sha=
|
438 |
-
"reference": "
|
439 |
"shasum": ""
|
440 |
},
|
441 |
"require": {
|
442 |
"monolog/monolog": "^1.23",
|
443 |
"php": ">=5.6",
|
444 |
-
"psr/log": "^1.0.1"
|
|
|
445 |
},
|
446 |
"require-dev": {
|
447 |
"phpunit/phpunit": "^5",
|
@@ -449,10 +450,13 @@
|
|
449 |
"wimg/php-compatibility": "^8",
|
450 |
"wp-coding-standards/wpcs": "^0.14.1"
|
451 |
},
|
452 |
-
"time": "2019-
|
453 |
"type": "library",
|
454 |
"installation-source": "dist",
|
455 |
"autoload": {
|
|
|
|
|
|
|
456 |
"psr-4": {
|
457 |
"WPDesk\\Logger\\": "src/"
|
458 |
}
|
425 |
},
|
426 |
{
|
427 |
"name": "wpdesk/wp-logs",
|
428 |
+
"version": "1.5.2",
|
429 |
+
"version_normalized": "1.5.2.0",
|
430 |
"source": {
|
431 |
"type": "git",
|
432 |
"url": "https://gitlab.com/wpdesk/wp-logs.git",
|
433 |
+
"reference": "9ae82e9a2e98a770c801232250ecba6b1d2fe12f"
|
434 |
},
|
435 |
"dist": {
|
436 |
"type": "zip",
|
437 |
+
"url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-logs/repository/archive.zip?sha=9ae82e9a2e98a770c801232250ecba6b1d2fe12f",
|
438 |
+
"reference": "9ae82e9a2e98a770c801232250ecba6b1d2fe12f",
|
439 |
"shasum": ""
|
440 |
},
|
441 |
"require": {
|
442 |
"monolog/monolog": "^1.23",
|
443 |
"php": ">=5.6",
|
444 |
+
"psr/log": "^1.0.1",
|
445 |
+
"wpdesk/wp-notice": "^3.0"
|
446 |
},
|
447 |
"require-dev": {
|
448 |
"phpunit/phpunit": "^5",
|
450 |
"wimg/php-compatibility": "^8",
|
451 |
"wp-coding-standards/wpcs": "^0.14.1"
|
452 |
},
|
453 |
+
"time": "2019-04-25T09:27:47+00:00",
|
454 |
"type": "library",
|
455 |
"installation-source": "dist",
|
456 |
"autoload": {
|
457 |
+
"classmap": [
|
458 |
+
"src/deprecated"
|
459 |
+
],
|
460 |
"psr-4": {
|
461 |
"WPDesk\\Logger\\": "src/"
|
462 |
}
|
vendor/moneyphp/money/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
Copyright (c) 2011-2016 Mathias Verraes
|
2 |
-
Copyright (c) 2016 Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
3 |
-
Copyright (c) 2016 Frederik Bosch <f.bosch@genkgo.nl>
|
4 |
-
|
5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
-
of this software and associated documentation files (the "Software"), to deal
|
7 |
-
in the Software without restriction, including without limitation the rights
|
8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
-
copies of the Software, and to permit persons to whom the Software is
|
10 |
-
furnished to do so, subject to the following conditions:
|
11 |
-
|
12 |
-
The above copyright notice and this permission notice shall be included in
|
13 |
-
all copies or substantial portions of the Software.
|
14 |
-
|
15 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/moneyphp/money/README.md
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
# Money
|
2 |
-
|
3 |
-
[![Latest Version](https://img.shields.io/github/release/moneyphp/money.svg?style=flat-square)](https://github.com/moneyphp/money/releases)
|
4 |
-
[![Build Status](https://img.shields.io/travis/moneyphp/money/master.svg?style=flat-square)](https://travis-ci.org/moneyphp/money)
|
5 |
-
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/moneyphp/money.svg?style=flat-square)](https://scrutinizer-ci.com/g/moneyphp/money)
|
6 |
-
[![Quality Score](https://img.shields.io/scrutinizer/g/moneyphp/money.svg?style=flat-square)](https://scrutinizer-ci.com/g/moneyphp/money)
|
7 |
-
[![Total Downloads](https://img.shields.io/packagist/dt/moneyphp/money.svg?style=flat-square)](https://packagist.org/packages/moneyphp/money)
|
8 |
-
|
9 |
-
[![Email](https://img.shields.io/badge/email-team@moneyphp.org-blue.svg?style=flat-square)](mailto:team@moneyphp.org)
|
10 |
-
|
11 |
-
![Money PHP](/resources/logo.png?raw=true)
|
12 |
-
|
13 |
-
PHP library to make working with money safer, easier, and fun!
|
14 |
-
|
15 |
-
> "If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- [Bill Karwin](https://twitter.com/billkarwin/status/347561901460447232)
|
16 |
-
|
17 |
-
In short: You shouldn't represent monetary values by a float. Wherever
|
18 |
-
you need to represent money, use this Money value object. Since version
|
19 |
-
3.0 this library uses [strings internally](https://github.com/moneyphp/money/pull/136)
|
20 |
-
in order to support unlimited integers.
|
21 |
-
|
22 |
-
```php
|
23 |
-
<?php
|
24 |
-
|
25 |
-
use Money\Money;
|
26 |
-
|
27 |
-
$fiveEur = Money::EUR(500);
|
28 |
-
$tenEur = $fiveEur->add($fiveEur);
|
29 |
-
|
30 |
-
list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));
|
31 |
-
assert($part1->equals(Money::EUR(334)));
|
32 |
-
assert($part2->equals(Money::EUR(333)));
|
33 |
-
assert($part3->equals(Money::EUR(333)));
|
34 |
-
```
|
35 |
-
|
36 |
-
The documentation is available at http://moneyphp.org
|
37 |
-
|
38 |
-
|
39 |
-
## Requirements
|
40 |
-
|
41 |
-
PHP 5.6+. Other than that, this library has no external requirements. MoneyPHP will not provide any support to
|
42 |
-
PHP versions that are [not supported by the language itself](http://php.net/supported-versions.php). There might be
|
43 |
-
additional dependencies for specific feature, e.g. the Swap exchange implementation, check the documentation for more information.
|
44 |
-
|
45 |
-
|
46 |
-
## Install
|
47 |
-
|
48 |
-
Via Composer
|
49 |
-
|
50 |
-
```bash
|
51 |
-
$ composer require moneyphp/money
|
52 |
-
```
|
53 |
-
|
54 |
-
|
55 |
-
## Features
|
56 |
-
|
57 |
-
- JSON Serialization
|
58 |
-
- Big integer support utilizing different, transparent calculation logic upon availability (bcmath, gmp, plain php)
|
59 |
-
- Money formatting (including intl formatter)
|
60 |
-
- Currency repositories (ISO currencies included)
|
61 |
-
- Money exchange (including [Swap](http://swap.voutzinos.org) implementation)
|
62 |
-
|
63 |
-
|
64 |
-
## Documentation
|
65 |
-
|
66 |
-
Please see the [official documentation](http://moneyphp.org).
|
67 |
-
|
68 |
-
|
69 |
-
## Testing
|
70 |
-
|
71 |
-
We try to follow BDD and TDD, as such we use both [phpspec](http://www.phpspec.net) and [phpunit](https://phpunit.de) to test this library.
|
72 |
-
|
73 |
-
```bash
|
74 |
-
$ composer test
|
75 |
-
```
|
76 |
-
|
77 |
-
### Running the tests in Docker
|
78 |
-
|
79 |
-
Money requires a set of dependencies, so you might want to run it in Docker.
|
80 |
-
|
81 |
-
First, build the image locally:
|
82 |
-
|
83 |
-
```bash
|
84 |
-
$ docker build -t moneyphp .
|
85 |
-
```
|
86 |
-
|
87 |
-
Then run the tests:
|
88 |
-
|
89 |
-
```bash
|
90 |
-
$ docker run --rm -it -v $PWD:/app -w /app moneyphp vendor/bin/phpunit --exclude-group segmentation
|
91 |
-
```
|
92 |
-
|
93 |
-
|
94 |
-
## Contributing
|
95 |
-
|
96 |
-
We would love to see you helping us to make this library better and better.
|
97 |
-
Please keep in mind we do not use suffixes and prefixes in class names,
|
98 |
-
so not `CurrenciesInterface`, but `Currencies`. Other than that, Style CI will help you
|
99 |
-
using the same code style as we are using. Please provide tests when creating a PR and clear descriptions of bugs when filing issues.
|
100 |
-
|
101 |
-
|
102 |
-
## Security
|
103 |
-
|
104 |
-
If you discover any security related issues, please contact us at [team@moneyphp.org](mailto:team@moneyphp.org).
|
105 |
-
|
106 |
-
|
107 |
-
## License
|
108 |
-
|
109 |
-
The MIT License (MIT). Please see [License File](LICENSE) for more information.
|
110 |
-
|
111 |
-
|
112 |
-
## Acknowledgements
|
113 |
-
|
114 |
-
This library is heavily inspired by [Martin Fowler's Money pattern](http://martinfowler.com/eaaCatalog/money.html).
|
115 |
-
A special remark goes to [Mathias Verraes](https://github.com/mathiasverraes), without his contributions,
|
116 |
-
in code and via his [blog](http://verraes.net/#blog), this library would not be where it stands now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2011-2016 Jordi Boggiano
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
-
to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in all
|
11 |
-
copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/README.md
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
# Monolog - Logging for PHP [![Build Status](https://img.shields.io/travis/Seldaek/monolog.svg)](https://travis-ci.org/Seldaek/monolog)
|
2 |
-
|
3 |
-
[![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
|
4 |
-
[![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
|
5 |
-
|
6 |
-
|
7 |
-
Monolog sends your logs to files, sockets, inboxes, databases and various
|
8 |
-
web services. See the complete list of handlers below. Special handlers
|
9 |
-
allow you to build advanced logging strategies.
|
10 |
-
|
11 |
-
This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
12 |
-
interface that you can type-hint against in your own libraries to keep
|
13 |
-
a maximum of interoperability. You can also use it in your applications to
|
14 |
-
make sure you can always use another compatible logger at a later time.
|
15 |
-
As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels.
|
16 |
-
Internally Monolog still uses its own level scheme since it predates PSR-3.
|
17 |
-
|
18 |
-
## Installation
|
19 |
-
|
20 |
-
Install the latest version with
|
21 |
-
|
22 |
-
```bash
|
23 |
-
$ composer require monolog/monolog
|
24 |
-
```
|
25 |
-
|
26 |
-
## Basic Usage
|
27 |
-
|
28 |
-
```php
|
29 |
-
<?php
|
30 |
-
|
31 |
-
use Monolog\Logger;
|
32 |
-
use Monolog\Handler\StreamHandler;
|
33 |
-
|
34 |
-
// create a log channel
|
35 |
-
$log = new Logger('name');
|
36 |
-
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
|
37 |
-
|
38 |
-
// add records to the log
|
39 |
-
$log->addWarning('Foo');
|
40 |
-
$log->addError('Bar');
|
41 |
-
```
|
42 |
-
|
43 |
-
## Documentation
|
44 |
-
|
45 |
-
- [Usage Instructions](doc/01-usage.md)
|
46 |
-
- [Handlers, Formatters and Processors](doc/02-handlers-formatters-processors.md)
|
47 |
-
- [Utility classes](doc/03-utilities.md)
|
48 |
-
- [Extending Monolog](doc/04-extending.md)
|
49 |
-
|
50 |
-
## Third Party Packages
|
51 |
-
|
52 |
-
Third party handlers, formatters and processors are
|
53 |
-
[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
|
54 |
-
can also add your own there if you publish one.
|
55 |
-
|
56 |
-
## About
|
57 |
-
|
58 |
-
### Requirements
|
59 |
-
|
60 |
-
- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM.
|
61 |
-
|
62 |
-
### Submitting bugs and feature requests
|
63 |
-
|
64 |
-
Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues)
|
65 |
-
|
66 |
-
### Framework Integrations
|
67 |
-
|
68 |
-
- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
69 |
-
can be used very easily with Monolog since it implements the interface.
|
70 |
-
- [Symfony2](http://symfony.com) comes out of the box with Monolog.
|
71 |
-
- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog.
|
72 |
-
- [Laravel 4 & 5](http://laravel.com/) come out of the box with Monolog.
|
73 |
-
- [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog.
|
74 |
-
- [PPI](http://www.ppi.io/) comes out of the box with Monolog.
|
75 |
-
- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin.
|
76 |
-
- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer.
|
77 |
-
- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog.
|
78 |
-
- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog.
|
79 |
-
- [Nette Framework](http://nette.org/en/) can be used with Monolog via [Kdyby/Monolog](https://github.com/Kdyby/Monolog) extension.
|
80 |
-
- [Proton Micro Framework](https://github.com/alexbilbie/Proton) comes out of the box with Monolog.
|
81 |
-
|
82 |
-
### Author
|
83 |
-
|
84 |
-
Jordi Boggiano - <j.boggiano@seld.be> - <http://twitter.com/seldaek><br />
|
85 |
-
See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project.
|
86 |
-
|
87 |
-
### License
|
88 |
-
|
89 |
-
Monolog is licensed under the MIT License - see the `LICENSE` file for details
|
90 |
-
|
91 |
-
### Acknowledgements
|
92 |
-
|
93 |
-
This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/)
|
94 |
-
library, although most concepts have been adjusted to fit to the PHP world.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Fixtures/.gitkeep
DELETED
File without changes
|
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/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2012 PHP Framework Interoperability Group
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is
|
8 |
-
furnished to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in
|
11 |
-
all copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/README.md
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
PSR Log
|
2 |
-
=======
|
3 |
-
|
4 |
-
This repository holds all interfaces/classes/traits related to
|
5 |
-
[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
|
6 |
-
|
7 |
-
Note that this is not a logger of its own. It is merely an interface that
|
8 |
-
describes a logger. See the specification for more details.
|
9 |
-
|
10 |
-
Installation
|
11 |
-
------------
|
12 |
-
|
13 |
-
```bash
|
14 |
-
composer require psr/log
|
15 |
-
```
|
16 |
-
|
17 |
-
Usage
|
18 |
-
-----
|
19 |
-
|
20 |
-
If you need a logger, you can use the interface like this:
|
21 |
-
|
22 |
-
```php
|
23 |
-
<?php
|
24 |
-
|
25 |
-
use Psr\Log\LoggerInterface;
|
26 |
-
|
27 |
-
class Foo
|
28 |
-
{
|
29 |
-
private $logger;
|
30 |
-
|
31 |
-
public function __construct(LoggerInterface $logger = null)
|
32 |
-
{
|
33 |
-
$this->logger = $logger;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function doSomething()
|
37 |
-
{
|
38 |
-
if ($this->logger) {
|
39 |
-
$this->logger->info('Doing work');
|
40 |
-
}
|
41 |
-
|
42 |
-
// do something useful
|
43 |
-
}
|
44 |
-
}
|
45 |
-
```
|
46 |
-
|
47 |
-
You can then pick one of the implementations of the interface to get a logger.
|
48 |
-
|
49 |
-
If you want to implement the interface, you can require this package and
|
50 |
-
implement `Psr\Log\LoggerInterface` in your code. Please read the
|
51 |
-
[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
52 |
-
for details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/simple-cache/README.md
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
PHP FIG Simple Cache PSR
|
2 |
-
========================
|
3 |
-
|
4 |
-
This repository holds all interfaces related to PSR-16.
|
5 |
-
|
6 |
-
Note that this is not a cache implementation of its own. It is merely an interface that describes a cache implementation. See [the specification](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md) for more details.
|
7 |
-
|
8 |
-
You can find implementations of the specification by looking for packages providing the [psr/simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation) virtual package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-abtesting/README.md
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-abtesting/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-abtesting/pipelines)
|
2 |
-
[![coverage report](https://gitlab.com/wpdesk/wp-abtesting/badges/master/coverage.svg)](https://gitlab.com/wpdesk/wp-abtesting/commits/master)
|
3 |
-
[![Latest Stable Version](https://poser.pugx.org/wpdesk/wp-abtesting/v/stable)](https://packagist.org/packages/wpdesk/wp-abtesting)
|
4 |
-
[![Total Downloads](https://poser.pugx.org/wpdesk/wp-abtesting/downloads)](https://packagist.org/packages/wpdesk/wp-abtesting)
|
5 |
-
[![Latest Unstable Version](https://poser.pugx.org/wpdesk/wp-abtesting/v/unstable)](https://packagist.org/packages/wpdesk/wp-abtesting)
|
6 |
-
[![License](https://poser.pugx.org/wpdesk/wp-abtesting/license)](https://packagist.org/packages/wpdesk/wp-abtesting)
|
7 |
-
|
8 |
-
WordPress Library to facilitate AB Testing
|
9 |
-
===================================================
|
10 |
-
|
11 |
-
|
12 |
-
## Requirements
|
13 |
-
|
14 |
-
PHP 5.6 or later.
|
15 |
-
|
16 |
-
## Composer
|
17 |
-
|
18 |
-
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
|
19 |
-
|
20 |
-
```bash
|
21 |
-
composer require wpdesk/wp-abtesting
|
22 |
-
```
|
23 |
-
|
24 |
-
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
|
25 |
-
|
26 |
-
```php
|
27 |
-
require_once 'vendor/autoload.php';
|
28 |
-
```
|
29 |
-
|
30 |
-
## Compatiblity between plugins
|
31 |
-
|
32 |
-
To ensure that always the latest and valid version of composer libraries are loaded in WP env you should use a solution
|
33 |
-
that ensure support between plugins and at least decreases the change that something would break. At the moment we recommend
|
34 |
-
using wpdesk/wp-autoloader.
|
35 |
-
|
36 |
-
|
37 |
-
## Manual instalation
|
38 |
-
|
39 |
-
If you do not wish to use Composer and wpdesk/wp-autoloader, you probably should stop using any existing library as it breaks compatibility between plugins.
|
40 |
-
|
41 |
-
## Getting Started
|
42 |
-
|
43 |
-
## Project documentation
|
44 |
-
|
45 |
-
PHPDoc: https://wpdesk.gitlab.io/wp-abtesting/index.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-autoloader/.gitlab-ci.yml
DELETED
@@ -1,310 +0,0 @@
|
|
1 |
-
variables:
|
2 |
-
WPDESK_CI_VERSION: 1.10.19
|
3 |
-
MYSQL_ROOT_PASSWORD: mysql
|
4 |
-
MYSQL_DATABASE: wptest
|
5 |
-
MYSQL_USER: mysql
|
6 |
-
MYSQL_PASSWORD: mysql
|
7 |
-
MYSQL_INNODB_LOG_BUFFER_SIZE: 32M
|
8 |
-
PHP_ERROR_REPORTING: E_ALL
|
9 |
-
COMPOSER_ALLOW_SUPERUSER: 1
|
10 |
-
GIT_STRATEGY: fetch
|
11 |
-
ACCEPTANCE_ERROR_PATH: ${CI_PROJECT_DIR}/acceptance
|
12 |
-
|
13 |
-
stages:
|
14 |
-
- tools
|
15 |
-
- tests
|
16 |
-
- pre-deploy
|
17 |
-
- deploy
|
18 |
-
|
19 |
-
.template: &job-test-template
|
20 |
-
stage: tests
|
21 |
-
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
22 |
-
|
23 |
-
.template: &job-test-integration-template
|
24 |
-
<<: *job-test-template
|
25 |
-
services:
|
26 |
-
- mysql:5.6
|
27 |
-
script:
|
28 |
-
- echo ${WPDESK_CI_VERSION}
|
29 |
-
- ls -l
|
30 |
-
- php --version
|
31 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
32 |
-
- cat /tmp/woocommerce/woocommerce.php
|
33 |
-
- composer update --no-progress
|
34 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
35 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --coverage-text --colors=never
|
36 |
-
only:
|
37 |
-
- tags
|
38 |
-
|
39 |
-
.template: &job-test-integration-template-fast
|
40 |
-
<<: *job-test-integration-template
|
41 |
-
script:
|
42 |
-
- echo ${WPDESK_CI_VERSION}
|
43 |
-
- ls -l
|
44 |
-
- php --version
|
45 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
46 |
-
- cat /tmp/woocommerce/woocommerce.php
|
47 |
-
- composer update --no-progress
|
48 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
49 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --no-coverage
|
50 |
-
except:
|
51 |
-
- tags
|
52 |
-
only:
|
53 |
-
|
54 |
-
.template: &job-test-unit-template
|
55 |
-
<<: *job-test-template
|
56 |
-
script:
|
57 |
-
- echo ${WPDESK_CI_VERSION}
|
58 |
-
- ls -l
|
59 |
-
- php --version
|
60 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
61 |
-
- cat /tmp/woocommerce/woocommerce.php
|
62 |
-
- composer update --no-progress
|
63 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --coverage-text --colors=never
|
64 |
-
only:
|
65 |
-
- tags
|
66 |
-
|
67 |
-
.template: &job-test-unit-template-fast
|
68 |
-
<<: *job-test-unit-template
|
69 |
-
script:
|
70 |
-
- echo ${WPDESK_CI_VERSION}
|
71 |
-
- ls -l
|
72 |
-
- php --version
|
73 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
74 |
-
- cat /tmp/woocommerce/woocommerce.php
|
75 |
-
- composer update --no-progress
|
76 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --no-coverage
|
77 |
-
except:
|
78 |
-
- tags
|
79 |
-
only:
|
80 |
-
|
81 |
-
.template: &job-deploy-template
|
82 |
-
image: wpdesknet/amazon-svn-deploy
|
83 |
-
stage: deploy
|
84 |
-
dependencies:
|
85 |
-
- build to deploy
|
86 |
-
- unit test lastest coverage
|
87 |
-
- integration test lastest coverage
|
88 |
-
retry: 2
|
89 |
-
when: manual
|
90 |
-
only:
|
91 |
-
- tags
|
92 |
-
|
93 |
-
before_script:
|
94 |
-
- cd ${CI_PROJECT_DIR}
|
95 |
-
|
96 |
-
phpmetric metrics:
|
97 |
-
stage: tools
|
98 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
99 |
-
allow_failure: true
|
100 |
-
when: manual
|
101 |
-
artifacts:
|
102 |
-
when: always
|
103 |
-
expire_in: 1 month
|
104 |
-
name: "metrics"
|
105 |
-
paths:
|
106 |
-
- ${CI_PROJECT_DIR}/phpmetric
|
107 |
-
script:
|
108 |
-
- echo ${WPDESK_CI_VERSION}
|
109 |
-
- composer require phpmetrics/phpmetrics
|
110 |
-
- composer update --no-progress
|
111 |
-
- php ./vendor/bin/phpmetrics --report-html=phpmetric .
|
112 |
-
|
113 |
-
churn metrics:
|
114 |
-
stage: tools
|
115 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
116 |
-
allow_failure: true
|
117 |
-
when: manual
|
118 |
-
script:
|
119 |
-
- echo ${WPDESK_CI_VERSION}
|
120 |
-
- composer require bmitch/churn-php
|
121 |
-
- composer update --no-progress
|
122 |
-
- vendor/bin/churn run classes inc
|
123 |
-
|
124 |
-
#code style test:
|
125 |
-
# stage: tests
|
126 |
-
# image: wpdesknet/phpunit-woocommerce:0-0
|
127 |
-
# allow_failure: true
|
128 |
-
# script:
|
129 |
-
# - echo ${WPDESK_CI_VERSION}
|
130 |
-
# - composer update --no-progress
|
131 |
-
# - vendor/bin/phpcs
|
132 |
-
|
133 |
-
unit test lastest:
|
134 |
-
<<: *job-test-unit-template-fast
|
135 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
136 |
-
|
137 |
-
integration test lastest:
|
138 |
-
<<: *job-test-integration-template-fast
|
139 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
140 |
-
|
141 |
-
unit test lastest coverage:
|
142 |
-
<<: *job-test-unit-template
|
143 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
144 |
-
|
145 |
-
integration test lastest coverage:
|
146 |
-
<<: *job-test-integration-template
|
147 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
148 |
-
|
149 |
-
integration test php7-1 wc-1:
|
150 |
-
<<: *job-test-integration-template-fast
|
151 |
-
image: wpdesknet/phpunit-woocommerce:1-1
|
152 |
-
|
153 |
-
integration test php7 wc-2:
|
154 |
-
<<: *job-test-integration-template-fast
|
155 |
-
image: wpdesknet/phpunit-woocommerce:2-2
|
156 |
-
|
157 |
-
integration test php-7 wc-3:
|
158 |
-
<<: *job-test-integration-template-fast
|
159 |
-
image: wpdesknet/phpunit-woocommerce:2-3
|
160 |
-
|
161 |
-
integration test php5-6:
|
162 |
-
<<: *job-test-integration-template-fast
|
163 |
-
image: wpdesknet/phpunit-woocommerce:3-0
|
164 |
-
|
165 |
-
integration test php5-5:
|
166 |
-
<<: *job-test-integration-template-fast
|
167 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
168 |
-
|
169 |
-
integration test current woocommerce:
|
170 |
-
<<: *job-test-integration-template-fast
|
171 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
172 |
-
allow_failure: true
|
173 |
-
before_script:
|
174 |
-
- cd /tmp
|
175 |
-
- rm -rf woocommerce
|
176 |
-
- git clone https://github.com/woocommerce/woocommerce.git
|
177 |
-
- cd ${CI_PROJECT_DIR}
|
178 |
-
|
179 |
-
acceptance test:
|
180 |
-
image: wpdesknet/node
|
181 |
-
variables:
|
182 |
-
CI_DEBUG_SERVICES: trace
|
183 |
-
services:
|
184 |
-
- name: mysql:5.6
|
185 |
-
alias: mysqltests
|
186 |
-
- name: wpdesknet/apache-woocommerce:latest
|
187 |
-
alias: wootests
|
188 |
-
- name: selenium/standalone-chrome
|
189 |
-
alias: selenium
|
190 |
-
artifacts:
|
191 |
-
when: always
|
192 |
-
expire_in: 1 day
|
193 |
-
name: "error logs"
|
194 |
-
paths:
|
195 |
-
- ${CI_PROJECT_DIR}/acceptance
|
196 |
-
stage: tests
|
197 |
-
allow_failure: true
|
198 |
-
script:
|
199 |
-
- cd ${CI_PROJECT_DIR}
|
200 |
-
- composer update --no-progress --no-dev
|
201 |
-
- if [[ -f ${CI_PROJECT_DIR}/tests/acceptance/prepare.sh ]]; then sh ${CI_PROJECT_DIR}/tests/acceptance/prepare.sh; fi
|
202 |
-
|
203 |
-
- export MYSQL_IP=$(awk '/^[[:space:]]*($|#)/{next} /mysqltests/{print $1; exit}' /etc/hosts)
|
204 |
-
- export WOOTESTS_IP=$(awk '/^[[:space:]]*($|#)/{next} /wootests/{print $1; exit}' /etc/hosts)
|
205 |
-
- echo "http://wootests/wpdesk_init.php?mysql_ip=${MYSQL_IP}&wootests_ip=${WOOTESTS_IP}"
|
206 |
-
- wget -O /tmp/wpdesk_init.txt "http://wootests/wpdesk_init.php?mysql_ip=${MYSQL_IP}&wootests_ip=${WOOTESTS_IP}"
|
207 |
-
- tail -50 /tmp/wpdesk_init.txt
|
208 |
-
|
209 |
-
- sh /tmp/clone.sh git@gitlab.com:wpdesk/plugins-tests.git /tmp/tests headless
|
210 |
-
- cd /tmp/tests
|
211 |
-
- npm install
|
212 |
-
- npm install -g grunt-cli
|
213 |
-
- cd node_modules/.bin
|
214 |
-
- ./webdriver-manager update
|
215 |
-
- cd ../
|
216 |
-
- mkdir -p ${CI_PROJECT_DIR}/acceptance/reports/html/screenshot
|
217 |
-
- grunt chrome-${CI_PROJECT_NAME}
|
218 |
-
|
219 |
-
|
220 |
-
apigen docs:
|
221 |
-
image:
|
222 |
-
name: wpdesknet/apigen
|
223 |
-
stage: pre-deploy
|
224 |
-
artifacts:
|
225 |
-
expire_in: 1 day
|
226 |
-
name: "docs"
|
227 |
-
paths:
|
228 |
-
- docs/
|
229 |
-
script:
|
230 |
-
- echo ${WPDESK_CI_VERSION}
|
231 |
-
- ls -l
|
232 |
-
- /app/vendor/bin/apigen generate
|
233 |
-
- php /app/hooks-docs.php ${CI_PROJECT_DIR}
|
234 |
-
only:
|
235 |
-
- tags
|
236 |
-
|
237 |
-
pages:
|
238 |
-
stage: deploy
|
239 |
-
dependencies:
|
240 |
-
- apigen docs
|
241 |
-
script:
|
242 |
-
- rm -rf public
|
243 |
-
- mv docs/ public/
|
244 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Dokumentacja projektu ${CI_PROJECT_NAME} w wersji ${CI_COMMIT_REF_NAME} umieszczona w <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}/pages|pages> \", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
245 |
-
artifacts:
|
246 |
-
expire_in: 1 day
|
247 |
-
paths:
|
248 |
-
- public
|
249 |
-
only:
|
250 |
-
- tags
|
251 |
-
|
252 |
-
build to deploy:
|
253 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
254 |
-
stage: pre-deploy
|
255 |
-
artifacts:
|
256 |
-
expire_in: 1 month
|
257 |
-
name: "production release"
|
258 |
-
paths:
|
259 |
-
- release
|
260 |
-
- release.zip
|
261 |
-
script:
|
262 |
-
- echo ${WPDESK_CI_VERSION}
|
263 |
-
- php --version
|
264 |
-
- ls -l
|
265 |
-
- /tmp/set_version.sh ${CI_COMMIT_REF_NAME}
|
266 |
-
- rm -rf ${CI_PROJECT_DIR}/release ${CI_PROJECT_DIR}/release.zip /tmp/release
|
267 |
-
- mkdir /tmp/release
|
268 |
-
- mkdir -p ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
269 |
-
- cp -rf ${CI_PROJECT_DIR}/* /tmp/release
|
270 |
-
- cp -rf /tmp/release/* ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
271 |
-
- cd ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
272 |
-
- composer install --no-dev --no-progress --optimize-autoloader
|
273 |
-
- rm -rf build-coverage release tests docs .git .editorconfig .gitignore .gitlab-ci.yml apigen.neon phpunit.xml acceptance test_soap.php .gitlab
|
274 |
-
- rm -rf composer.json composer.lock phpcs.xml.dist phpunit-integration.xml phpunit-unit.xml composer.phar wp-cli.phar
|
275 |
-
- cd ../
|
276 |
-
- zip -r -q ../release.zip ./
|
277 |
-
only:
|
278 |
-
- tags
|
279 |
-
|
280 |
-
deploy to shop:
|
281 |
-
<<: *job-deploy-template
|
282 |
-
script:
|
283 |
-
- echo ${WPDESK_CI_VERSION}
|
284 |
-
- /tmp/deploy_shop.sh ${CI_PROJECT_NAME} release.zip ${CI_PROJECT_NAME}.zip
|
285 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do sklepu w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
286 |
-
environment:
|
287 |
-
name: wpdesk shop
|
288 |
-
url: https://wpdeskplugin.s3.amazonaws.com/${CI_PROJECT_NAME}.zip
|
289 |
-
|
290 |
-
deploy to demo:
|
291 |
-
<<: *job-deploy-template
|
292 |
-
script:
|
293 |
-
- echo ${WPDESK_CI_VERSION}
|
294 |
-
- /tmp/deploy_demo.sh release/${CI_PROJECT_NAME} ${CI_PROJECT_NAME}
|
295 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do demo w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
296 |
-
environment:
|
297 |
-
name: wpdesk demo
|
298 |
-
url: https://demo.wpdesk.org
|
299 |
-
|
300 |
-
deploy to repository:
|
301 |
-
<<: *job-deploy-template
|
302 |
-
script:
|
303 |
-
- echo ${WPDESK_CI_VERSION}
|
304 |
-
- rm -rf /tmp/svn-repository
|
305 |
-
- mkdir /tmp/svn-repository
|
306 |
-
- /tmp/deploy_repository.sh ${CI_PROJECT_NAME} ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME} /tmp/svn-repository
|
307 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do repozytorium WP w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
308 |
-
environment:
|
309 |
-
name: wordpress repository
|
310 |
-
url: https://downloads.wordpress.org/plugin/${CI_PROJECT_NAME}.${CI_COMMIT_REF_NAME}.zip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-autoloader/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
MIT License
|
2 |
-
|
3 |
-
Copyright (c) 2018 WP Desk
|
4 |
-
|
5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
-
of this software and associated documentation files (the "Software"), to deal
|
7 |
-
in the Software without restriction, including without limitation the rights
|
8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
-
copies of the Software, and to permit persons to whom the Software is
|
10 |
-
furnished to do so, subject to the following conditions:
|
11 |
-
|
12 |
-
The above copyright notice and this permission notice shall be included in all
|
13 |
-
copies or substantial portions of the Software.
|
14 |
-
|
15 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
-
SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-autoloader/tests/docker-compose.yaml
DELETED
@@ -1,172 +0,0 @@
|
|
1 |
-
version: '2.0'
|
2 |
-
|
3 |
-
services:
|
4 |
-
|
5 |
-
wordpress:
|
6 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
7 |
-
volumes:
|
8 |
-
- .././:/opt/project
|
9 |
-
depends_on:
|
10 |
-
- mysql0
|
11 |
-
environment:
|
12 |
-
WORDPRESS_DB_NAME: wptest
|
13 |
-
WORDPRESS_DB_USER: mysql
|
14 |
-
WORDPRESS_DB_PASSWORD: mysql
|
15 |
-
WORDPRESS_DB_HOST: mysql0
|
16 |
-
|
17 |
-
wordpress-0-1:
|
18 |
-
image: wpdesknet/phpunit-woocommerce:0-1
|
19 |
-
volumes:
|
20 |
-
- .././:/opt/project
|
21 |
-
depends_on:
|
22 |
-
- mysql1
|
23 |
-
environment:
|
24 |
-
WORDPRESS_DB_NAME: wptest
|
25 |
-
WORDPRESS_DB_USER: mysql
|
26 |
-
WORDPRESS_DB_PASSWORD: mysql
|
27 |
-
WORDPRESS_DB_HOST: mysql1
|
28 |
-
|
29 |
-
wordpress-0-2:
|
30 |
-
image: wpdesknet/phpunit-woocommerce:0-2
|
31 |
-
volumes:
|
32 |
-
- .././:/opt/project
|
33 |
-
depends_on:
|
34 |
-
- mysql2
|
35 |
-
environment:
|
36 |
-
WORDPRESS_DB_NAME: wptest
|
37 |
-
WORDPRESS_DB_USER: mysql
|
38 |
-
WORDPRESS_DB_PASSWORD: mysql
|
39 |
-
WORDPRESS_DB_HOST: mysql2
|
40 |
-
|
41 |
-
wordpress-0-3:
|
42 |
-
image: wpdesknet/phpunit-woocommerce:0-3
|
43 |
-
volumes:
|
44 |
-
- .././:/opt/project
|
45 |
-
depends_on:
|
46 |
-
- mysql3
|
47 |
-
environment:
|
48 |
-
WORDPRESS_DB_NAME: wptest
|
49 |
-
WORDPRESS_DB_USER: mysql
|
50 |
-
WORDPRESS_DB_PASSWORD: mysql
|
51 |
-
WORDPRESS_DB_HOST: mysql3
|
52 |
-
|
53 |
-
wordpress-0-4:
|
54 |
-
image: wpdesknet/phpunit-woocommerce:0-4
|
55 |
-
volumes:
|
56 |
-
- .././:/opt/project
|
57 |
-
depends_on:
|
58 |
-
- mysql4
|
59 |
-
environment:
|
60 |
-
WORDPRESS_DB_NAME: wptest
|
61 |
-
WORDPRESS_DB_USER: mysql
|
62 |
-
WORDPRESS_DB_PASSWORD: mysql
|
63 |
-
WORDPRESS_DB_HOST: mysql4
|
64 |
-
|
65 |
-
wordpress-0-5:
|
66 |
-
image: wpdesknet/phpunit-woocommerce:0-5
|
67 |
-
volumes:
|
68 |
-
- .././:/opt/project
|
69 |
-
depends_on:
|
70 |
-
- mysql5
|
71 |
-
environment:
|
72 |
-
WORDPRESS_DB_NAME: wptest
|
73 |
-
WORDPRESS_DB_USER: mysql
|
74 |
-
WORDPRESS_DB_PASSWORD: mysql
|
75 |
-
WORDPRESS_DB_HOST: mysql5
|
76 |
-
|
77 |
-
wordpress-1-0:
|
78 |
-
image: wpdesknet/phpunit-woocommerce:1-0
|
79 |
-
volumes:
|
80 |
-
- .././:/opt/project
|
81 |
-
depends_on:
|
82 |
-
- mysql0
|
83 |
-
environment:
|
84 |
-
WORDPRESS_DB_NAME: wptest
|
85 |
-
WORDPRESS_DB_USER: mysql
|
86 |
-
WORDPRESS_DB_PASSWORD: mysql
|
87 |
-
WORDPRESS_DB_HOST: mysql0
|
88 |
-
|
89 |
-
wordpress-2-0:
|
90 |
-
image: wpdesknet/phpunit-woocommerce:2-0
|
91 |
-
volumes:
|
92 |
-
- .././:/opt/project
|
93 |
-
depends_on:
|
94 |
-
- mysql0
|
95 |
-
environment:
|
96 |
-
WORDPRESS_DB_NAME: wptest
|
97 |
-
WORDPRESS_DB_USER: mysql
|
98 |
-
WORDPRESS_DB_PASSWORD: mysql
|
99 |
-
WORDPRESS_DB_HOST: mysql0
|
100 |
-
|
101 |
-
wordpress-3-0:
|
102 |
-
image: wpdesknet/phpunit-woocommerce:3-0
|
103 |
-
volumes:
|
104 |
-
- .././:/opt/project
|
105 |
-
depends_on:
|
106 |
-
- mysql0
|
107 |
-
environment:
|
108 |
-
WORDPRESS_DB_NAME: wptest
|
109 |
-
WORDPRESS_DB_USER: mysql
|
110 |
-
WORDPRESS_DB_PASSWORD: mysql
|
111 |
-
WORDPRESS_DB_HOST: mysql0
|
112 |
-
|
113 |
-
wordpress-4-0:
|
114 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
115 |
-
volumes:
|
116 |
-
- .././:/opt/project
|
117 |
-
depends_on:
|
118 |
-
- mysql0
|
119 |
-
environment:
|
120 |
-
WORDPRESS_DB_NAME: wptest
|
121 |
-
WORDPRESS_DB_USER: mysql
|
122 |
-
WORDPRESS_DB_PASSWORD: mysql
|
123 |
-
WORDPRESS_DB_HOST: mysql0
|
124 |
-
|
125 |
-
mysql0:
|
126 |
-
image: mysql:5.7
|
127 |
-
environment:
|
128 |
-
MYSQL_ROOT_PASSWORD: mysql
|
129 |
-
MYSQL_DATABASE: wptest
|
130 |
-
MYSQL_USER: mysql
|
131 |
-
MYSQL_PASSWORD: mysql
|
132 |
-
|
133 |
-
mysql1:
|
134 |
-
image: mysql:5.7
|
135 |
-
environment:
|
136 |
-
MYSQL_ROOT_PASSWORD: mysql
|
137 |
-
MYSQL_DATABASE: wptest
|
138 |
-
MYSQL_USER: mysql
|
139 |
-
MYSQL_PASSWORD: mysql
|
140 |
-
|
141 |
-
mysql2:
|
142 |
-
image: mysql:5.7
|
143 |
-
environment:
|
144 |
-
MYSQL_ROOT_PASSWORD: mysql
|
145 |
-
MYSQL_DATABASE: wptest
|
146 |
-
MYSQL_USER: mysql
|
147 |
-
MYSQL_PASSWORD: mysql
|
148 |
-
|
149 |
-
mysql3:
|
150 |
-
image: mysql:5.7
|
151 |
-
environment:
|
152 |
-
MYSQL_ROOT_PASSWORD: mysql
|
153 |
-
MYSQL_DATABASE: wptest
|
154 |
-
MYSQL_USER: mysql
|
155 |
-
MYSQL_PASSWORD: mysql
|
156 |
-
|
157 |
-
mysql4:
|
158 |
-
image: mysql:5.7
|
159 |
-
environment:
|
160 |
-
MYSQL_ROOT_PASSWORD: mysql
|
161 |
-
MYSQL_DATABASE: wptest
|
162 |
-
MYSQL_USER: mysql
|
163 |
-
MYSQL_PASSWORD: mysql
|
164 |
-
|
165 |
-
mysql5:
|
166 |
-
image: mysql:5.7
|
167 |
-
environment:
|
168 |
-
MYSQL_ROOT_PASSWORD: mysql
|
169 |
-
MYSQL_DATABASE: wptest
|
170 |
-
MYSQL_USER: mysql
|
171 |
-
MYSQL_PASSWORD: mysql
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-autoloader/tests/integration/bootstrap.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
|
4 |
-
ini_set('display_errors', '1');
|
5 |
-
ini_set('display_startup_errors', '1');
|
6 |
-
|
7 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
8 |
-
|
9 |
-
// disable xdebug backtrace
|
10 |
-
if ( function_exists( 'xdebug_disable' ) ) {
|
11 |
-
xdebug_disable();
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
15 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
16 |
-
} else {
|
17 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR );
|
18 |
-
}
|
19 |
-
|
20 |
-
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
|
21 |
-
|
22 |
-
tests_add_filter( 'muplugins_loaded', function () {
|
23 |
-
}, 100 );
|
24 |
-
|
25 |
-
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
|
26 |
-
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
|
27 |
-
|
28 |
-
do_action('plugins_loaded');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-autoloader/tests/unit/bootstrap.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPUnit bootstrap file
|
4 |
-
*/
|
5 |
-
|
6 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
7 |
-
|
8 |
-
WP_Mock::setUsePatchwork( true );
|
9 |
-
WP_Mock::bootstrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/.gitlab-ci.yml
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
variables:
|
2 |
-
WPDESK_CI_VERSION: 1.10.19-library
|
3 |
-
MYSQL_ROOT_PASSWORD: mysql
|
4 |
-
MYSQL_DATABASE: wptest
|
5 |
-
MYSQL_USER: mysql
|
6 |
-
MYSQL_PASSWORD: mysql
|
7 |
-
MYSQL_INNODB_LOG_BUFFER_SIZE: 32M
|
8 |
-
PHP_ERROR_REPORTING: E_ALL
|
9 |
-
COMPOSER_ALLOW_SUPERUSER: 1
|
10 |
-
GIT_STRATEGY: fetch
|
11 |
-
ACCEPTANCE_ERROR_PATH: ${CI_PROJECT_DIR}/acceptance
|
12 |
-
|
13 |
-
stages:
|
14 |
-
- tools
|
15 |
-
- tests
|
16 |
-
|
17 |
-
.template: &job-test-template
|
18 |
-
stage: tests
|
19 |
-
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
20 |
-
|
21 |
-
.template: &job-test-integration-template
|
22 |
-
<<: *job-test-template
|
23 |
-
services:
|
24 |
-
- mysql:5.6
|
25 |
-
script:
|
26 |
-
- echo ${WPDESK_CI_VERSION}
|
27 |
-
- ls -l
|
28 |
-
- php --version
|
29 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
30 |
-
- cat /tmp/woocommerce/woocommerce.php
|
31 |
-
- composer update --no-progress
|
32 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
33 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --coverage-text --colors=never
|
34 |
-
only:
|
35 |
-
- tags
|
36 |
-
|
37 |
-
.template: &job-test-integration-template-fast
|
38 |
-
<<: *job-test-integration-template
|
39 |
-
script:
|
40 |
-
- echo ${WPDESK_CI_VERSION}
|
41 |
-
- ls -l
|
42 |
-
- php --version
|
43 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
44 |
-
- cat /tmp/woocommerce/woocommerce.php
|
45 |
-
- composer update --no-progress
|
46 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
47 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --no-coverage
|
48 |
-
except:
|
49 |
-
- tags
|
50 |
-
only:
|
51 |
-
|
52 |
-
.template: &job-test-unit-template
|
53 |
-
<<: *job-test-template
|
54 |
-
script:
|
55 |
-
- echo ${WPDESK_CI_VERSION}
|
56 |
-
- ls -l
|
57 |
-
- php --version
|
58 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
59 |
-
- cat /tmp/woocommerce/woocommerce.php
|
60 |
-
- composer update --no-progress
|
61 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --coverage-text --colors=never
|
62 |
-
only:
|
63 |
-
- tags
|
64 |
-
|
65 |
-
.template: &job-test-unit-template-fast
|
66 |
-
<<: *job-test-unit-template
|
67 |
-
script:
|
68 |
-
- echo ${WPDESK_CI_VERSION}
|
69 |
-
- ls -l
|
70 |
-
- php --version
|
71 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
72 |
-
- cat /tmp/woocommerce/woocommerce.php
|
73 |
-
- composer update --no-progress
|
74 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --no-coverage
|
75 |
-
except:
|
76 |
-
- tags
|
77 |
-
only:
|
78 |
-
|
79 |
-
before_script:
|
80 |
-
- cd ${CI_PROJECT_DIR}
|
81 |
-
|
82 |
-
phpmetric metrics:
|
83 |
-
stage: tools
|
84 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
85 |
-
allow_failure: true
|
86 |
-
when: manual
|
87 |
-
artifacts:
|
88 |
-
when: always
|
89 |
-
expire_in: 1 month
|
90 |
-
name: "metrics"
|
91 |
-
paths:
|
92 |
-
- ${CI_PROJECT_DIR}/phpmetric
|
93 |
-
script:
|
94 |
-
- echo ${WPDESK_CI_VERSION}
|
95 |
-
- composer require phpmetrics/phpmetrics
|
96 |
-
- composer update --no-progress
|
97 |
-
- php ./vendor/bin/phpmetrics --report-html=phpmetric .
|
98 |
-
|
99 |
-
churn metrics:
|
100 |
-
stage: tools
|
101 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
102 |
-
allow_failure: true
|
103 |
-
when: manual
|
104 |
-
script:
|
105 |
-
- echo ${WPDESK_CI_VERSION}
|
106 |
-
- composer require bmitch/churn-php
|
107 |
-
- composer update --no-progress
|
108 |
-
- vendor/bin/churn run src
|
109 |
-
|
110 |
-
unit test lastest:
|
111 |
-
<<: *job-test-unit-template-fast
|
112 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
113 |
-
|
114 |
-
integration test lastest:
|
115 |
-
<<: *job-test-integration-template-fast
|
116 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
117 |
-
|
118 |
-
unit test lastest coverage:
|
119 |
-
<<: *job-test-unit-template
|
120 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
121 |
-
|
122 |
-
integration test lastest coverage:
|
123 |
-
<<: *job-test-integration-template
|
124 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
125 |
-
|
126 |
-
integration test php7-1 wc-1:
|
127 |
-
<<: *job-test-integration-template-fast
|
128 |
-
image: wpdesknet/phpunit-woocommerce:1-1
|
129 |
-
|
130 |
-
integration test php7 wc-2:
|
131 |
-
<<: *job-test-integration-template-fast
|
132 |
-
image: wpdesknet/phpunit-woocommerce:2-2
|
133 |
-
|
134 |
-
integration test php-7 wc-3:
|
135 |
-
<<: *job-test-integration-template-fast
|
136 |
-
image: wpdesknet/phpunit-woocommerce:2-3
|
137 |
-
|
138 |
-
integration test php5-6:
|
139 |
-
<<: *job-test-integration-template-fast
|
140 |
-
image: wpdesknet/phpunit-woocommerce:3-0
|
141 |
-
|
142 |
-
integration test php5-5:
|
143 |
-
<<: *job-test-integration-template-fast
|
144 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
145 |
-
|
146 |
-
integration test current woocommerce:
|
147 |
-
<<: *job-test-integration-template-fast
|
148 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
149 |
-
allow_failure: true
|
150 |
-
before_script:
|
151 |
-
- cd /tmp
|
152 |
-
- rm -rf woocommerce
|
153 |
-
- git clone https://github.com/woocommerce/woocommerce.git
|
154 |
-
- cd ${CI_PROJECT_DIR}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
MIT License
|
2 |
-
|
3 |
-
Copyright (c) 2018 WP Desk
|
4 |
-
|
5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
-
of this software and associated documentation files (the "Software"), to deal
|
7 |
-
in the Software without restriction, including without limitation the rights
|
8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
-
copies of the Software, and to permit persons to whom the Software is
|
10 |
-
furnished to do so, subject to the following conditions:
|
11 |
-
|
12 |
-
The above copyright notice and this permission notice shall be included in all
|
13 |
-
copies or substantial portions of the Software.
|
14 |
-
|
15 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
-
SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
Wp-basic-requirements is a simple library for WordPress plugins to check if the environment meets the requirements
|
2 |
-
and if the requirements are not met shows proper notice to user.
|
3 |
-
|
4 |
-
Library have to be compatible with PHP 5.2.x as it's the lowest possible version for WordPress.
|
5 |
-
|
6 |
-
Requirements may be:
|
7 |
-
- Minimal PHP version
|
8 |
-
- Minimal WordPress version
|
9 |
-
- Minimal WooCommerce version
|
10 |
-
- Required PHP module
|
11 |
-
- Required PHP setting
|
12 |
-
- OpenSSL version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/tests/integration/bootstrap.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// disable xdebug backtrace
|
3 |
-
if ( function_exists( 'xdebug_disable' ) ) {
|
4 |
-
xdebug_disable();
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
8 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
9 |
-
} else {
|
10 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
11 |
-
}
|
12 |
-
|
13 |
-
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
|
14 |
-
|
15 |
-
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
|
16 |
-
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/tests/unit/Test_Basic_Requirement_Checker.php
DELETED
@@ -1,167 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Test_Basic_Requirement_Checker extends PHPUnit\Framework\TestCase {
|
4 |
-
const RANDOM_PLUGIN_FILE = 'file';
|
5 |
-
|
6 |
-
const RANDOM_PLUGIN_NAME = 'name';
|
7 |
-
|
8 |
-
const RANDOM_PLUGIN_TEXTDOMAIN = 'text';
|
9 |
-
|
10 |
-
const ALWAYS_VALID_PHP_VERSION = '5.2';
|
11 |
-
|
12 |
-
const ALWAYS_NOT_VALID_PHP_VERSION = '100.100';
|
13 |
-
|
14 |
-
const ALWAYS_VALID_WP_VERSION = '4.0';
|
15 |
-
|
16 |
-
const HOOK_TYPE_ACTION = 'action';
|
17 |
-
|
18 |
-
public function setUp() {
|
19 |
-
WP_Mock::setUp();
|
20 |
-
|
21 |
-
WP_Mock::wpFunction( 'get_bloginfo' )
|
22 |
-
->andReturn( self::ALWAYS_VALID_WP_VERSION );
|
23 |
-
}
|
24 |
-
|
25 |
-
public function tearDown() {
|
26 |
-
WP_Mock::tearDown();
|
27 |
-
}
|
28 |
-
|
29 |
-
public function test_php_version_check() {
|
30 |
-
$known_PHP_versions = [ '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4', '5.3', '5.2' ];
|
31 |
-
|
32 |
-
$requirements = $this->create_requirements_for_php_wp(
|
33 |
-
self::ALWAYS_VALID_PHP_VERSION,
|
34 |
-
self::ALWAYS_VALID_WP_VERSION );
|
35 |
-
|
36 |
-
foreach ( $known_PHP_versions as $version ) {
|
37 |
-
$requirements->set_min_php_require( $version );
|
38 |
-
if ( version_compare( PHP_VERSION, $version, '>=' ) ) {
|
39 |
-
$this->assertTrue( $requirements->are_requirements_met(),
|
40 |
-
'Should be ok because WP is OK and PHP is OK' );
|
41 |
-
} else {
|
42 |
-
$this->assertFalse( $requirements->are_requirements_met(),
|
43 |
-
'Should fail because required PHP should be at least ' . $version );
|
44 |
-
}
|
45 |
-
}
|
46 |
-
$requirements->set_min_php_require( self::ALWAYS_NOT_VALID_PHP_VERSION );
|
47 |
-
$requirements->are_requirements_met();
|
48 |
-
$this->expectOutputRegex( "/PHP/" );
|
49 |
-
$requirements->handle_render_notices_action();
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @param string $php
|
54 |
-
* @param string $wp
|
55 |
-
*
|
56 |
-
* @return WPDesk_Basic_Requirement_Checker
|
57 |
-
*/
|
58 |
-
public function create_requirements_for_php_wp( $php, $wp ) {
|
59 |
-
return new WPDesk_Basic_Requirement_Checker( self::RANDOM_PLUGIN_FILE, self::RANDOM_PLUGIN_NAME,
|
60 |
-
self::RANDOM_PLUGIN_TEXTDOMAIN, $php, $wp );
|
61 |
-
}
|
62 |
-
|
63 |
-
public function test_wp_version_check() {
|
64 |
-
$wp_version_fail = '4.1';
|
65 |
-
|
66 |
-
$requirements = $this->create_requirements_for_php_wp(
|
67 |
-
self::ALWAYS_VALID_PHP_VERSION,
|
68 |
-
self::ALWAYS_VALID_WP_VERSION );
|
69 |
-
|
70 |
-
$this->assertTrue( $requirements->are_requirements_met(), 'Should be ok because WP is OK and PHP is OK' );
|
71 |
-
$requirements->set_min_wp_require( $wp_version_fail );
|
72 |
-
$this->assertFalse( $requirements->are_requirements_met(),
|
73 |
-
'Should fail because required WP should be at least ' . $wp_version_fail );
|
74 |
-
|
75 |
-
$this->expectOutputRegex( "/WordPress/" );
|
76 |
-
$requirements->handle_render_notices_action();
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @requires extension curl
|
81 |
-
*/
|
82 |
-
public function test_module_check() {
|
83 |
-
$requirements = $this->create_requirements_for_php_wp(
|
84 |
-
self::ALWAYS_VALID_PHP_VERSION,
|
85 |
-
self::ALWAYS_VALID_WP_VERSION );
|
86 |
-
|
87 |
-
$requirements->add_php_module_require( 'curl' );
|
88 |
-
$this->assertTrue( $requirements->are_requirements_met(), 'Curl should exists' );
|
89 |
-
|
90 |
-
$this->expectOutputRegex( "/^$/" );
|
91 |
-
$requirements->handle_render_notices_action();
|
92 |
-
}
|
93 |
-
|
94 |
-
public function test_plugin_check_with_multisite() {
|
95 |
-
$multisite = true;
|
96 |
-
$exising_plugin_name = 'WooCommerce';
|
97 |
-
$exising_multisite_plugin_name = 'Multisite';
|
98 |
-
$not_existing_plugin_name = 'Not exist';
|
99 |
-
|
100 |
-
WP_Mock::wpFunction( 'get_option' )
|
101 |
-
->withArgs( [ 'active_plugins', [] ] )
|
102 |
-
->andReturn( [ $exising_plugin_name ] );
|
103 |
-
|
104 |
-
WP_Mock::wpFunction( 'is_multisite' )
|
105 |
-
->andReturn( $multisite );
|
106 |
-
|
107 |
-
WP_Mock::wpFunction( 'get_site_option' )
|
108 |
-
->withArgs( [ 'active_sitewide_plugins', [] ] )
|
109 |
-
->andReturn( [ $exising_multisite_plugin_name ] );
|
110 |
-
|
111 |
-
|
112 |
-
$requirements = $this->create_requirements_for_php_wp( self::ALWAYS_VALID_PHP_VERSION,
|
113 |
-
self::ALWAYS_VALID_WP_VERSION );
|
114 |
-
|
115 |
-
$requirements->add_plugin_require( $exising_plugin_name );
|
116 |
-
$this->assertTrue( $requirements->are_requirements_met(), 'Plugin should exists' );
|
117 |
-
|
118 |
-
$requirements->add_plugin_require( $exising_multisite_plugin_name );
|
119 |
-
$this->assertTrue( $requirements->are_requirements_met(), 'Multisite plugin should exists' );
|
120 |
-
|
121 |
-
$requirements->add_plugin_require( $not_existing_plugin_name );
|
122 |
-
$this->assertFalse( $requirements->are_requirements_met(), 'Plugin should not exists' );
|
123 |
-
|
124 |
-
$this->expectOutputRegex( "/$not_existing_plugin_name/" );
|
125 |
-
$requirements->handle_render_notices_action();
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* @requires extension openssl
|
130 |
-
*/
|
131 |
-
public function test_existing_openssl_requirement() {
|
132 |
-
$open_ssl_always_valid = 1;
|
133 |
-
$open_ssl_always_not_valid = 0x900905000; // 9.9.6
|
134 |
-
|
135 |
-
$requirements = $this->create_requirements_for_php_wp( self::ALWAYS_VALID_PHP_VERSION,
|
136 |
-
self::ALWAYS_VALID_WP_VERSION );
|
137 |
-
|
138 |
-
$this->assertTrue( $requirements->is_open_ssl_at_least( $open_ssl_always_valid ),
|
139 |
-
'OpenSSL should have at least 0.1 version if exists' );
|
140 |
-
|
141 |
-
$this->assertFalse( $requirements->is_open_ssl_at_least( $open_ssl_always_not_valid ),
|
142 |
-
'OpenSSL should fail for that high number' );
|
143 |
-
|
144 |
-
$requirements->set_min_openssl_require( $open_ssl_always_not_valid );
|
145 |
-
|
146 |
-
$this->assertFalse( $requirements->are_requirements_met(),
|
147 |
-
'Requirement OpenSSL should fail for that high number' );
|
148 |
-
|
149 |
-
$this->expectOutputRegex( '/without OpenSSL module/' );
|
150 |
-
$requirements->handle_render_notices_action();
|
151 |
-
}
|
152 |
-
|
153 |
-
public function test_deactivate_plugin_notice() {
|
154 |
-
$requirements = $this->create_requirements_for_php_wp( self::ALWAYS_NOT_VALID_PHP_VERSION,
|
155 |
-
self::ALWAYS_VALID_WP_VERSION );
|
156 |
-
|
157 |
-
WP_Mock::expectActionAdded( WPDesk_Basic_Requirement_Checker::HOOK_ADMIN_NOTICES_ACTION,
|
158 |
-
[ $requirements, 'handle_render_notices_action'] );
|
159 |
-
|
160 |
-
$this->assertFalse( $requirements->are_requirements_met() );
|
161 |
-
$requirements->disable_plugin();
|
162 |
-
$requirements->render_notices();
|
163 |
-
|
164 |
-
$this->expectOutputRegex( '/cannot run on PHP/' );
|
165 |
-
$requirements->handle_render_notices_action();
|
166 |
-
}
|
167 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-basic-requirements/tests/unit/bootstrap.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPUnit bootstrap file
|
4 |
-
*/
|
5 |
-
|
6 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
7 |
-
|
8 |
-
error_reporting( E_ALL );
|
9 |
-
|
10 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
11 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
12 |
-
} else {
|
13 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( getenv( 'ABSPATH' ) !== false ) {
|
17 |
-
define( 'ABSPATH', getenv( 'ABSPATH' ) );
|
18 |
-
} else {
|
19 |
-
define( 'ABSPATH', PLUGIN_PATH . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
20 |
-
}
|
21 |
-
|
22 |
-
WP_Mock::setUsePatchwork( true );
|
23 |
-
WP_Mock::bootstrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-builder/.gitlab-ci.yml
DELETED
@@ -1,310 +0,0 @@
|
|
1 |
-
variables:
|
2 |
-
WPDESK_CI_VERSION: 1.10.19
|
3 |
-
MYSQL_ROOT_PASSWORD: mysql
|
4 |
-
MYSQL_DATABASE: wptest
|
5 |
-
MYSQL_USER: mysql
|
6 |
-
MYSQL_PASSWORD: mysql
|
7 |
-
MYSQL_INNODB_LOG_BUFFER_SIZE: 32M
|
8 |
-
PHP_ERROR_REPORTING: E_ALL
|
9 |
-
COMPOSER_ALLOW_SUPERUSER: 1
|
10 |
-
GIT_STRATEGY: fetch
|
11 |
-
ACCEPTANCE_ERROR_PATH: ${CI_PROJECT_DIR}/acceptance
|
12 |
-
|
13 |
-
stages:
|
14 |
-
- tools
|
15 |
-
- tests
|
16 |
-
- pre-deploy
|
17 |
-
- deploy
|
18 |
-
|
19 |
-
.template: &job-test-template
|
20 |
-
stage: tests
|
21 |
-
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
22 |
-
|
23 |
-
.template: &job-test-integration-template
|
24 |
-
<<: *job-test-template
|
25 |
-
services:
|
26 |
-
- mysql:5.6
|
27 |
-
script:
|
28 |
-
- echo ${WPDESK_CI_VERSION}
|
29 |
-
- ls -l
|
30 |
-
- php --version
|
31 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
32 |
-
- cat /tmp/woocommerce/woocommerce.php
|
33 |
-
- composer update --no-progress
|
34 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
35 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --coverage-text --colors=never
|
36 |
-
only:
|
37 |
-
- tags
|
38 |
-
|
39 |
-
.template: &job-test-integration-template-fast
|
40 |
-
<<: *job-test-integration-template
|
41 |
-
script:
|
42 |
-
- echo ${WPDESK_CI_VERSION}
|
43 |
-
- ls -l
|
44 |
-
- php --version
|
45 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
46 |
-
- cat /tmp/woocommerce/woocommerce.php
|
47 |
-
- composer update --no-progress
|
48 |
-
- if [[ -f tests/integration/prepare.sh ]]; then sh tests/integration/prepare.sh; fi
|
49 |
-
- vendor/bin/phpunit --configuration phpunit-integration.xml --no-coverage
|
50 |
-
except:
|
51 |
-
- tags
|
52 |
-
only:
|
53 |
-
|
54 |
-
.template: &job-test-unit-template
|
55 |
-
<<: *job-test-template
|
56 |
-
script:
|
57 |
-
- echo ${WPDESK_CI_VERSION}
|
58 |
-
- ls -l
|
59 |
-
- php --version
|
60 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
61 |
-
- cat /tmp/woocommerce/woocommerce.php
|
62 |
-
- composer update --no-progress
|
63 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --coverage-text --colors=never
|
64 |
-
only:
|
65 |
-
- tags
|
66 |
-
|
67 |
-
.template: &job-test-unit-template-fast
|
68 |
-
<<: *job-test-unit-template
|
69 |
-
script:
|
70 |
-
- echo ${WPDESK_CI_VERSION}
|
71 |
-
- ls -l
|
72 |
-
- php --version
|
73 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
74 |
-
- cat /tmp/woocommerce/woocommerce.php
|
75 |
-
- composer update --no-progress
|
76 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --no-coverage
|
77 |
-
except:
|
78 |
-
- tags
|
79 |
-
only:
|
80 |
-
|
81 |
-
.template: &job-deploy-template
|
82 |
-
image: wpdesknet/amazon-svn-deploy
|
83 |
-
stage: deploy
|
84 |
-
dependencies:
|
85 |
-
- build to deploy
|
86 |
-
- unit test lastest coverage
|
87 |
-
- integration test lastest coverage
|
88 |
-
retry: 2
|
89 |
-
when: manual
|
90 |
-
only:
|
91 |
-
- tags
|
92 |
-
|
93 |
-
before_script:
|
94 |
-
- cd ${CI_PROJECT_DIR}
|
95 |
-
|
96 |
-
phpmetric metrics:
|
97 |
-
stage: tools
|
98 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
99 |
-
allow_failure: true
|
100 |
-
when: manual
|
101 |
-
artifacts:
|
102 |
-
when: always
|
103 |
-
expire_in: 1 month
|
104 |
-
name: "metrics"
|
105 |
-
paths:
|
106 |
-
- ${CI_PROJECT_DIR}/phpmetric
|
107 |
-
script:
|
108 |
-
- echo ${WPDESK_CI_VERSION}
|
109 |
-
- composer require phpmetrics/phpmetrics
|
110 |
-
- composer update --no-progress
|
111 |
-
- php ./vendor/bin/phpmetrics --report-html=phpmetric .
|
112 |
-
|
113 |
-
churn metrics:
|
114 |
-
stage: tools
|
115 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
116 |
-
allow_failure: true
|
117 |
-
when: manual
|
118 |
-
script:
|
119 |
-
- echo ${WPDESK_CI_VERSION}
|
120 |
-
- composer require bmitch/churn-php
|
121 |
-
- composer update --no-progress
|
122 |
-
- vendor/bin/churn run classes inc
|
123 |
-
|
124 |
-
#code style test:
|
125 |
-
# stage: tests
|
126 |
-
# image: wpdesknet/phpunit-woocommerce:0-0
|
127 |
-
# allow_failure: true
|
128 |
-
# script:
|
129 |
-
# - echo ${WPDESK_CI_VERSION}
|
130 |
-
# - composer update --no-progress
|
131 |
-
# - vendor/bin/phpcs
|
132 |
-
|
133 |
-
unit test lastest:
|
134 |
-
<<: *job-test-unit-template-fast
|
135 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
136 |
-
|
137 |
-
integration test lastest:
|
138 |
-
<<: *job-test-integration-template-fast
|
139 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
140 |
-
|
141 |
-
unit test lastest coverage:
|
142 |
-
<<: *job-test-unit-template
|
143 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
144 |
-
|
145 |
-
integration test lastest coverage:
|
146 |
-
<<: *job-test-integration-template
|
147 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
148 |
-
|
149 |
-
integration test php7-1 wc-1:
|
150 |
-
<<: *job-test-integration-template-fast
|
151 |
-
image: wpdesknet/phpunit-woocommerce:1-1
|
152 |
-
|
153 |
-
integration test php7 wc-2:
|
154 |
-
<<: *job-test-integration-template-fast
|
155 |
-
image: wpdesknet/phpunit-woocommerce:2-2
|
156 |
-
|
157 |
-
integration test php-7 wc-3:
|
158 |
-
<<: *job-test-integration-template-fast
|
159 |
-
image: wpdesknet/phpunit-woocommerce:2-3
|
160 |
-
|
161 |
-
integration test php5-6:
|
162 |
-
<<: *job-test-integration-template-fast
|
163 |
-
image: wpdesknet/phpunit-woocommerce:3-0
|
164 |
-
|
165 |
-
integration test php5-5:
|
166 |
-
<<: *job-test-integration-template-fast
|
167 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
168 |
-
|
169 |
-
integration test current woocommerce:
|
170 |
-
<<: *job-test-integration-template-fast
|
171 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
172 |
-
allow_failure: true
|
173 |
-
before_script:
|
174 |
-
- cd /tmp
|
175 |
-
- rm -rf woocommerce
|
176 |
-
- git clone https://github.com/woocommerce/woocommerce.git
|
177 |
-
- cd ${CI_PROJECT_DIR}
|
178 |
-
|
179 |
-
acceptance test:
|
180 |
-
image: wpdesknet/node
|
181 |
-
variables:
|
182 |
-
CI_DEBUG_SERVICES: trace
|
183 |
-
services:
|
184 |
-
- name: mysql:5.6
|
185 |
-
alias: mysqltests
|
186 |
-
- name: wpdesknet/apache-woocommerce:latest
|
187 |
-
alias: wootests
|
188 |
-
- name: selenium/standalone-chrome
|
189 |
-
alias: selenium
|
190 |
-
artifacts:
|
191 |
-
when: always
|
192 |
-
expire_in: 1 day
|
193 |
-
name: "error logs"
|
194 |
-
paths:
|
195 |
-
- ${CI_PROJECT_DIR}/acceptance
|
196 |
-
stage: tests
|
197 |
-
allow_failure: true
|
198 |
-
script:
|
199 |
-
- cd ${CI_PROJECT_DIR}
|
200 |
-
- composer update --no-progress --no-dev
|
201 |
-
- if [[ -f ${CI_PROJECT_DIR}/tests/acceptance/prepare.sh ]]; then sh ${CI_PROJECT_DIR}/tests/acceptance/prepare.sh; fi
|
202 |
-
|
203 |
-
- export MYSQL_IP=$(awk '/^[[:space:]]*($|#)/{next} /mysqltests/{print $1; exit}' /etc/hosts)
|
204 |
-
- export WOOTESTS_IP=$(awk '/^[[:space:]]*($|#)/{next} /wootests/{print $1; exit}' /etc/hosts)
|
205 |
-
- echo "http://wootests/wpdesk_init.php?mysql_ip=${MYSQL_IP}&wootests_ip=${WOOTESTS_IP}"
|
206 |
-
- wget -O /tmp/wpdesk_init.txt "http://wootests/wpdesk_init.php?mysql_ip=${MYSQL_IP}&wootests_ip=${WOOTESTS_IP}"
|
207 |
-
- tail -50 /tmp/wpdesk_init.txt
|
208 |
-
|
209 |
-
- sh /tmp/clone.sh git@gitlab.com:wpdesk/plugins-tests.git /tmp/tests headless
|
210 |
-
- cd /tmp/tests
|
211 |
-
- npm install
|
212 |
-
- npm install -g grunt-cli
|
213 |
-
- cd node_modules/.bin
|
214 |
-
- ./webdriver-manager update
|
215 |
-
- cd ../
|
216 |
-
- mkdir -p ${CI_PROJECT_DIR}/acceptance/reports/html/screenshot
|
217 |
-
- grunt chrome-${CI_PROJECT_NAME}
|
218 |
-
|
219 |
-
|
220 |
-
apigen docs:
|
221 |
-
image:
|
222 |
-
name: wpdesknet/apigen
|
223 |
-
stage: pre-deploy
|
224 |
-
artifacts:
|
225 |
-
expire_in: 1 day
|
226 |
-
name: "docs"
|
227 |
-
paths:
|
228 |
-
- docs/
|
229 |
-
script:
|
230 |
-
- echo ${WPDESK_CI_VERSION}
|
231 |
-
- ls -l
|
232 |
-
- /app/vendor/bin/apigen generate
|
233 |
-
- php /app/hooks-docs.php ${CI_PROJECT_DIR}
|
234 |
-
only:
|
235 |
-
- tags
|
236 |
-
|
237 |
-
pages:
|
238 |
-
stage: deploy
|
239 |
-
dependencies:
|
240 |
-
- apigen docs
|
241 |
-
script:
|
242 |
-
- rm -rf public
|
243 |
-
- mv docs/ public/
|
244 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Dokumentacja projektu ${CI_PROJECT_NAME} w wersji ${CI_COMMIT_REF_NAME} umieszczona w <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}/pages|pages> \", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
245 |
-
artifacts:
|
246 |
-
expire_in: 1 day
|
247 |
-
paths:
|
248 |
-
- public
|
249 |
-
only:
|
250 |
-
- tags
|
251 |
-
|
252 |
-
build to deploy:
|
253 |
-
image: wpdesknet/phpunit-woocommerce:4-0
|
254 |
-
stage: pre-deploy
|
255 |
-
artifacts:
|
256 |
-
expire_in: 1 month
|
257 |
-
name: "production release"
|
258 |
-
paths:
|
259 |
-
- release
|
260 |
-
- release.zip
|
261 |
-
script:
|
262 |
-
- echo ${WPDESK_CI_VERSION}
|
263 |
-
- php --version
|
264 |
-
- ls -l
|
265 |
-
- /tmp/set_version.sh ${CI_COMMIT_REF_NAME}
|
266 |
-
- rm -rf ${CI_PROJECT_DIR}/release ${CI_PROJECT_DIR}/release.zip /tmp/release
|
267 |
-
- mkdir /tmp/release
|
268 |
-
- mkdir -p ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
269 |
-
- cp -rf ${CI_PROJECT_DIR}/* /tmp/release
|
270 |
-
- cp -rf /tmp/release/* ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
271 |
-
- cd ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME}
|
272 |
-
- composer install --no-dev --no-progress --optimize-autoloader
|
273 |
-
- rm -rf build-coverage release tests docs .git .editorconfig .gitignore .gitlab-ci.yml apigen.neon phpunit.xml acceptance test_soap.php .gitlab
|
274 |
-
- rm -rf composer.json composer.lock phpcs.xml.dist phpunit-integration.xml phpunit-unit.xml composer.phar wp-cli.phar
|
275 |
-
- cd ../
|
276 |
-
- zip -r -q ../release.zip ./
|
277 |
-
only:
|
278 |
-
- tags
|
279 |
-
|
280 |
-
deploy to shop:
|
281 |
-
<<: *job-deploy-template
|
282 |
-
script:
|
283 |
-
- echo ${WPDESK_CI_VERSION}
|
284 |
-
- /tmp/deploy_shop.sh ${CI_PROJECT_NAME} release.zip ${CI_PROJECT_NAME}.zip
|
285 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do sklepu w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
286 |
-
environment:
|
287 |
-
name: wpdesk shop
|
288 |
-
url: https://wpdeskplugin.s3.amazonaws.com/${CI_PROJECT_NAME}.zip
|
289 |
-
|
290 |
-
deploy to demo:
|
291 |
-
<<: *job-deploy-template
|
292 |
-
script:
|
293 |
-
- echo ${WPDESK_CI_VERSION}
|
294 |
-
- /tmp/deploy_demo.sh release/${CI_PROJECT_NAME} ${CI_PROJECT_NAME}
|
295 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do demo w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
296 |
-
environment:
|
297 |
-
name: wpdesk demo
|
298 |
-
url: https://demo.wpdesk.org
|
299 |
-
|
300 |
-
deploy to repository:
|
301 |
-
<<: *job-deploy-template
|
302 |
-
script:
|
303 |
-
- echo ${WPDESK_CI_VERSION}
|
304 |
-
- rm -rf /tmp/svn-repository
|
305 |
-
- mkdir /tmp/svn-repository
|
306 |
-
- /tmp/deploy_repository.sh ${CI_PROJECT_NAME} ${CI_PROJECT_DIR}/release/${CI_PROJECT_NAME} /tmp/svn-repository
|
307 |
-
- 'curl -X POST --data-urlencode "payload={\"text\": \"Projekt <https://gitlab.com/wpdesk/${CI_PROJECT_NAME}|${CI_PROJECT_NAME}> zdeployowany do repozytorium WP w wersji ${CI_COMMIT_REF_NAME}\", }" https://hooks.slack.com/services/${SLACK_AUTH}'
|
308 |
-
environment:
|
309 |
-
name: wordpress repository
|
310 |
-
url: https://downloads.wordpress.org/plugin/${CI_PROJECT_NAME}.${CI_COMMIT_REF_NAME}.zip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-builder/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
MIT License
|
2 |
-
|
3 |
-
Copyright (c) 2018 WP Desk
|
4 |
-
|
5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
-
of this software and associated documentation files (the "Software"), to deal
|
7 |
-
in the Software without restriction, including without limitation the rights
|
8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
-
copies of the Software, and to permit persons to whom the Software is
|
10 |
-
furnished to do so, subject to the following conditions:
|
11 |
-
|
12 |
-
The above copyright notice and this permission notice shall be included in all
|
13 |
-
copies or substantial portions of the Software.
|
14 |
-
|
15 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
-
SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-builder/tests/integration/bootstrap.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
|
4 |
-
ini_set('display_errors', '1');
|
5 |
-
ini_set('display_startup_errors', '1');
|
6 |
-
|
7 |
-
// disable xdebug backtrace
|
8 |
-
if ( function_exists( 'xdebug_disable' ) ) {
|
9 |
-
xdebug_disable();
|
10 |
-
}
|
11 |
-
|
12 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
13 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
14 |
-
} else {
|
15 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
16 |
-
}
|
17 |
-
|
18 |
-
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
|
19 |
-
|
20 |
-
tests_add_filter( 'muplugins_loaded', function () {
|
21 |
-
$plugins_to_active[] = 'hello.php';
|
22 |
-
update_option( 'active_plugins', $plugins_to_active );
|
23 |
-
}, 100 );
|
24 |
-
|
25 |
-
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
|
26 |
-
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-builder/tests/unit/bootstrap.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPUnit bootstrap file
|
4 |
-
*/
|
5 |
-
|
6 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
7 |
-
|
8 |
-
error_reporting( E_ALL );
|
9 |
-
|
10 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
11 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
12 |
-
} else {
|
13 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( getenv( 'ABSPATH' ) !== false ) {
|
17 |
-
define( 'ABSPATH', getenv( 'ABSPATH' ) );
|
18 |
-
} else {
|
19 |
-
define( 'ABSPATH', PLUGIN_PATH . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
|
20 |
-
}
|
21 |
-
|
22 |
-
WP_Mock::setUsePatchwork( true );
|
23 |
-
WP_Mock::bootstrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-logs/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
## [1.4.0] - 2019-01-21
|
2 |
### Changed
|
3 |
- WC integration now considers broken WC_Logger implementation
|
1 |
+
## [1.5.2] - 2019-04-25
|
2 |
+
### Changed
|
3 |
+
- wp-notice 3.x
|
4 |
+
|
5 |
+
## [1.5.1] - 2019-04-23
|
6 |
+
### Changed
|
7 |
+
- Two files for custom loggers (default+custom)
|
8 |
+
### Fixed
|
9 |
+
- Tests
|
10 |
+
|
11 |
+
## [1.5.0] - 2019-04-18
|
12 |
+
### Changed
|
13 |
+
- Log file is unified with old way logger and all is logged in /wp-content/uploads/wpdesk-logs/wpdesk_debug.log
|
14 |
+
- Old static logger methods are deprecated
|
15 |
+
### Added
|
16 |
+
- All old way loggers are in deprecated dir and should work for old plugins
|
17 |
+
- Support for $shouldLoggerBeActivated static flag in factory - can return null logger
|
18 |
+
|
19 |
## [1.4.0] - 2019-01-21
|
20 |
### Changed
|
21 |
- WC integration now considers broken WC_Logger implementation
|
vendor/wpdesk/wp-logs/README.md
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-logs/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-logs/pipelines)
|
2 |
-
[![coverage report](https://gitlab.com/wpdesk/wp-logs/badges/master/coverage.svg)](https://gitlab.com/wpdesk/wp-logs/commits/master)
|
3 |
-
[![Latest Stable Version](https://poser.pugx.org/wpdesk/wp-logs/v/stable)](https://packagist.org/packages/wpdesk/wp-logs)
|
4 |
-
[![Total Downloads](https://poser.pugx.org/wpdesk/wp-logs/downloads)](https://packagist.org/packages/wpdesk/wp-logs)
|
5 |
-
[![Latest Unstable Version](https://poser.pugx.org/wpdesk/wp-logs/v/unstable)](https://packagist.org/packages/wpdesk/wp-logs)
|
6 |
-
[![License](https://poser.pugx.org/wpdesk/wp-logs/license)](https://packagist.org/packages/wpdesk/wp-logs)
|
7 |
-
|
8 |
-
WordPress Library to log all that can be logged in a modern way.
|
9 |
-
===================================================
|
10 |
-
|
11 |
-
wp-log is a simple library for WordPress plugins which integrates Monolog with PHP/WP error handling and WooCommerce log system.
|
12 |
-
|
13 |
-
By default library logs to WC_Logger and WP Desk log file located in /uploads/wpdesk-logs/wpdesk_debug.log.
|
14 |
-
|
15 |
-
## Requirements
|
16 |
-
|
17 |
-
PHP 5.6 or later.
|
18 |
-
|
19 |
-
## Composer
|
20 |
-
|
21 |
-
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
|
22 |
-
|
23 |
-
```bash
|
24 |
-
composer require wpdesk/wp-logs
|
25 |
-
```
|
26 |
-
|
27 |
-
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
|
28 |
-
|
29 |
-
```php
|
30 |
-
require_once 'vendor/autoload.php';
|
31 |
-
```
|
32 |
-
|
33 |
-
## Compatiblity between plugins
|
34 |
-
|
35 |
-
To ensure that always the latest and valid version of composer libraries are loaded in WP env you should use a solution
|
36 |
-
that ensure support between plugins and at least decreases the change that something would break. At the moment we recommend
|
37 |
-
using wpdesk/wp-autoloader.
|
38 |
-
|
39 |
-
|
40 |
-
## Manual instalation
|
41 |
-
|
42 |
-
If you do not wish to use Composer and wpdesk/wp-autoloader, you probably should stop using any existing library as it breaks compatibility between plugins.
|
43 |
-
|
44 |
-
## Getting Started
|
45 |
-
|
46 |
-
Simple usage to get Monolog style logger:
|
47 |
-
|
48 |
-
```php
|
49 |
-
WPDesk\Logger\LoggerFacade::get_logger()->addDebug('some debug message');
|
50 |
-
|
51 |
-
// Is equivalent to:
|
52 |
-
WPDesk\Logger\LoggerFacade::get_logger()->debug('some debug message');
|
53 |
-
|
54 |
-
// Is equivalent to:
|
55 |
-
WPDesk\Logger\LoggerFacade::get_logger()->log(Logger::DEBUG, 'some debug message');
|
56 |
-
```
|
57 |
-
|
58 |
-
You can also use various Facade helpers:
|
59 |
-
```php
|
60 |
-
|
61 |
-
// log WP_Errors
|
62 |
-
WPDesk\Logger\LoggerFacade::log_wp_error(new WP_Error(), debug_backtrace());
|
63 |
-
|
64 |
-
// log Exceptions
|
65 |
-
WPDesk\Logger\LoggerFacade::log_exception(new \RuntimeException());
|
66 |
-
|
67 |
-
// log message with backtrace
|
68 |
-
WPDesk\Logger\LoggerFacade::log_message_backtrace('some message', debug_backtrace(), Logger::DEBUG);
|
69 |
-
|
70 |
-
// log standard message
|
71 |
-
WPDesk\Logger\LoggerFacade::log_message('some message', ['some_user' => $user], 'my-app-source', Logger::DEBUG);
|
72 |
-
|
73 |
-
|
74 |
-
```
|
75 |
-
|
76 |
-
|
77 |
-
Logs can be used whether WC is active or not but if add_action is unavailable then WC logs capture would break.
|
78 |
-
|
79 |
-
## Project documentation
|
80 |
-
|
81 |
-
PHPDoc: https://wpdesk.gitlab.io/wp-logs/index.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-logs/composer.json
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
"require": {
|
10 |
"php": ">=5.6",
|
11 |
"psr/log": "^1.0.1",
|
12 |
-
"monolog/monolog": "^1.23"
|
|
|
13 |
},
|
14 |
"require-dev": {
|
15 |
"phpunit/phpunit": "^5",
|
@@ -18,6 +19,7 @@
|
|
18 |
"wimg/php-compatibility": "^8"
|
19 |
},
|
20 |
"autoload": {
|
|
|
21 |
"psr-4": {"WPDesk\\Logger\\": "src/"}
|
22 |
},
|
23 |
"autoload-dev": {
|
9 |
"require": {
|
10 |
"php": ">=5.6",
|
11 |
"psr/log": "^1.0.1",
|
12 |
+
"monolog/monolog": "^1.23",
|
13 |
+
"wpdesk/wp-notice": "^3.0"
|
14 |
},
|
15 |
"require-dev": {
|
16 |
"phpunit/phpunit": "^5",
|
19 |
"wimg/php-compatibility": "^8"
|
20 |
},
|
21 |
"autoload": {
|
22 |
+
"classmap": ["src/deprecated"],
|
23 |
"psr-4": {"WPDesk\\Logger\\": "src/"}
|
24 |
},
|
25 |
"autoload-dev": {
|
vendor/wpdesk/wp-logs/src/LoggerFacade.php
CHANGED
@@ -10,6 +10,8 @@ use Exception;
|
|
10 |
/**
|
11 |
* Facilitates creation of logger with default WPDesk settings
|
12 |
*
|
|
|
|
|
13 |
* @package WPDesk\Logger
|
14 |
*/
|
15 |
class LoggerFacade
|
10 |
/**
|
11 |
* Facilitates creation of logger with default WPDesk settings
|
12 |
*
|
13 |
+
* @deprecated Only for backward compatibility. Please use injected Logger compatible with PSR
|
14 |
+
*
|
15 |
* @package WPDesk\Logger
|
16 |
*/
|
17 |
class LoggerFacade
|
vendor/wpdesk/wp-logs/src/WP/WPCapture.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WPDesk\Logger\WP;
|
4 |
+
|
5 |
+
class WPCapture {
|
6 |
+
/** @var string */
|
7 |
+
private $filename;
|
8 |
+
|
9 |
+
const LOG_DIR = 'wpdesk-logs';
|
10 |
+
|
11 |
+
public function __construct($filename) {
|
12 |
+
$this->filename = $filename;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Add notice for directory.
|
17 |
+
*
|
18 |
+
* @param string $dir Directory.
|
19 |
+
*/
|
20 |
+
private function add_notice_for_dir( $dir ) {
|
21 |
+
new \WPDesk\Notice\Notice(
|
22 |
+
sprintf(
|
23 |
+
// Translators: directory.
|
24 |
+
__(
|
25 |
+
'Can not enable WP Desk Debug log! Cannot create directory %s or this directory is not writeable!',
|
26 |
+
'wpdesk-helper'
|
27 |
+
),
|
28 |
+
$dir
|
29 |
+
),
|
30 |
+
WPDesk\Notice\Notice::NOTICE_TYPE_ERROR
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add notice for file.
|
36 |
+
*
|
37 |
+
* @param string $file File..
|
38 |
+
*/
|
39 |
+
private function add_notice_for_file( $file ) {
|
40 |
+
new \WPDesk\Notice\Notice(
|
41 |
+
sprintf(
|
42 |
+
// Translators: directory.
|
43 |
+
__(
|
44 |
+
'Can not enable WP Desk Debug log! Cannot create file %s!',
|
45 |
+
'wpdesk-helper'
|
46 |
+
),
|
47 |
+
$file
|
48 |
+
),
|
49 |
+
WPDesk\Notice\Notice::NOTICE_TYPE_ERROR
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Is debug log writable.
|
55 |
+
*
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
private function is_debug_log_writable_or_show_notice() {
|
59 |
+
$log_dir = $this->get_log_dir();
|
60 |
+
$log_file = $this->get_log_file();
|
61 |
+
$index_file = $this->get_index_file();
|
62 |
+
if ( ! file_exists( $log_dir ) ) {
|
63 |
+
if ( ! mkdir( $log_dir, 0777, true ) ) {
|
64 |
+
$this->add_notice_for_dir( $log_dir );
|
65 |
+
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
if ( ! file_exists( $index_file ) ) {
|
70 |
+
$index_html = fopen( $index_file, 'w' );
|
71 |
+
if ( false === $index_html ) {
|
72 |
+
$this->add_notice_for_file( $index_file );
|
73 |
+
|
74 |
+
return false;
|
75 |
+
} else {
|
76 |
+
fclose( $index_html );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
if ( ! file_exists( $log_file ) ) {
|
80 |
+
$log = fopen( $log_file, 'w' );
|
81 |
+
if ( false === $log ) {
|
82 |
+
$this->add_notice_for_file( $log_file );
|
83 |
+
|
84 |
+
return false;
|
85 |
+
} else {
|
86 |
+
fclose( $log );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Init debug log file.
|
95 |
+
*/
|
96 |
+
public function init_debug_log_file() {
|
97 |
+
if ( $this->is_debug_log_writable_or_show_notice() ) {
|
98 |
+
ini_set( 'log_errors', 1 );
|
99 |
+
ini_set( 'error_log', $this->get_log_file() );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Get uploads dir.
|
105 |
+
*
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
private function get_uploads_dir() {
|
109 |
+
$upload_dir = wp_upload_dir();
|
110 |
+
|
111 |
+
return untrailingslashit( $upload_dir['basedir'] );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Get log dir.
|
116 |
+
*
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
private function get_log_dir() {
|
120 |
+
return trailingslashit( $this->get_uploads_dir() ) . self::LOG_DIR;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get log file.
|
125 |
+
*
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
public function get_log_file() {
|
129 |
+
return trailingslashit( $this->get_log_dir() ) . $this->filename;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get log file.
|
134 |
+
*
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
private function get_index_file() {
|
138 |
+
return trailingslashit( $this->get_log_dir() ) . 'index.html';
|
139 |
+
}
|
140 |
+
}
|
vendor/wpdesk/wp-logs/src/WPDeskLoggerFactory.php
CHANGED
@@ -2,15 +2,16 @@
|
|
2 |
|
3 |
namespace WPDesk\Logger;
|
4 |
|
5 |
-
use
|
|
|
|
|
6 |
use Monolog\Handler\NullHandler;
|
7 |
use Monolog\Logger;
|
8 |
use Monolog\Registry;
|
9 |
-
use Monolog\ErrorHandler;
|
10 |
use Monolog\Handler\StreamHandler;
|
11 |
use Psr\Log\LogLevel;
|
12 |
-
use WPDesk\Logger\Filter\BooleanFilter;
|
13 |
use WPDesk\Logger\WC\WooCommerceCapture;
|
|
|
14 |
|
15 |
/**
|
16 |
* Manages and facilitates creation of logger
|
@@ -27,6 +28,9 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
27 |
/** @var string Log to wc logger when level is */
|
28 |
const LEVEL_WC = LogLevel::ERROR;
|
29 |
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Remove static instances. In general should be use only testing purposes.
|
32 |
*
|
@@ -72,23 +76,58 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
72 |
*/
|
73 |
public function createWPDeskLogger($name = self::DEFAULT_LOGGER_CHANNEL_NAME)
|
74 |
{
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
return Registry::getInstance($name);
|
77 |
}
|
78 |
$logger = $this->createLogger($name);
|
|
|
79 |
$this->captureWooCommerce($logger);
|
80 |
-
$this->
|
81 |
-
|
82 |
-
$this->
|
83 |
-
} catch (\InvalidArgumentException $e) {
|
84 |
-
$logger->emergency('File log could not be created - invalid filename.');
|
85 |
-
} catch (\Exception $e) {
|
86 |
-
$logger->emergency('File log could not be written.');
|
87 |
}
|
88 |
|
89 |
return $logger;
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
/**
|
93 |
* Capture WooCommerce and add handle
|
94 |
*
|
@@ -104,36 +143,24 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
104 |
$wcIntegration->captureWcLogger();
|
105 |
}
|
106 |
|
107 |
-
/**
|
108 |
-
* Add WordPress(standard PHP) errors handle
|
109 |
-
*
|
110 |
-
* @param Logger $logger
|
111 |
-
*/
|
112 |
-
private function captureErrorHandle(Logger $logger)
|
113 |
-
{
|
114 |
-
$errorHandler = new ErrorHandler($logger);
|
115 |
-
$errorHandler->registerErrorHandler();
|
116 |
-
}
|
117 |
-
|
118 |
/**
|
119 |
* Add WPDesk log file handle
|
120 |
*
|
121 |
* @param Logger $logger
|
122 |
-
* @param string $
|
123 |
*
|
124 |
-
* @throws
|
125 |
-
* @throws
|
126 |
*/
|
127 |
-
private function pushFileHandle($
|
128 |
{
|
129 |
-
$filename = $this->getFileName($name);
|
130 |
$logger->pushHandler(new StreamHandler($filename, self::LEVEL_WPDESK_FILE));
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
* Get filename old way
|
135 |
*
|
136 |
-
* @deprecated
|
137 |
*/
|
138 |
public function getWPDeskFileName()
|
139 |
{
|
@@ -141,7 +168,7 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
-
* Returns WPDesk filename
|
145 |
*
|
146 |
* @param string $name Name of the logger
|
147 |
*
|
@@ -149,7 +176,8 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
149 |
*/
|
150 |
public function getFileName($name = self::DEFAULT_LOGGER_CHANNEL_NAME)
|
151 |
{
|
152 |
-
|
|
|
153 |
}
|
154 |
|
155 |
/**
|
@@ -165,7 +193,7 @@ class WPDeskLoggerFactory extends BasicLoggerFactory
|
|
165 |
while (true) {
|
166 |
$logger->popHandler();
|
167 |
}
|
168 |
-
} catch (
|
169 |
$logger->pushHandler(new NullHandler());
|
170 |
}
|
171 |
}
|
2 |
|
3 |
namespace WPDesk\Logger;
|
4 |
|
5 |
+
use Exception;
|
6 |
+
use InvalidArgumentException;
|
7 |
+
use LogicException;
|
8 |
use Monolog\Handler\NullHandler;
|
9 |
use Monolog\Logger;
|
10 |
use Monolog\Registry;
|
|
|
11 |
use Monolog\Handler\StreamHandler;
|
12 |
use Psr\Log\LogLevel;
|
|
|
13 |
use WPDesk\Logger\WC\WooCommerceCapture;
|
14 |
+
use WPDesk\Logger\WP\WPCapture;
|
15 |
|
16 |
/**
|
17 |
* Manages and facilitates creation of logger
|
28 |
/** @var string Log to wc logger when level is */
|
29 |
const LEVEL_WC = LogLevel::ERROR;
|
30 |
|
31 |
+
/** @var bool Will factory return null logger or not */
|
32 |
+
public static $shouldLoggerBeActivated = true;
|
33 |
+
|
34 |
/**
|
35 |
* Remove static instances. In general should be use only testing purposes.
|
36 |
*
|
76 |
*/
|
77 |
public function createWPDeskLogger($name = self::DEFAULT_LOGGER_CHANNEL_NAME)
|
78 |
{
|
79 |
+
if (!self::$shouldLoggerBeActivated) {
|
80 |
+
return new Logger($name);
|
81 |
+
}
|
82 |
+
|
83 |
+
if (Registry::hasLogger($name)) {
|
84 |
return Registry::getInstance($name);
|
85 |
}
|
86 |
$logger = $this->createLogger($name);
|
87 |
+
|
88 |
$this->captureWooCommerce($logger);
|
89 |
+
$this->appendMainLog($logger);
|
90 |
+
if ($name !== self::DEFAULT_LOGGER_CHANNEL_NAME) {
|
91 |
+
$this->appendFileLog($logger, $this->getFileName($name));
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
return $logger;
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
+
* @param $logger
|
99 |
+
*/
|
100 |
+
private function appendMainLog($logger) {
|
101 |
+
$wpCapture = $this->captureWPLog();
|
102 |
+
$this->appendFileLog($logger, $wpCapture->get_log_file());
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @param Logger $logger
|
107 |
+
*/
|
108 |
+
private function appendFileLog($logger, $filename) {
|
109 |
+
try {
|
110 |
+
$this->pushFileHandle($filename, $logger);
|
111 |
+
} catch (InvalidArgumentException $e) {
|
112 |
+
$logger->emergency('Main log file could not be created - invalid filename.');
|
113 |
+
} catch (Exception $e) {
|
114 |
+
$logger->emergency('Main log file could not be written.');
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @return WPCapture
|
120 |
+
*/
|
121 |
+
private function captureWPLog() {
|
122 |
+
static $wpCapture;
|
123 |
+
if (!$wpCapture) {
|
124 |
+
$wpCapture = new WPCapture(basename($this->getFileName()));
|
125 |
+
$wpCapture->init_debug_log_file();
|
126 |
+
}
|
127 |
+
|
128 |
+
return $wpCapture;
|
129 |
+
}
|
130 |
+
|
131 |
/**
|
132 |
* Capture WooCommerce and add handle
|
133 |
*
|
143 |
$wcIntegration->captureWcLogger();
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
/**
|
147 |
* Add WPDesk log file handle
|
148 |
*
|
149 |
* @param Logger $logger
|
150 |
+
* @param string $filename Name of file with path
|
151 |
*
|
152 |
+
* @throws Exception If a missing directory is not buildable
|
153 |
+
* @throws InvalidArgumentException If stream is not a resource or string
|
154 |
*/
|
155 |
+
private function pushFileHandle($filename, Logger $logger)
|
156 |
{
|
|
|
157 |
$logger->pushHandler(new StreamHandler($filename, self::LEVEL_WPDESK_FILE));
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
* Get filename old way
|
162 |
*
|
163 |
+
* @deprecated not sure if can remove
|
164 |
*/
|
165 |
public function getWPDeskFileName()
|
166 |
{
|
168 |
}
|
169 |
|
170 |
/**
|
171 |
+
* Returns WPDesk filename.
|
172 |
*
|
173 |
* @param string $name Name of the logger
|
174 |
*
|
176 |
*/
|
177 |
public function getFileName($name = self::DEFAULT_LOGGER_CHANNEL_NAME)
|
178 |
{
|
179 |
+
$upload_dir = wp_upload_dir();
|
180 |
+
return trailingslashit( untrailingslashit( $upload_dir['basedir'] ) ) . WPCapture::LOG_DIR . DIRECTORY_SEPARATOR . $name . '_debug.log';
|
181 |
}
|
182 |
|
183 |
/**
|
193 |
while (true) {
|
194 |
$logger->popHandler();
|
195 |
}
|
196 |
+
} catch (LogicException $e) {
|
197 |
$logger->pushHandler(new NullHandler());
|
198 |
}
|
199 |
}
|
vendor/wpdesk/wp-logs/src/deprecated/wpdesk-logger-factory.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'WPDesk_Logger_Factory' ) ) {
|
8 |
+
/**
|
9 |
+
* @deprecated Only for backward compatibility. Please use injected Logger compatible with PSR
|
10 |
+
*/
|
11 |
+
class WPDesk_Logger_Factory {
|
12 |
+
/**
|
13 |
+
* Static logger storage
|
14 |
+
*
|
15 |
+
* @var WPDesk_Logger
|
16 |
+
*/
|
17 |
+
static private $logger = null;
|
18 |
+
|
19 |
+
const BACKTRACE_FILENAME_KEY = 'file';
|
20 |
+
const WPDESK_LOG_ACTION_NAME = 'wpdesk_log';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Creates and returns a logger
|
24 |
+
*
|
25 |
+
* @return WPDesk_Logger
|
26 |
+
*/
|
27 |
+
public static function create_logger() {
|
28 |
+
if ( empty( self::$logger ) ) {
|
29 |
+
$logger = new WPDesk_Logger();
|
30 |
+
$logger->attach_hooks();
|
31 |
+
self::$logger = $logger;
|
32 |
+
}
|
33 |
+
|
34 |
+
return self::$logger;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Log this exception into wpdesk logger
|
39 |
+
*
|
40 |
+
* @param WP_Error $e Error to log.
|
41 |
+
* @param array $backtrace Backtrace information with snapshot of error env.
|
42 |
+
*
|
43 |
+
* @see http://php.net/manual/en/function.debug-backtrace.php
|
44 |
+
*/
|
45 |
+
public static function log_wp_error( WP_Error $e, array $backtrace ) {
|
46 |
+
$message = 'Error: ' . get_class( $e ) . ' Code: ' . $e->get_error_code() . ' Message: ' . $e->get_error_message();
|
47 |
+
|
48 |
+
self::log_message_backtrace( $message, WPDesk_Logger::ERROR, $backtrace );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Log this exception into WPDesk logger
|
53 |
+
*
|
54 |
+
* @param Exception $e Exception to log.
|
55 |
+
*/
|
56 |
+
public static function log_exception( Exception $e ) {
|
57 |
+
$message = 'Exception: ' . get_class( $e ) . ' Code: ' . $e->getCode() . ' Message: ' . $e->getMessage() . ' Stack: ' . $e->getTraceAsString();
|
58 |
+
|
59 |
+
self::log_message( $message, $e->getFile(), WPDesk_Logger::ERROR );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Log message into WPDesk logger
|
64 |
+
*
|
65 |
+
* @param string $message Message to log.
|
66 |
+
* @param string $source Source of the message - can be file name, class name or whatever.
|
67 |
+
* @param string $level Level of error.
|
68 |
+
*/
|
69 |
+
public static function log_message( $message, $source = 'unknown', $level = WPDesk_Logger::DEBUG ) {
|
70 |
+
self::create_logger();
|
71 |
+
do_action( self::WPDESK_LOG_ACTION_NAME, $level, $source, $message );
|
72 |
+
self::$logger->wpdesk_log($level, $source, $message);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Log message into WPDesk logger
|
77 |
+
*
|
78 |
+
* @param string $message Message to log.
|
79 |
+
* @param string $level Level of error.
|
80 |
+
* @param array $backtrace Backtrace information with snapshot of error env.
|
81 |
+
*/
|
82 |
+
public static function log_message_backtrace( $message, $level = WPDesk_Logger::DEBUG, array $backtrace ) {
|
83 |
+
$message .= ' Backtrace: ' . json_encode( $backtrace );
|
84 |
+
if (isset($backtrace[ self::BACKTRACE_FILENAME_KEY ])) {
|
85 |
+
$filename = $backtrace[ self::BACKTRACE_FILENAME_KEY ];
|
86 |
+
} else {
|
87 |
+
$filename = 'unknown';
|
88 |
+
}
|
89 |
+
|
90 |
+
self::log_message( $message, $filename, $level );
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
vendor/wpdesk/wp-logs/src/deprecated/wpdesk-logger.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'WPDesk_Logger' ) ) {
|
8 |
+
/**
|
9 |
+
* @deprecated Only for backward compatibility. Please use injected Logger compatible with PSR
|
10 |
+
*/
|
11 |
+
class WPDesk_Logger {
|
12 |
+
|
13 |
+
/** @var \Psr\Log\LoggerInterface */
|
14 |
+
static $logger;
|
15 |
+
|
16 |
+
const EMERGENCY = 'emergency';
|
17 |
+
const ALERT = 'alert';
|
18 |
+
const CRITICAL = 'critical';
|
19 |
+
const ERROR = 'error';
|
20 |
+
const WARNING = 'warning';
|
21 |
+
const NOTICE = 'notice';
|
22 |
+
const INFO = 'info';
|
23 |
+
const DEBUG = 'debug';
|
24 |
+
|
25 |
+
public function __construct() {
|
26 |
+
if (!self::$logger) {
|
27 |
+
$loggerFactroy = new \WPDesk\Logger\WPDeskLoggerFactory();
|
28 |
+
self::$logger = $loggerFactroy->createWPDeskLogger();
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Level strings mapped to integer severity.
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
protected $level_to_severity = [
|
38 |
+
self::EMERGENCY => 800,
|
39 |
+
self::ALERT => 700,
|
40 |
+
self::CRITICAL => 600,
|
41 |
+
self::ERROR => 500,
|
42 |
+
self::WARNING => 400,
|
43 |
+
self::NOTICE => 300,
|
44 |
+
self::INFO => 200,
|
45 |
+
self::DEBUG => 100,
|
46 |
+
];
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Attach hooks
|
50 |
+
*
|
51 |
+
* @return void
|
52 |
+
*/
|
53 |
+
public function attach_hooks() {
|
54 |
+
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
|
55 |
+
add_filter( 'wpdesk_logger_level_options', [ $this, 'wpdesk_logger_level_options' ] );
|
56 |
+
}
|
57 |
+
|
58 |
+
public function plugins_loaded() {
|
59 |
+
if ( defined( 'WC_VERSION' ) ) {
|
60 |
+
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
61 |
+
add_action( 'wpdesk_log', [ $this, 'wpdesk_log' ], 10, 4 );
|
62 |
+
} else {
|
63 |
+
add_action( 'wpdesk_log', [ $this, 'wpdesk_log_30' ], 10, 4 );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
public function wpdesk_logger_level_options( array $options ) {
|
69 |
+
return [
|
70 |
+
'disabled' => __( 'Disabled', 'wpdesk-helper' ),
|
71 |
+
'emergency' => __( 'Emergency', 'wpdesk-helper' ),
|
72 |
+
'alert' => __( 'Alert', 'wpdesk-helper' ),
|
73 |
+
'critical' => __( 'Critical', 'wpdesk-helper' ),
|
74 |
+
'error' => __( 'Error', 'wpdesk-helper' ),
|
75 |
+
'warning' => __( 'Warning', 'wpdesk-helper' ),
|
76 |
+
'notice' => __( 'Notice', 'wpdesk-helper' ),
|
77 |
+
'info' => __( 'Info', 'wpdesk-helper' ),
|
78 |
+
'debug' => __( 'Debug', 'wpdesk-helper' ),
|
79 |
+
];
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param string $level
|
84 |
+
* @param string $source
|
85 |
+
* @param string $message
|
86 |
+
* @param string $settings_level
|
87 |
+
*/
|
88 |
+
public function wpdesk_log( $level, $source, $message, $settings_level = 'debug' ) {
|
89 |
+
if ( ! isset( $this->level_to_severity[ $settings_level ] ) || ! isset( $this->level_to_severity[ $level ] ) ) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
if ( $this->level_to_severity[ $settings_level ] > $this->level_to_severity[ $level ] ) {
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
96 |
+
$message = print_r( $message, true );
|
97 |
+
}
|
98 |
+
self::$logger->log( $level, $message, ['source' => $source]);
|
99 |
+
}
|
100 |
+
|
101 |
+
public function wpdesk_log_30( $level, $source, $message, $settings_level = 'debug' ) {
|
102 |
+
if ( ! isset( $this->level_to_severity[ $settings_level ] ) || ! isset( $this->level_to_severity[ $level ] ) ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
if ( $this->level_to_severity[ $settings_level ] > $this->level_to_severity[ $level ] ) {
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
109 |
+
$message = print_r( $message, true );
|
110 |
+
}
|
111 |
+
self::$logger->log( $level, $message, ['source' => $source]);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
|
vendor/wpdesk/wp-notice/README.md
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-notice/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-notice/pipelines)
|
2 |
-
[![coverage report](https://gitlab.com/wpdesk/wp-notice/badges/master/coverage.svg?job=integration+test+lastest+coverage)](https://gitlab.com/wpdesk/wp-notice/commits/master)
|
3 |
-
[![Latest Stable Version](https://poser.pugx.org/wpdesk/wp-notice/v/stable)](https://packagist.org/packages/wpdesk/wp-notice)
|
4 |
-
[![Total Downloads](https://poser.pugx.org/wpdesk/wp-notice/downloads)](https://packagist.org/packages/wpdesk/wp-notice)
|
5 |
-
[![Latest Unstable Version](https://poser.pugx.org/wpdesk/wp-notice/v/unstable)](https://packagist.org/packages/wpdesk/wp-notice)
|
6 |
-
[![License](https://poser.pugx.org/wpdesk/wp-notice/license)](https://packagist.org/packages/wpdesk/wp-notice)
|
7 |
-
|
8 |
-
|
9 |
-
WordPress Library to display notices in admin area.
|
10 |
-
===================================================
|
11 |
-
|
12 |
-
wp-notice is a simple library for WordPress plugins to display notices in admin area.
|
13 |
-
|
14 |
-
This library can display simple notices (error, warning, success, info) and dismissible notices.
|
15 |
-
It also handles dismiss functionality with AJAX requests.
|
16 |
-
|
17 |
-
## Requirements
|
18 |
-
|
19 |
-
PHP 5.5 or later.
|
20 |
-
|
21 |
-
## Composer
|
22 |
-
|
23 |
-
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
|
24 |
-
|
25 |
-
```bash
|
26 |
-
composer require wpdesk/wp-notice
|
27 |
-
```
|
28 |
-
|
29 |
-
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
|
30 |
-
|
31 |
-
```php
|
32 |
-
require_once 'vendor/autoload.php';
|
33 |
-
```
|
34 |
-
|
35 |
-
## Manual instalation
|
36 |
-
|
37 |
-
If you do not wish to use Composer, you can [download the latest release](https://gitlab.com/wpdesk/wp-notice/-/jobs/artifacts/master/download?job=library). Then, to use the Notices, include the init.php file.
|
38 |
-
|
39 |
-
```php
|
40 |
-
require_once('/path/to/wp-desk/wp-notice/init.php');
|
41 |
-
```
|
42 |
-
|
43 |
-
## Getting Started
|
44 |
-
|
45 |
-
Simple usage looks like:
|
46 |
-
|
47 |
-
```php
|
48 |
-
$notice = wpdesk_wp_notice('Notice text goes here');
|
49 |
-
|
50 |
-
// Is equivalent to:
|
51 |
-
$notice = WPDeskWpNotice('Notice text goes here');
|
52 |
-
|
53 |
-
// Is equivalent to:
|
54 |
-
$notice = \WPDesk\Notice\Factory::notice('Notice text goes here');
|
55 |
-
|
56 |
-
// Is equivalent to:
|
57 |
-
$notice = new \WPDesk\Notice\Notice('Notice text goes here');
|
58 |
-
```
|
59 |
-
|
60 |
-
Notice must be used before WordPress action `admin_notices`. WordPress admin actions order is listed [here](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_an_Admin_Page_Request).
|
61 |
-
|
62 |
-
## Project documentation
|
63 |
-
|
64 |
-
PHPDoc: https://wpdesk.gitlab.io/wp-notice/index.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-persistence/README.md
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-persistence/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-persistence/pipelines)
|
2 |
-
[![coverage report](https://gitlab.com/wpdesk/wp-persistence/badges/master/coverage.svg)](https://gitlab.com/wpdesk/wp-persistence/commits/master)
|
3 |
-
[![Latest Stable Version](https://poser.pugx.org/wpdesk/wp-persistence/v/stable)](https://packagist.org/packages/wpdesk/wp-persistence)
|
4 |
-
[![Total Downloads](https://poser.pugx.org/wpdesk/wp-persistence/downloads)](https://packagist.org/packages/wpdesk/wp-persistence)
|
5 |
-
[![Latest Unstable Version](https://poser.pugx.org/wpdesk/wp-persistence/v/unstable)](https://packagist.org/packages/wpdesk/wp-persistence)
|
6 |
-
[![License](https://poser.pugx.org/wpdesk/wp-persistence/license)](https://packagist.org/packages/wpdesk/wp-persistence)
|
7 |
-
|
8 |
-
WordPress Library to facilitate access to various persistence possibilities
|
9 |
-
===================================================
|
10 |
-
|
11 |
-
|
12 |
-
## Requirements
|
13 |
-
|
14 |
-
PHP 5.6 or later.
|
15 |
-
|
16 |
-
## Composer
|
17 |
-
|
18 |
-
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
|
19 |
-
|
20 |
-
```bash
|
21 |
-
composer require wpdesk/wp-persistence
|
22 |
-
```
|
23 |
-
|
24 |
-
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
|
25 |
-
|
26 |
-
```php
|
27 |
-
require_once 'vendor/autoload.php';
|
28 |
-
```
|
29 |
-
|
30 |
-
## Compatiblity between plugins
|
31 |
-
|
32 |
-
To ensure that always the latest and valid version of composer libraries are loaded in WP env you should use a solution
|
33 |
-
that ensure support between plugins and at least decreases the change that something would break. At the moment we recommend
|
34 |
-
using wpdesk/wp-autoloader.
|
35 |
-
|
36 |
-
|
37 |
-
## Manual instalation
|
38 |
-
|
39 |
-
If you do not wish to use Composer and wpdesk/wp-autoloader, you probably should stop using any existing library as it breaks compatibility between plugins.
|
40 |
-
|
41 |
-
## Getting Started
|
42 |
-
|
43 |
-
## Project documentation
|
44 |
-
|
45 |
-
PHPDoc: https://wpdesk.gitlab.io/wp-persistence/index.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-pointer/README.md
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-pointer/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-pointer/pipelines)
|
2 |
-
[![coverage report](https://gitlab.com/wpdesk/wp-pointer/badges/master/coverage.svg?job=integration+test+lastest+coverage)](https://gitlab.com/wpdesk/wp-pointer/commits/master)
|
3 |
-
[![Latest Stable Version](https://poser.pugx.org/wpdesk/wp-pointer/v/stable)](https://packagist.org/packages/wpdesk/wp-pointer)
|
4 |
-
[![Total Downloads](https://poser.pugx.org/wpdesk/wp-pointer/downloads)](https://packagist.org/packages/wpdesk/wp-pointer)
|
5 |
-
[![Latest Unstable Version](https://poser.pugx.org/wpdesk/wp-pointer/v/unstable)](https://packagist.org/packages/wpdesk/wp-pointer)
|
6 |
-
[![License](https://poser.pugx.org/wpdesk/wp-pointer/license)](https://packagist.org/packages/wpdesk/wp-pointer)
|
7 |
-
|
8 |
-
|
9 |
-
WordPress Library to display pointer messages in admin area.
|
10 |
-
===================================================
|
11 |
-
|
12 |
-
## Project documentation
|
13 |
-
|
14 |
-
PHPDoc: https://wpdesk.gitlab.io/wp-pointer/index.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-saas-platform-client/README.md
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
[![pipeline status](https://gitlab.com/wpdesk/wp-saas-platform-client/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/wp-saas-platform-client/commits/master)
|
2 |
-
Integration: [![coverage report](https://gitlab.com/wpdesk/wp-saas-platform-client/badges/master/coverage.svg?job=integration+test+lastest+coverage)](https://gitlab.com/wpdesk/wp-saas-platform-client/commits/master)
|
3 |
-
Unit: [![coverage report](https://gitlab.com/wpdesk/wp-saas-platform-client/badges/master/coverage.svg?job=unit+test+lastest+coverage)](https://gitlab.com/wpdesk/wp-saas-platform-client/commits/master)
|
4 |
-
|
5 |
-
SaaS Platform Client
|
6 |
-
====================
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/.gitlab-ci.yml
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
variables:
|
2 |
-
PHP_ERROR_REPORTING: E_ALL
|
3 |
-
COMPOSER_ALLOW_SUPERUSER: 1
|
4 |
-
GIT_STRATEGY: fetch
|
5 |
-
|
6 |
-
stages:
|
7 |
-
- tools
|
8 |
-
- tests
|
9 |
-
|
10 |
-
.template: &job-test-template
|
11 |
-
stage: tests
|
12 |
-
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
13 |
-
|
14 |
-
.template: &job-test-unit-template
|
15 |
-
<<: *job-test-template
|
16 |
-
script:
|
17 |
-
- echo ${WPDESK_CI_VERSION}
|
18 |
-
- ls -l
|
19 |
-
- php --version
|
20 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
21 |
-
- cat /tmp/woocommerce/woocommerce.php
|
22 |
-
- composer update --no-progress
|
23 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --coverage-text --colors=never
|
24 |
-
|
25 |
-
.template: &job-test-unit-template-fast
|
26 |
-
<<: *job-test-unit-template
|
27 |
-
script:
|
28 |
-
- echo ${WPDESK_CI_VERSION}
|
29 |
-
- ls -l
|
30 |
-
- php --version
|
31 |
-
- cat /tmp/wordpress-develop/src/wp-includes/version.php
|
32 |
-
- cat /tmp/woocommerce/woocommerce.php
|
33 |
-
- composer update --no-progress
|
34 |
-
- vendor/bin/phpunit --configuration phpunit-unit.xml --no-coverage
|
35 |
-
|
36 |
-
|
37 |
-
before_script:
|
38 |
-
- cd ${CI_PROJECT_DIR}
|
39 |
-
|
40 |
-
phpmetric metrics:
|
41 |
-
stage: tools
|
42 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
43 |
-
allow_failure: true
|
44 |
-
when: manual
|
45 |
-
artifacts:
|
46 |
-
when: always
|
47 |
-
expire_in: 1 month
|
48 |
-
name: "metrics"
|
49 |
-
paths:
|
50 |
-
- ${CI_PROJECT_DIR}/phpmetric
|
51 |
-
script:
|
52 |
-
- echo ${WPDESK_CI_VERSION}
|
53 |
-
- composer require phpmetrics/phpmetrics
|
54 |
-
- composer update --no-progress
|
55 |
-
- php ./vendor/bin/phpmetrics --report-html=phpmetric .
|
56 |
-
|
57 |
-
churn metrics:
|
58 |
-
stage: tools
|
59 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
60 |
-
allow_failure: true
|
61 |
-
when: manual
|
62 |
-
script:
|
63 |
-
- echo ${WPDESK_CI_VERSION}
|
64 |
-
- composer require bmitch/churn-php
|
65 |
-
- composer update --no-progress
|
66 |
-
- vendor/bin/churn run classes inc
|
67 |
-
|
68 |
-
unit test lastest:
|
69 |
-
<<: *job-test-unit-template-fast
|
70 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
71 |
-
|
72 |
-
integration test lastest:
|
73 |
-
<<: *job-test-unit-template
|
74 |
-
image: wpdesknet/phpunit-woocommerce:0-0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/integration/bootstrap.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
|
4 |
-
ini_set('display_errors', '1');
|
5 |
-
ini_set('display_startup_errors', '1');
|
6 |
-
|
7 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
8 |
-
|
9 |
-
// disable xdebug backtrace
|
10 |
-
if ( function_exists( 'xdebug_disable' ) ) {
|
11 |
-
xdebug_disable();
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
|
15 |
-
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
|
16 |
-
} else {
|
17 |
-
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR );
|
18 |
-
}
|
19 |
-
|
20 |
-
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
|
21 |
-
|
22 |
-
tests_add_filter( 'muplugins_loaded', function () {
|
23 |
-
}, 100 );
|
24 |
-
|
25 |
-
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
|
26 |
-
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
|
27 |
-
|
28 |
-
do_action('plugins_loaded');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Renderer/TestSimplePhpRenderer.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
use WPDesk\View\Resolver\ChainResolver;
|
4 |
-
use WPDesk\View\Resolver\Exception\CanNotResolve;
|
5 |
-
use WPDesk\View\Resolver\NullResolver;
|
6 |
-
|
7 |
-
class TestSimplePhpRenderer extends \PHPUnit\Framework\TestCase
|
8 |
-
{
|
9 |
-
const TEXT_IN_TEMPLATE = 'outputText';
|
10 |
-
|
11 |
-
const TEMPLATE_NAME = 'some_template';
|
12 |
-
|
13 |
-
const TEMPLATE_DIR = '/templates';
|
14 |
-
|
15 |
-
public function testRenderWithDirResolver()
|
16 |
-
{
|
17 |
-
$renderer = new \WPDesk\View\Renderer\SimplePhpRenderer(new \WPDesk\View\Resolver\DirResolver(__DIR__ . self::TEMPLATE_DIR));
|
18 |
-
$this->assertEquals(self::TEXT_IN_TEMPLATE, $renderer->render(self::TEMPLATE_NAME));
|
19 |
-
}
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Renderer/templates/some_template.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
echo 'outputText';
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Resolver/TestChainResolver.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
use WPDesk\View\Resolver\ChainResolver;
|
4 |
-
use WPDesk\View\Resolver\Exception\CanNotResolve;
|
5 |
-
use WPDesk\View\Resolver\NullResolver;
|
6 |
-
|
7 |
-
class TestChainResolver extends \PHPUnit\Framework\TestCase
|
8 |
-
{
|
9 |
-
const RESPONSE_OF_RESOLVER = 'response';
|
10 |
-
|
11 |
-
const RESOLVE_METHOD_NAME = 'resolve';
|
12 |
-
|
13 |
-
public function setUp()
|
14 |
-
{
|
15 |
-
\WP_Mock::setUp();
|
16 |
-
}
|
17 |
-
|
18 |
-
public function tearDown()
|
19 |
-
{
|
20 |
-
\WP_Mock::tearDown();
|
21 |
-
}
|
22 |
-
|
23 |
-
public function testUseSecondResolverWhenFirstFailed()
|
24 |
-
{
|
25 |
-
$validResolver = Mockery::mock(NullResolver::class);
|
26 |
-
$validResolver
|
27 |
-
->shouldReceive(self::RESOLVE_METHOD_NAME)
|
28 |
-
->andReturn(self::RESPONSE_OF_RESOLVER);
|
29 |
-
|
30 |
-
$resolver = new ChainResolver(new NullResolver(), new NullResolver(), $validResolver);
|
31 |
-
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever.php'));
|
32 |
-
}
|
33 |
-
|
34 |
-
public function testUseFirstResolverFirst()
|
35 |
-
{
|
36 |
-
$validResolver = Mockery::mock(NullResolver::class);
|
37 |
-
$validResolver
|
38 |
-
->shouldReceive(self::RESOLVE_METHOD_NAME)
|
39 |
-
->andReturn(self::RESPONSE_OF_RESOLVER);
|
40 |
-
|
41 |
-
$resolver = new ChainResolver($validResolver, new NullResolver(), new NullResolver());
|
42 |
-
$this->assertEquals(self::RESPONSE_OF_RESOLVER, $resolver->resolve('whatever.php'));
|
43 |
-
}
|
44 |
-
|
45 |
-
public function testThrowExceptionWhenBothCannotFind()
|
46 |
-
{
|
47 |
-
$this->expectException(CanNotResolve::class);
|
48 |
-
|
49 |
-
$resolver = new ChainResolver(new NullResolver(), new NullResolver());
|
50 |
-
|
51 |
-
$resolver->resolve('whatever2');
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Resolver/TestDirResolver.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
use WPDesk\View\Resolver\Exception\CanNotResolve;
|
5 |
-
|
6 |
-
class TestDirResolver extends \PHPUnit\Framework\TestCase
|
7 |
-
{
|
8 |
-
const TEMPLATE_NAME = 'some_template.php';
|
9 |
-
const TEMPLATE_FILE = 'some_template.php';
|
10 |
-
const TEMPLATE_SUBDIR = 'templates';
|
11 |
-
|
12 |
-
|
13 |
-
public function testCanFindInDirPath()
|
14 |
-
{
|
15 |
-
$dir = __DIR__ . '/' . self::TEMPLATE_SUBDIR;
|
16 |
-
$resolver = new \WPDesk\View\Resolver\DirResolver($dir);
|
17 |
-
|
18 |
-
$this->assertStringEndsWith(self::TEMPLATE_FILE, $resolver->resolve(self::TEMPLATE_NAME),
|
19 |
-
'Template should be found in dir');
|
20 |
-
}
|
21 |
-
|
22 |
-
public function testThrowExceptionWhenCannotFind()
|
23 |
-
{
|
24 |
-
$this->expectException(CanNotResolve::class);
|
25 |
-
|
26 |
-
$resolver = new \WPDesk\View\Resolver\DirResolver('whatever');
|
27 |
-
$resolver->resolve('whatever2');
|
28 |
-
}
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Resolver/TestWpThemeResolver.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
use WPDesk\View\Resolver\Exception\CanNotResolve;
|
5 |
-
|
6 |
-
class TestThemeResolver extends \PHPUnit\Framework\TestCase
|
7 |
-
{
|
8 |
-
const TEMPLATE_NAME = 'some_template.php';
|
9 |
-
const TEMPLATE_FILE = 'some_template.php';
|
10 |
-
const TEMPLATE_SUBDIR = 'templates';
|
11 |
-
|
12 |
-
public function setUp()
|
13 |
-
{
|
14 |
-
\WP_Mock::setUp();
|
15 |
-
|
16 |
-
\WP_Mock::userFunction('locate_template', [
|
17 |
-
'return' => function ($template_names, $load = false, $require_once = true) {
|
18 |
-
$located = '';
|
19 |
-
foreach ((array)$template_names as $template_name) {
|
20 |
-
if ( ! $template_name) {
|
21 |
-
continue;
|
22 |
-
}
|
23 |
-
if (file_exists(STYLESHEETPATH . '/' . $template_name)) {
|
24 |
-
$located = STYLESHEETPATH . '/' . $template_name;
|
25 |
-
break;
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
return $located;
|
30 |
-
}
|
31 |
-
]);
|
32 |
-
|
33 |
-
\WP_Mock::userFunction('trailingslashit', [
|
34 |
-
'return' => function ($string) {
|
35 |
-
return untrailingslashit($string) . '/';
|
36 |
-
}
|
37 |
-
]);
|
38 |
-
|
39 |
-
\WP_Mock::userFunction('untrailingslashit', [
|
40 |
-
'return' => function ($string) {
|
41 |
-
return rtrim($string, '/\\');
|
42 |
-
}
|
43 |
-
]);
|
44 |
-
}
|
45 |
-
|
46 |
-
public function tearDown()
|
47 |
-
{
|
48 |
-
\WP_Mock::tearDown();
|
49 |
-
}
|
50 |
-
|
51 |
-
public function testCanFindInStyleSheetPath()
|
52 |
-
{
|
53 |
-
define('STYLESHEETPATH', __DIR__);
|
54 |
-
|
55 |
-
$template_base_path = self::TEMPLATE_SUBDIR;
|
56 |
-
$resolver = new \WPDesk\View\Resolver\WPThemeResolver($template_base_path);
|
57 |
-
|
58 |
-
$this->assertStringEndsWith(self::TEMPLATE_FILE, $resolver->resolve(self::TEMPLATE_NAME),
|
59 |
-
'Template should be found in stylesheetpath');
|
60 |
-
}
|
61 |
-
|
62 |
-
public function testThrowExceptionWhenCannotFind()
|
63 |
-
{
|
64 |
-
$this->expectException(CanNotResolve::class);
|
65 |
-
|
66 |
-
$resolver = new \WPDesk\View\Resolver\WPThemeResolver('whatever');
|
67 |
-
$resolver->resolve('whatever2');
|
68 |
-
}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/wpdesk/wp-view/tests/unit/Resolver/templates/some_template.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
this is dummy text
|
|
vendor/wpdesk/wp-view/tests/unit/bootstrap.php
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* PHPUnit bootstrap file
|
4 |
-
*/
|
5 |
-
|
6 |
-
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
|
|
|
|
|
|
|
|