-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.2: [Translation] Decouple TranslatorPathsPass from "debug." convention [VarDumper] Add a bit of test coverage [TwigBridge] Fix flagged malicious url [HttpClient] Fix encoding "+" in URLs [DependencyInjection] Fix dumping array of enums parameters Bump Symfony version to 6.2.8 Update VERSION for 6.2.7 Update CHANGELOG for 6.2.7 Bump Symfony version to 5.4.22 Update VERSION for 5.4.21 Update CONTRIBUTORS for 5.4.21 Update CHANGELOG for 5.4.21 [Messenger] Fix TransportNamesStamp deserialization Removed @internal tag on TraceableAuthenticator::getAuthenticator()
- Loading branch information
Showing
4 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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\VarDumper\Tests\Caster; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\Mapping\ClassMetadata; | ||
use Doctrine\ORM\PersistentCollection; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait; | ||
|
||
/** | ||
* @requires function \Doctrine\Common\Collections\ArrayCollection::__construct | ||
*/ | ||
class DoctrineCasterTest extends TestCase | ||
{ | ||
use VarDumperTestTrait; | ||
|
||
public function testCastPersistentCollection() | ||
{ | ||
$classMetadata = new ClassMetadata(__CLASS__); | ||
|
||
$collection = new PersistentCollection($this->createMock(EntityManagerInterface::class), $classMetadata, new ArrayCollection(['test'])); | ||
|
||
$expected = <<<EODUMP | ||
Doctrine\ORM\PersistentCollection { | ||
%A | ||
-em: Mock_EntityManagerInterface_%s { …3} | ||
-backRefFieldName: null | ||
-typeClass: Doctrine\ORM\Mapping\ClassMetadata { …} | ||
%A | ||
EODUMP; | ||
|
||
$this->assertDumpMatchesFormat($expected, $collection); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?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\VarDumper\Tests\Caster; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait; | ||
|
||
class FiberCasterTest extends TestCase | ||
{ | ||
use VarDumperTestTrait; | ||
|
||
public function testCastFiberNotStarted() | ||
{ | ||
$fiber = new \Fiber(static fn() => true); | ||
|
||
$expected = <<<EODUMP | ||
Fiber { | ||
status: "not started" | ||
} | ||
EODUMP; | ||
|
||
$this->assertDumpEquals($expected, $fiber); | ||
} | ||
|
||
public function testCastFiberTerminated() | ||
{ | ||
$fiber = new \Fiber(static fn () => true); | ||
$fiber->start(); | ||
|
||
$expected = <<<EODUMP | ||
Fiber { | ||
status: "terminated" | ||
} | ||
EODUMP; | ||
|
||
$this->assertDumpEquals($expected, $fiber); | ||
} | ||
|
||
public function testCastFiberSuspended() | ||
{ | ||
$fiber = new \Fiber(\Fiber::suspend(...)); | ||
$fiber->start(); | ||
|
||
$expected = <<<EODUMP | ||
Fiber { | ||
status: "suspended" | ||
} | ||
EODUMP; | ||
|
||
$this->assertDumpEquals($expected, $fiber); | ||
} | ||
|
||
public function testCastFiberRunning() | ||
{ | ||
$fiber = new \Fiber(function () { | ||
$expected = <<<EODUMP | ||
Fiber { | ||
status: "running" | ||
} | ||
EODUMP; | ||
|
||
$this->assertDumpEquals($expected, \Fiber::getCurrent()); | ||
}); | ||
|
||
$fiber->start(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Tests/Dumper/ContextProvider/RequestContextProviderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?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 Dumper\ContextProvider; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\VarDumper\Cloner\Data; | ||
use Symfony\Component\VarDumper\Dumper\ContextProvider\RequestContextProvider; | ||
|
||
/** | ||
* @requires function \Symfony\Component\HttpFoundation\RequestStack::__construct | ||
*/ | ||
class RequestContextProviderTest extends TestCase | ||
{ | ||
public function testGetContextOnNullRequest() | ||
{ | ||
$requestStack = new RequestStack(); | ||
$provider = new RequestContextProvider($requestStack); | ||
|
||
$this->assertNull($provider->getContext()); | ||
} | ||
|
||
public function testGetContextOnRequest() | ||
{ | ||
$request = Request::create('https://example.org/', 'POST'); | ||
$request->attributes->set('_controller', 'MyControllerClass'); | ||
|
||
$requestStack = new RequestStack(); | ||
$requestStack->push($request); | ||
|
||
$context = (new RequestContextProvider($requestStack))->getContext(); | ||
$this->assertSame('https://example.org/', $context['uri']); | ||
$this->assertSame('POST', $context['method']); | ||
$this->assertInstanceOf(Data::class, $context['controller']); | ||
$this->assertSame('MyControllerClass', $context['controller']->getValue()); | ||
$this->assertSame('https://example.org/', $context['uri']); | ||
$this->assertArrayHasKey('identifier', $context); | ||
} | ||
} |