mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 04:14:36 +02:00
Refactored TwigExtensions Part 2
This commit is contained in:
parent
b078389381
commit
a9e527ce2a
22 changed files with 168 additions and 124 deletions
43
tests/Twig/UserExtensionTest.php
Normal file
43
tests/Twig/UserExtensionTest.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests\Twig;
|
||||
|
||||
use App\Twig\UserExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class UserExtensionTest extends WebTestCase
|
||||
{
|
||||
protected $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->service = self::getContainer()->get(UserExtension::class);
|
||||
}
|
||||
|
||||
public function removeeLocaleFromPathDataSet()
|
||||
{
|
||||
yield ['/', '/de/'];
|
||||
yield ['/test', '/de/test'];
|
||||
yield ['/test/foo', '/en/test/foo'];
|
||||
yield ['/test/foo/bar?param1=val1¶m2=val2', '/en/test/foo/bar?param1=val1¶m2=val2'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeeLocaleFromPathDataSet
|
||||
* @param string $expected
|
||||
* @param string $input
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveLocaleFromPath(string $expected, string $input): void
|
||||
{
|
||||
$this->assertEquals($expected, $this->service->removeLocaleFromPath($input));
|
||||
}
|
||||
|
||||
public function testRemoveLocaleFromPathException(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->service->removeLocaleFromPath('/part/info/1');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue