Skip to content

Commit

Permalink
Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Oct 21, 2024
1 parent 78487b1 commit 823ade9
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 87 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Component\Resource\tests\Symfony\ExpressionLanguage;

use Sylius\Resource\Symfony\ExpressionLanguage\ArgumentParserInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

final class ArgumentParserTest extends KernelTestCase
{
public function testResourceFactoryArgumentParser(): void
{
self::bootKernel();

$container = static::getContainer();

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.factory');

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
$this->assertTrue($argumentParser->parseExpression('token.getUser() === null'));
$this->assertTrue($argumentParser->parseExpression('user === null'));
$this->assertTrue($argumentParser->parseExpression('request === null'));
}

public function testRepositoryArgumentParser(): void
{
self::bootKernel();

$container = static::getContainer();

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.repository');

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
$this->assertTrue($argumentParser->parseExpression('token.getUser() === null'));
$this->assertTrue($argumentParser->parseExpression('user === null'));
$this->assertTrue($argumentParser->parseExpression('request === null'));
}

public function testRoutingArgumentParser(): void
{
self::bootKernel();

$container = static::getContainer();

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.routing');
$this->assertTrue($argumentParser->parseExpression('request === null'));

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,45 @@

declare(strict_types=1);

namespace Sylius\Component\Resource\tests\Symfony\ExpressionLanguage;
namespace Sylius\Resource\Tests\Symfony\ExpressionLanguage;

use Sylius\Resource\Symfony\ExpressionLanguage\ArgumentParserInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use PHPUnit\Framework\TestCase;
use Sylius\Resource\Symfony\ExpressionLanguage\ArgumentParser;
use Sylius\Resource\Symfony\ExpressionLanguage\VariablesCollectionInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

final class ArgumentParserTest extends KernelTestCase
final class ArgumentParserTest extends TestCase
{
public function testResourceFactoryArgumentParser(): void
{
self::bootKernel();

$container = static::getContainer();
private ArgumentParser $argumentParser;

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.factory');
private VariablesCollectionInterface $variablesCollection;

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
$this->assertTrue($argumentParser->parseExpression('token.getUser() === null'));
$this->assertTrue($argumentParser->parseExpression('user === null'));
$this->assertTrue($argumentParser->parseExpression('request === null'));
protected function setUp(): void
{
$this->variablesCollection = $this->createMock(VariablesCollectionInterface::class);
$this->argumentParser = new ArgumentParser(new ExpressionLanguage(), $this->variablesCollection);
}

public function testRepositoryArgumentParser(): void
public function testItIsInitializable(): void
{
self::bootKernel();
$this->assertInstanceOf(ArgumentParser::class, $this->argumentParser);
}

$container = static::getContainer();
public function testItParsesExpressions(): void
{
$this->variablesCollection->method('getVariables')->willReturn(['foo' => 'fighters']);

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.repository');
$result = $this->argumentParser->parseExpression('foo');

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
$this->assertTrue($argumentParser->parseExpression('token.getUser() === null'));
$this->assertTrue($argumentParser->parseExpression('user === null'));
$this->assertTrue($argumentParser->parseExpression('request === null'));
$this->assertSame('fighters', $result);
}

public function testRoutingArgumentParser(): void
public function testItMergesVariables(): void
{
self::bootKernel();

$container = static::getContainer();
$this->variablesCollection->method('getVariables')->willReturn(['foo' => 'fighters']);

/** @var ArgumentParserInterface $argumentParser */
$argumentParser = $container->get('sylius.expression_language.argument_parser.routing');
$this->assertTrue($argumentParser->parseExpression('request === null'));
$result = $this->argumentParser->parseExpression('foo', ['foo' => 'bar']);

$this->assertInstanceOf(ArgumentParserInterface::class, $argumentParser);
$this->assertSame('bar', $result);
}
}

0 comments on commit 823ade9

Please sign in to comment.