Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Jan 29, 2025
1 parent 04fc310 commit 6ea59f4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 90 deletions.
3 changes: 1 addition & 2 deletions lib/Parameters/ParameterType/ChannelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Netgen\Layouts\Parameters\ParameterType;
use Netgen\Layouts\Parameters\ValueObjectProviderInterface;
use Netgen\Layouts\Sylius\Validator\Constraint as SyliusConstraints;
use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints;
Expand All @@ -35,7 +34,7 @@ public function configureOptions(OptionsResolver $optionsResolver): void
$optionsResolver->setAllowedTypes('multiple', 'bool');
}

public function getValueObject($value): ?ChannelInterface
public function getValueObject($value): ?object
{
return $this->channelRepository->find($value);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Parameters/ParameterType/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Netgen\Layouts\Parameters\ParameterType;
use Netgen\Layouts\Parameters\ValueObjectProviderInterface;
use Netgen\Layouts\Sylius\Validator\Constraint as SyliusConstraints;
use Sylius\Component\Product\Model\ProductInterface;
use Sylius\Component\Product\Repository\ProductRepositoryInterface;
use Symfony\Component\Validator\Constraints;

Expand All @@ -27,7 +26,7 @@ public static function getIdentifier(): string
return 'sylius_product';
}

public function getValueObject($value): ?ProductInterface
public function getValueObject($value): ?object
{
return $this->productRepository->find($value);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Parameters/ParameterType/TaxonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Netgen\Layouts\Parameters\ParameterType;
use Netgen\Layouts\Parameters\ValueObjectProviderInterface;
use Netgen\Layouts\Sylius\Validator\Constraint as SyliusConstraints;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\Validator\Constraints;

Expand All @@ -27,7 +26,7 @@ public static function getIdentifier(): string
return 'sylius_taxon';
}

public function getValueObject($value): ?TaxonInterface
public function getValueObject($value): ?object
{
return $this->taxonRepository->find($value);
}
Expand Down
44 changes: 16 additions & 28 deletions tests/lib/Parameters/ParameterType/ChannelTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Netgen\Layouts\Sylius\Tests\Parameters\ParameterType;

use Netgen\Layouts\Parameters\ParameterDefinition;
use Netgen\Layouts\Parameters\ParameterTypeInterface;
use Netgen\Layouts\Sylius\Parameters\ParameterType\ChannelType;
use Netgen\Layouts\Sylius\Tests\Stubs\Channel as ChannelStub;
use Netgen\Layouts\Sylius\Tests\Validator\RepositoryValidatorFactory;
Expand All @@ -23,9 +22,6 @@ final class ChannelTypeTest extends TestCase
{
use ParameterTypeTestTrait;

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\ChannelType */
private ParameterTypeInterface $type;

private MockObject&ChannelRepositoryInterface $repositoryMock;

protected function setUp(): void
Expand Down Expand Up @@ -110,30 +106,6 @@ public static function invalidOptionsDataProvider(): iterable
];
}

public function testValueObjectNull(): void
{
$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(null))
->willReturn(null);

self::assertNull($this->type->getValueObject(null));
}

public function testValueObjectIsValidObject(): void
{
$stub = new ChannelStub(1, 'test', 'test');

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

self::assertSame($stub, $this->type->getValueObject(1));
}

public function testValidationValid(): void
{
$this->repositoryMock
Expand Down Expand Up @@ -196,4 +168,20 @@ public static function emptyDataProvider(): iterable
[new ChannelStub(42, 'WEBSHOP', 'Webshop'), false],
];
}

public function testGetValueObject(): void
{
$stub = new ChannelStub(1, 'test', 'test');

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\ChannelType $type */
$type = $this->type;

self::assertSame($stub, $type->getValueObject(1));
}
}
44 changes: 16 additions & 28 deletions tests/lib/Parameters/ParameterType/ProductTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Netgen\Layouts\Sylius\Tests\Parameters\ParameterType;

use Netgen\Layouts\Parameters\ParameterDefinition;
use Netgen\Layouts\Parameters\ParameterTypeInterface;
use Netgen\Layouts\Sylius\Parameters\ParameterType\ProductType;
use Netgen\Layouts\Sylius\Tests\Stubs\Product as ProductStub;
use Netgen\Layouts\Sylius\Tests\Validator\RepositoryValidatorFactory;
Expand All @@ -23,9 +22,6 @@ final class ProductTypeTest extends TestCase
{
use ParameterTypeTestTrait;

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\ProductType */
private ParameterTypeInterface $type;

private MockObject&ProductRepositoryInterface $repositoryMock;

protected function setUp(): void
Expand Down Expand Up @@ -89,30 +85,6 @@ public static function invalidOptionsDataProvider(): iterable
];
}

public function testValueObjectNull(): void
{
$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(null))
->willReturn(null);

self::assertNull($this->type->getValueObject(null));
}

public function testValueObjectIsValidObject(): void
{
$stub = new ProductStub(1);

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

self::assertSame($stub, $this->type->getValueObject(1));
}

public function testValidationValid(): void
{
$this->repositoryMock
Expand Down Expand Up @@ -175,4 +147,20 @@ public static function emptyDataProvider(): iterable
[new ProductStub(42), false],
];
}

public function testGetValueObject(): void
{
$stub = new ProductStub(1);

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\ProductType $type */
$type = $this->type;

self::assertSame($stub, $type->getValueObject(1));
}
}
44 changes: 16 additions & 28 deletions tests/lib/Parameters/ParameterType/TaxonTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Netgen\Layouts\Sylius\Tests\Parameters\ParameterType;

use Netgen\Layouts\Parameters\ParameterDefinition;
use Netgen\Layouts\Parameters\ParameterTypeInterface;
use Netgen\Layouts\Sylius\Parameters\ParameterType\TaxonType;
use Netgen\Layouts\Sylius\Tests\Stubs\Taxon as TaxonStub;
use Netgen\Layouts\Sylius\Tests\Validator\RepositoryValidatorFactory;
Expand All @@ -23,9 +22,6 @@ final class TaxonTypeTest extends TestCase
{
use ParameterTypeTestTrait;

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\TaxonType */
private ParameterTypeInterface $type;

private MockObject&TaxonRepositoryInterface $repositoryMock;

protected function setUp(): void
Expand Down Expand Up @@ -89,30 +85,6 @@ public static function invalidOptionsDataProvider(): iterable
];
}

public function testValueObjectNull(): void
{
$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(null))
->willReturn(null);

self::assertNull($this->type->getValueObject(null));
}

public function testValueObjectIsValidObject(): void
{
$stub = new TaxonStub(1);

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

self::assertSame($stub, $this->type->getValueObject(1));
}

public function testValidationValid(): void
{
$this->repositoryMock
Expand Down Expand Up @@ -175,4 +147,20 @@ public static function emptyDataProvider(): iterable
[new TaxonStub(42), false],
];
}

public function testGetValueObject(): void
{
$stub = new TaxonStub(1);

$this->repositoryMock
->expects(self::once())
->method('find')
->with(self::identicalTo(1))
->willReturn($stub);

/** @var \Netgen\Layouts\Sylius\Parameters\ParameterType\TaxonType $type */
$type = $this->type;

self::assertSame($stub, $type->getValueObject(1));
}
}

0 comments on commit 6ea59f4

Please sign in to comment.