Merge branch '5.1' into 5.2

* 5.1:
  Remove wrong test
  [Uid] Unable to extend Uuid/Ulid and use fromString()
  Fix typo in property name
This commit is contained in:
Jérémy Derussé 2021-01-21 17:54:56 +01:00
commit c1769d1b48
No known key found for this signature in database
GPG Key ID: 2083FA5758C473D2
7 changed files with 54 additions and 7 deletions

View File

@ -51,7 +51,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO,
OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG,
];
private $consoleFormaterOptions;
private $consoleFormatterOptions;
/**
* @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null
@ -60,7 +60,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
* @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging
* level (leave empty to use the default mapping)
*/
public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = [], array $consoleFormaterOptions = [])
public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = [], array $consoleFormatterOptions = [])
{
parent::__construct(Logger::DEBUG, $bubble);
$this->output = $output;
@ -69,7 +69,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
$this->verbosityLevelMap = $verbosityLevelMap;
}
$this->consoleFormaterOptions = $consoleFormaterOptions;
$this->consoleFormatterOptions = $consoleFormatterOptions;
}
/**
@ -159,13 +159,13 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
return new LineFormatter();
}
if (!$this->output) {
return new ConsoleFormatter($this->consoleFormaterOptions);
return new ConsoleFormatter($this->consoleFormatterOptions);
}
return new ConsoleFormatter(array_replace([
'colors' => $this->output->isDecorated(),
'multiline' => OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity(),
], $this->consoleFormaterOptions));
], $this->consoleFormatterOptions));
}
/**

View File

@ -36,7 +36,6 @@ class CsrfFormLoginTest extends AbstractWebTestCase
$logoutLinks = $crawler->selectLink('Log out')->links();
$this->assertCount(2, $logoutLinks);
$this->assertStringContainsString('_csrf_token=', $logoutLinks[0]->getUri());
$this->assertSame($logoutLinks[0]->getUri(), $logoutLinks[1]->getUri());
$client->click($logoutLinks[0]);

View File

@ -0,0 +1,18 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Uid\Tests\Fixtures;
use Symfony\Component\Uid\Ulid;
final class CustomUlid extends Ulid
{
}

View File

@ -0,0 +1,18 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Uid\Tests\Fixtures;
use Symfony\Component\Uid\Uuid;
final class CustomUuid extends Uuid
{
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Uid\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Tests\Fixtures\CustomUlid;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\UuidV4;
@ -118,4 +119,9 @@ class UlidTest extends TestCase
$this->assertLessThan(0, $b->compare($c));
$this->assertGreaterThan(0, $c->compare($b));
}
public function testFromStringOnExtendedClassReturnsStatic()
{
$this->assertInstanceOf(CustomUlid::class, CustomUlid::fromString((new CustomUlid())->toBinary()));
}
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Uid\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\NilUuid;
use Symfony\Component\Uid\Tests\Fixtures\CustomUuid;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Uid\UuidV1;
@ -193,4 +194,9 @@ class UuidTest extends TestCase
$this->assertInstanceOf(NilUuid::class, $uuid);
$this->assertSame('00000000-0000-0000-0000-000000000000', (string) $uuid);
}
public function testFromStringOnExtendedClassReturnsStatic()
{
$this->assertInstanceOf(CustomUuid::class, CustomUuid::fromString(self::A_UUID_V4));
}
}

View File

@ -79,7 +79,7 @@ class Ulid extends AbstractUid
base_convert(substr($ulid, 27, 5), 16, 32)
);
return new self(strtr($ulid, 'abcdefghijklmnopqrstuv', 'ABCDEFGHJKMNPQRSTVWXYZ'));
return new static(strtr($ulid, 'abcdefghijklmnopqrstuv', 'ABCDEFGHJKMNPQRSTVWXYZ'));
}
public function toBinary(): string