Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboss86 committed Mar 19, 2024
1 parent 900c376 commit 1c9a038
Show file tree
Hide file tree
Showing 42 changed files with 150 additions and 140 deletions.
3 changes: 0 additions & 3 deletions spec/Controller/ReportControllerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

/**
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class ReportControllerSpec extends ObjectBehavior
{
function let(
Expand Down
3 changes: 0 additions & 3 deletions spec/DataFetcher/DataSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use Odiseo\SyliusReportPlugin\DataFetcher\Data;
use PhpSpec\ObjectBehavior;

/**
* @author Diego D'amico <diego@odiseo.com.ar>
*/
class DataSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down
3 changes: 0 additions & 3 deletions spec/DataFetcher/DelegatingDataFetcherSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PhpSpec\ObjectBehavior;
use Sylius\Component\Registry\ServiceRegistryInterface;

/**
* @author Diego D'amico <diego@odiseo.com.ar>
*/
class DelegatingDataFetcherSpec extends ObjectBehavior
{
function let(ServiceRegistryInterface $registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class RegisterDataFetchersPassSpec extends ObjectBehavior
{
function it_should_implement_compiler_pass_interface()
Expand All @@ -33,7 +29,10 @@ function it_processes_with_given_container(ContainerBuilder $container, Definiti
];
$container->findTaggedServiceIds('odiseo_sylius_report_plugin.data_fetcher')->willReturn($dataFetcherServices);

$dataFetcherDefinition->addMethodCall('register', ['test', new Reference('odiseo_sylius_report_plugin.form.type.data_fetcher.test')])->shouldBeCalled();
$dataFetcherDefinition->addMethodCall(
'register',
['test', new Reference('odiseo_sylius_report_plugin.form.type.data_fetcher.test')]
)->willReturn($dataFetcherDefinition);
$container->setParameter('odiseo_sylius_report_plugin.data_fetchers', ['test' => 'Test data fetcher'])->shouldBeCalled();

$this->process($container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class RegisterRenderersPassSpec extends ObjectBehavior
{
function it_should_implement_compiler_pass_interface()
Expand All @@ -33,7 +29,10 @@ function it_processes_with_given_container(ContainerBuilder $container, Definiti
];
$container->findTaggedServiceIds('odiseo_sylius_report_plugin.renderer')->willReturn($rendererServices);

$rendererDefinition->addMethodCall('register', ['test', new Reference('odiseo_sylius_report_plugin.form.type.renderer.test')])->shouldBeCalled();
$rendererDefinition->addMethodCall(
'register',
['test', new Reference('odiseo_sylius_report_plugin.form.type.renderer.test')]
)->willReturn($rendererDefinition);
$container->setParameter('odiseo_sylius_report_plugin.renderers', ['test' => 'Test renderer'])->shouldBeCalled();

$this->process($container);
Expand Down
3 changes: 0 additions & 3 deletions spec/Entity/ReportSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\TimestampableInterface;

/**
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class ReportSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryInterface;

/**
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class BuildReportDataFetcherFormSubscriberSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down Expand Up @@ -59,7 +55,7 @@ function it_adds_configuration_fields_in_pre_set_data(
Argument::cetera()
)->willReturn($field);

$form->add($field)->shouldBeCalled();
$form->add($field)->willReturn($form);

$this->preSetData($event);
}
Expand All @@ -81,7 +77,7 @@ function it_adds_configuration_fields_in_pre_bind(
Argument::cetera()
)->willReturn($field);

$form->add($field)->shouldBeCalled();
$form->add($field)->willReturn($form);

$this->preBind($event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryInterface;

/**
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class BuildReportRendererFormSubscriberSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down Expand Up @@ -59,7 +55,7 @@ function it_adds_configuration_fields_in_pre_set_data(
Argument::cetera()
)->willReturn($field);

$form->add($field)->shouldBeCalled();
$form->add($field)->willReturn($form);

$this->preSetData($event);
}
Expand All @@ -81,7 +77,7 @@ function it_adds_configuration_fields_in_pre_bind(
Argument::cetera()
)->willReturn($field);

$form->add($field)->shouldBeCalled();
$form->add($field)->willReturn($form);

$this->preBind($event);
}
Expand Down
2 changes: 1 addition & 1 deletion spec/Form/Type/DataFetcher/DataFetcherChoiceTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function it_sets_default_options(OptionsResolver $resolver)
'DataFetcher 2' => 'dataFetcher2',
];

$resolver->setDefaults(['choices' => $choices])->shouldBeCalled();
$resolver->setDefaults(['choices' => $choices])->willReturn($resolver);

$this->configureOptions($resolver);
}
Expand Down
4 changes: 0 additions & 4 deletions spec/Form/Type/Renderer/ChartConfigurationTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilder;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class ChartConfigurationTypeSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down
6 changes: 1 addition & 5 deletions spec/Form/Type/Renderer/RendererChoiceTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class RendererChoiceTypeSpec extends ObjectBehavior
{
function let()
Expand Down Expand Up @@ -42,7 +38,7 @@ function it_sets_default_options(OptionsResolver $resolver)
'Chart renderer' =>'chart',
];

$resolver->setDefaults(['choices' => $choices])->shouldBeCalled();
$resolver->setDefaults(['choices' => $choices])->willReturn($resolver);

$this->configureOptions($resolver);
}
Expand Down
4 changes: 0 additions & 4 deletions spec/Form/Type/Renderer/TableConfigurationTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilder;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class TableConfigurationTypeSpec extends ObjectBehavior
{
function it_is_initializable()
Expand Down
17 changes: 7 additions & 10 deletions spec/Form/Type/ReportTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class ReportTypeSpec extends ObjectBehavior
{
function let(
Expand Down Expand Up @@ -61,7 +57,8 @@ function it_build_form_with_proper_fields(
$dataFetcherRegistry,
$rendererRegistry,
RendererInterface $renderer,
DataFetcherInterface $dataFetcher
DataFetcherInterface $dataFetcher,
FormInterface $form
) {
$builder->getFormFactory()->willReturn($factory);

Expand All @@ -82,22 +79,22 @@ function it_build_form_with_proper_fields(
$renderer->getType()->willReturn('odiseo_sylius_report_renderer_test');
$rendererRegistry->all()->willReturn(['test_renderer' => $renderer]);
$builder->create('rendererConfiguration', 'odiseo_sylius_report_renderer_test')->willReturn($builder);
$builder->getForm()->shouldBeCalled()->willReturn(Argument::type(Form::class));
$builder->getForm()->willReturn($form);

$dataFetcher->getType()->willReturn('odiseo_sylius_report_data_fetcher_test');
$dataFetcherRegistry->all()->willReturn(['test_data_fetcher' => $dataFetcher]);
$builder->create('dataFetcherConfiguration', 'odiseo_sylius_report_data_fetcher_test')->willReturn($builder);
$builder->getForm()->shouldBeCalled()->willReturn(Argument::type(Form::class));
$builder->getForm()->willReturn($form);

$prototypes = [
'renderers' => [
'test_renderer' => Argument::type(Form::class),
'test_renderer' => $form,
],
'dataFetchers' => [
'test_data_fetcher' => Argument::type(Form::class),
'test_data_fetcher' => $form,
],
];
$builder->setAttribute('prototypes', $prototypes)->shouldBeCalled();
$builder->setAttribute('prototypes', $prototypes)->willReturn($builder);

$this->buildForm($builder, []);
}
Expand Down
5 changes: 0 additions & 5 deletions spec/Renderer/ChartRendererSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
use PhpSpec\ObjectBehavior;
use Twig\Environment;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class ChartRendererSpec extends ObjectBehavior
{
function let(Environment $templating)
Expand Down
3 changes: 0 additions & 3 deletions spec/Renderer/DelegatingRendererSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PhpSpec\ObjectBehavior;
use Sylius\Component\Registry\ServiceRegistryInterface;

/**
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class DelegatingRendererSpec extends ObjectBehavior
{
function let(ServiceRegistryInterface $registry)
Expand Down
5 changes: 0 additions & 5 deletions spec/Renderer/TableRendererSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
* @author Diego D'amico <diego@odiseo.com.ar>
*/
final class TableRendererSpec extends ObjectBehavior
{
function let(Environment $templating)
Expand Down
6 changes: 4 additions & 2 deletions src/Controller/Action/CitySearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
final class CitySearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler
ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->countryRepository = $countryRepository;
Expand Down Expand Up @@ -52,7 +54,7 @@ private function getAddresses(string $query): array
foreach ($searchAddresses as $address) {
/** @var CountryInterface|null $country */
$country = $this->countryRepository->findOneBy([
'code' => $address->getCountryCode()
'code' => $address->getCountryCode(),
]);

/** @var string $countryName */
Expand Down
6 changes: 4 additions & 2 deletions src/Controller/Action/PostcodeSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
final class PostcodeSearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler
ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->countryRepository = $countryRepository;
Expand Down Expand Up @@ -52,7 +54,7 @@ private function getAddresses(string $query): array
foreach ($searchAddresses as $address) {
/** @var CountryInterface|null $country */
$country = $this->countryRepository->findOneBy([
'code' => $address->getCountryCode()
'code' => $address->getCountryCode(),
]);

/** @var string $countryName */
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/Action/ProductSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
final class ProductSearchAction
{
private ProductRepositoryInterface $productRepository;

private LocaleContextInterface $localeContext;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
ProductRepositoryInterface $productRepository,
LocaleContextInterface $localeContext,
ConfigurableViewHandlerInterface $viewHandler
ConfigurableViewHandlerInterface $viewHandler,
) {
$this->productRepository = $productRepository;
$this->localeContext = $localeContext;
Expand Down
7 changes: 5 additions & 2 deletions src/Controller/Action/ProvinceSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
final class ProvinceSearchAction
{
private AddressRepositoryInterface $addressRepository;

private RepositoryInterface $provinceRepository;

private RepositoryInterface $countryRepository;

private ConfigurableViewHandlerInterface $viewHandler;

public function __construct(
AddressRepositoryInterface $addressRepository,
RepositoryInterface $provinceRepository,
RepositoryInterface $countryRepository,
ConfigurableViewHandlerInterface $viewHandler
ConfigurableViewHandlerInterface $viewHandler,
) {
$this->addressRepository = $addressRepository;
$this->provinceRepository = $provinceRepository;
Expand Down Expand Up @@ -56,7 +59,7 @@ private function getAddresses(string $query): array
foreach ($searchAddresses as $address) {
/** @var CountryInterface|null $country */
$country = $this->countryRepository->findOneBy([
'code' => $address->getCountryCode()
'code' => $address->getCountryCode(),
]);

/** @var string $countryName */
Expand Down
Loading

0 comments on commit 1c9a038

Please sign in to comment.