Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
81
vendor/consolidation/log/tests/src/TestDataPermuter.php
vendored
Normal file
81
vendor/consolidation/log/tests/src/TestDataPermuter.php
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
namespace Consolidation\TestUtils;
|
||||
|
||||
class TestDataPermuter
|
||||
{
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test AND each unit test requires
|
||||
* only scalar or object test value, find each array
|
||||
* in each test, and build all of the permutations for all
|
||||
* of the data provided in arrays.
|
||||
*/
|
||||
public static function expandProviderDataArrays($tests)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$subsitutionIndex = 1;
|
||||
$permutationData = [];
|
||||
$replacements = [];
|
||||
|
||||
foreach($test as $testValue) {
|
||||
if (is_array($testValue)) {
|
||||
$key = "{SUB$subsitutionIndex}";
|
||||
$replacements[$key] = $testValue;
|
||||
$permutationData[] = $key;
|
||||
}
|
||||
else {
|
||||
$permutationData[] = $testValue;
|
||||
}
|
||||
}
|
||||
|
||||
$permuted = static::expandDataMatrix([$permutationData], $replacements);
|
||||
$result = array_merge($result, $permuted);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, expand all of the
|
||||
* permutations of $replacements, where each key
|
||||
* holds the placeholder value, and the value holds
|
||||
* an array of replacement values.
|
||||
*/
|
||||
public static function expandDataMatrix($tests, $replacements)
|
||||
{
|
||||
foreach($replacements as $substitute => $values) {
|
||||
$tests = static::expandOneValue($tests, $substitute, $values);
|
||||
}
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of test data, where each element is
|
||||
* data to pass to a unit test, find any element in any
|
||||
* one test item whose value is exactly $substitute.
|
||||
* Make a new test item for every item in $values, using
|
||||
* each as the substitution for $substitute.
|
||||
*/
|
||||
public static function expandOneValue($tests, $substitute, $values)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach($tests as $test) {
|
||||
$position = array_search($substitute, $test);
|
||||
if ($position === FALSE) {
|
||||
$result[] = $test;
|
||||
}
|
||||
else {
|
||||
foreach($values as $replacement) {
|
||||
$test[$position] = $replacement;
|
||||
$result[] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
54
vendor/consolidation/log/tests/testLogMethods.php
vendored
Normal file
54
vendor/consolidation/log/tests/testLogMethods.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class LogMethodTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup() {
|
||||
$this->output = new BufferedOutput();
|
||||
$this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
$this->logger = new Logger($this->output);
|
||||
$this->logger->setLogOutputStyler(new UnstyledLogOutputStyler());
|
||||
}
|
||||
|
||||
function testError() {
|
||||
$this->logger->error('Do not enter - wrong way.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [error] Do not enter - wrong way.', $outputText);
|
||||
}
|
||||
|
||||
function testWarning() {
|
||||
$this->logger->warning('Steep grade.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [warning] Steep grade.', $outputText);
|
||||
}
|
||||
|
||||
function testNotice() {
|
||||
$this->logger->notice('No loitering.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [notice] No loitering.', $outputText);
|
||||
}
|
||||
|
||||
function testInfo() {
|
||||
$this->logger->info('Scenic route.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [info] Scenic route.', $outputText);
|
||||
}
|
||||
|
||||
function testDebug() {
|
||||
$this->logger->debug('Counter incremented.');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [debug] Counter incremented.', $outputText);
|
||||
}
|
||||
|
||||
function testSuccess() {
|
||||
$this->logger->success('It worked!');
|
||||
$outputText = rtrim($this->output->fetch());
|
||||
$this->assertEquals(' [success] It worked!', $outputText);
|
||||
}
|
||||
}
|
164
vendor/consolidation/log/tests/testLoggerVerbosityAndStyles.php
vendored
Normal file
164
vendor/consolidation/log/tests/testLoggerVerbosityAndStyles.php
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
<?php
|
||||
namespace Consolidation\Log;
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Consolidation\TestUtils\TestDataPermuter;
|
||||
|
||||
class LoggerVerbosityAndStyleTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $output;
|
||||
protected $logger;
|
||||
|
||||
function setup() {
|
||||
$this->output = new BufferedOutput();
|
||||
//$this->output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
$this->logger = new Logger($this->output);
|
||||
}
|
||||
|
||||
public static function logTestValues()
|
||||
{
|
||||
/**
|
||||
* Use TEST_ALL_LOG_LEVELS to ensure that output is the same
|
||||
* in instances where the output does not vary by log level.
|
||||
*/
|
||||
$TEST_ALL_LOG_LEVELS = [
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
];
|
||||
|
||||
// Tests that return the same value for multiple inputs
|
||||
// may use the expandProviderDataArrays method, and list
|
||||
// repeated scalars as array values. All permutations of
|
||||
// all array items will be calculated, and one test will
|
||||
// be generated for each one.
|
||||
return TestDataPermuter::expandProviderDataArrays([
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::ERROR,
|
||||
'Do not enter - wrong way.',
|
||||
' [error] Do not enter - wrong way.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
' [warning] Steep grade.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
],
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
' [notice] No loitering.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
' [info] Scenic route.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
' [debug] Counter incremented.',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
[
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_NORMAL
|
||||
],
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
'',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\UnstyledLogOutputStyler',
|
||||
$TEST_ALL_LOG_LEVELS,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\LogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
' [success] It worked!',
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::WARNING,
|
||||
'Steep grade.',
|
||||
"\n [WARNING] Steep grade.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::NOTICE,
|
||||
'No loitering.',
|
||||
"\n ! [NOTE] No loitering.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::INFO,
|
||||
'Scenic route.',
|
||||
"\n ! [NOTE] Scenic route.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_DEBUG,
|
||||
LogLevel::DEBUG,
|
||||
'Counter incremented.',
|
||||
"\n ! [NOTE] Counter incremented.",
|
||||
],
|
||||
[
|
||||
'\Consolidation\Log\SymfonyLogOutputStyler',
|
||||
OutputInterface::VERBOSITY_NORMAL,
|
||||
ConsoleLogLevel::SUCCESS,
|
||||
'It worked!',
|
||||
"\n [OK] It worked!",
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is our only test method. It accepts all of the
|
||||
* permuted data from the data provider, and runs one
|
||||
* test on each one.
|
||||
*
|
||||
* @dataProvider logTestValues
|
||||
*/
|
||||
function testLogging($styleClass, $verbocity, $level, $message, $expected) {
|
||||
$logStyler = new $styleClass;
|
||||
$this->logger->setLogOutputStyler($logStyler);
|
||||
$this->output->setVerbosity($verbocity);
|
||||
$this->logger->log($level, $message);
|
||||
$outputText = rtrim($this->output->fetch(), "\n\r\t ");
|
||||
$this->assertEquals($expected, $outputText);
|
||||
}
|
||||
}
|
Reference in a new issue