mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Renamed domain ParameterManagement to PArameter
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Parameter\Parameter;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Infinito\Domain\Parameter\Parameter\VersionParameter;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class VersionParameterIntegrationTest extends KernelTestCase
|
||||
{
|
||||
public function testValidation()
|
||||
{
|
||||
self::bootKernel();
|
||||
$validator = self::$container->get(ValidatorInterface::class);
|
||||
$versionParameter = new VersionParameter();
|
||||
$versionParameter->setValue(123);
|
||||
$errors = $validator->validate($versionParameter)->count();
|
||||
$this->assertEquals(0, $errors);
|
||||
$versionParameter->setValue(null);
|
||||
$errors = $validator->validate($versionParameter)->count();
|
||||
$this->assertEquals(0, $errors);
|
||||
$versionParameter->setValue('abc');
|
||||
$errors = $validator->validate($versionParameter)->count();
|
||||
$this->assertGreaterThan(0, $errors);
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Parameter\Parameter;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Infinito\Domain\Parameter\Parameter\ViewParameter;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ViewParameterIntegrationTest extends KernelTestCase
|
||||
{
|
||||
public function testValidation()
|
||||
{
|
||||
self::bootKernel();
|
||||
$validator = self::$container->get(ValidatorInterface::class);
|
||||
$viewParameter = new ViewParameter();
|
||||
foreach (ActionType::getValues() as $value) {
|
||||
$this->assertNull($viewParameter->setValue($value));
|
||||
$this->assertEquals($value, $viewParameter->getValue());
|
||||
$errors = $validator->validate($viewParameter)->count();
|
||||
$this->assertEquals(0, $errors);
|
||||
}
|
||||
$viewParameter->setValue('abc');
|
||||
$errors = $validator->validate($viewParameter)->count();
|
||||
$this->assertGreaterThan(0, $errors);
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Parameter;
|
||||
|
||||
use Infinito\Domain\Parameter\ParameterFactory;
|
||||
use Infinito\Domain\Parameter\ValidGetParametersService;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Infinito\Domain\Parameter\ValidGetParameterServiceInterface;
|
||||
use Infinito\Domain\Parameter\Parameter\VersionParameter;
|
||||
use Infinito\Domain\Parameter\ParameterFactoryInterface;
|
||||
use Infinito\Exception\Validation\GetParameterInvalidException;
|
||||
use Infinito\Exception\Collection\NotSetElementException;
|
||||
use Infinito\Exception\Core\NotImplementedCoreException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ValidGetParameterServiceIntegrationTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
private $currentRequest;
|
||||
|
||||
/**
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* @var ValidGetParameterServiceInterface
|
||||
*/
|
||||
private $validGetParameterService;
|
||||
|
||||
/**
|
||||
* @var ParameterFactoryInterface
|
||||
*/
|
||||
private $parameterFactory;
|
||||
|
||||
/**
|
||||
* @var ValidatorInterface
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->currentRequest = new Request();
|
||||
$this->requestStack = $this->createMock(RequestStack::class);
|
||||
$this->requestStack->method('getCurrentRequest')->willReturn($this->currentRequest);
|
||||
$this->parameterFactory = new ParameterFactory();
|
||||
$this->validator = self::$container->get(ValidatorInterface::class);
|
||||
$this->validGetParameterService = new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
|
||||
}
|
||||
|
||||
public function testVersionCorrectType(): void
|
||||
{
|
||||
$key = VersionParameter::getKey();
|
||||
$value = 123;
|
||||
$this->currentRequest->query->set($key, $value);
|
||||
$result = $this->validGetParameterService->getParameter($key);
|
||||
$this->assertEquals($value, $result);
|
||||
}
|
||||
|
||||
public function testVersionWrongType(): void
|
||||
{
|
||||
$versionKey = VersionParameter::getKey();
|
||||
$this->currentRequest->query->set($versionKey, 'adasdas');
|
||||
$this->expectException(GetParameterInvalidException::class);
|
||||
$this->validGetParameterService->getParameter($versionKey);
|
||||
}
|
||||
|
||||
public function testConstructorInvalid(): void
|
||||
{
|
||||
$this->currentRequest->query->set(VersionParameter::getKey(), 'adasa');
|
||||
$this->expectException(GetParameterInvalidException::class);
|
||||
new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
|
||||
}
|
||||
|
||||
public function testConstructorNotImplemented(): void
|
||||
{
|
||||
$this->currentRequest->query->set('asdwgwe', 'adasa');
|
||||
$this->expectException(NotImplementedCoreException::class);
|
||||
new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
|
||||
}
|
||||
|
||||
public function testSetParameterException(): void
|
||||
{
|
||||
$this->expectException(NotSetElementException::class);
|
||||
$this->validGetParameterService->getParameter(VersionParameter::getKey());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user