Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboss86 committed Oct 14, 2021
1 parent 4b03af6 commit 8e1e62a
Show file tree
Hide file tree
Showing 65 changed files with 316 additions and 255 deletions.
1 change: 1 addition & 0 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ sylius_address:
6. Finish the installation updating the database schema and installing assets
```
php bin/console doctrine:migrations:migrate
php bin/console sylius:theme:assets:install
php bin/console cache:clear
```
2 changes: 1 addition & 1 deletion features/admin/adding_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: Adding a new report
When I fill the code with "2018_sales"
And I fill the name with "2018 Sales"
And I fill the description with "Sales statistic for year 2018"
And I select "odiseo_sylius_report_data_fetcher_sales_total" as data fetcher
And I select "odiseo_sylius_report_plugin_data_fetcher_sales_total" as data fetcher
And I select "2018-01-01" as start date
And I select today as end date
And I select "month" as time period
Expand Down
4 changes: 3 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
<arg name="extensions" value="php" />
<arg name="standard" value="PSR12" />

<rule ref="PSR12"/>
<rule ref="PSR12">
<exclude-pattern>src/Migrations/*</exclude-pattern>
</rule>
</ruleset>
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
<PossiblyUndefinedMethod errorLevel="info" />
<MixedMethodCall errorLevel="info" />
<PossiblyInvalidArgument errorLevel="info" />
<MixedArrayAssignment errorLevel="info" />
<MixedArgumentTypeCoercion errorLevel="info" />
<TooManyArguments errorLevel="info" />
<MixedOperand errorLevel="info" />
<MixedArrayAccess errorLevel="info" />
</issueHandlers>
</psalm>
4 changes: 3 additions & 1 deletion spec/Controller/ReportControllerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Controller;

use Doctrine\Persistence\ObjectManager;
Expand Down Expand Up @@ -35,7 +37,7 @@
/**
* @author Diego D'amico <[email protected]>
*/
class ReportControllerSpec extends ObjectBehavior
final class ReportControllerSpec extends ObjectBehavior
{
function let(
MetadataInterface $metadata,
Expand Down
2 changes: 2 additions & 0 deletions spec/DataFetcher/DataSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\DataFetcher;

use Odiseo\SyliusReportPlugin\DataFetcher\Data;
Expand Down
2 changes: 2 additions & 0 deletions spec/DataFetcher/DelegatingDataFetcherSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\DataFetcher;

use Odiseo\SyliusReportPlugin\DataFetcher\Data;
Expand Down
28 changes: 15 additions & 13 deletions spec/DependencyInjection/Compiler/RegisterDataFetchersPassSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\DependencyInjection\Compiler;

use PhpSpec\ObjectBehavior;
Expand All @@ -21,42 +23,42 @@ function it_should_implement_compiler_pass_interface()

function it_processes_with_given_container(ContainerBuilder $container, Definition $dataFetcherDefinition)
{
$container->hasDefinition('odiseo_sylius_report.registry.data_fetcher')->willReturn(true);
$container->getDefinition('odiseo_sylius_report.registry.data_fetcher')->willReturn($dataFetcherDefinition);
$container->hasDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->willReturn(true);
$container->getDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->willReturn($dataFetcherDefinition);

$dataFetcherServices = [
'odiseo_sylius_report.form.type.data_fetcher.test' => [
'odiseo_sylius_report_plugin.form.type.data_fetcher.test' => [
['fetcher' => 'test', 'label' => 'Test data fetcher'],
],
];
$container->findTaggedServiceIds('odiseo_sylius_report.data_fetcher')->willReturn($dataFetcherServices);
$container->findTaggedServiceIds('odiseo_sylius_report_plugin.data_fetcher')->willReturn($dataFetcherServices);

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

$this->process($container);
}

function it_does_not_process_if_container_has_not_proper_definition(ContainerBuilder $container)
{
$container->hasDefinition('odiseo_sylius_report.registry.data_fetcher')->willReturn(false);
$container->getDefinition('odiseo_sylius_report.registry.data_fetcher')->shouldNotBeCalled();
$container->hasDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->willReturn(false);
$container->getDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->shouldNotBeCalled();

$this->process($container);
}

function it_throws_exception_if_any_data_fetcher_has_improper_attributes(ContainerBuilder $container, Definition $dataFetcherDefinition)
{
$container->hasDefinition('odiseo_sylius_report.registry.data_fetcher')->willReturn(true);
$container->getDefinition('odiseo_sylius_report.registry.data_fetcher')->willReturn($dataFetcherDefinition);
$container->hasDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->willReturn(true);
$container->getDefinition('odiseo_sylius_report_plugin.registry.data_fetcher')->willReturn($dataFetcherDefinition);

$dataFetcherServices = [
'odiseo_sylius_report.form.type.data_fetcher.test' => [
'odiseo_sylius_report_plugin.form.type.data_fetcher.test' => [
['data_fetcher' => 'test'],
],
];
$container->findTaggedServiceIds('odiseo_sylius_report.data_fetcher')->willReturn($dataFetcherServices);
$dataFetcherDefinition->addMethodCall('register', ['test', new Reference('odiseo_sylius_report.form.type.data_fetcher.test')])->shouldNotBeCalled();
$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')])->shouldNotBeCalled();

$this->shouldThrow(new \InvalidArgumentException('Tagged report data fetchers needs to have `fetcher` and `label` attributes.'))
->during('process', [$container]);
Expand Down
28 changes: 15 additions & 13 deletions spec/DependencyInjection/Compiler/RegisterRenderersPassSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\DependencyInjection\Compiler;

use PhpSpec\ObjectBehavior;
Expand All @@ -21,42 +23,42 @@ function it_should_implement_compiler_pass_interface()

function it_processes_with_given_container(ContainerBuilder $container, Definition $rendererDefinition)
{
$container->hasDefinition('odiseo_sylius_report.registry.renderer')->willReturn(true);
$container->getDefinition('odiseo_sylius_report.registry.renderer')->willReturn($rendererDefinition);
$container->hasDefinition('odiseo_sylius_report_plugin.registry.renderer')->willReturn(true);
$container->getDefinition('odiseo_sylius_report_plugin.registry.renderer')->willReturn($rendererDefinition);

$rendererServices = [
'odiseo_sylius_report.form.type.renderer.test' => [
'odiseo_sylius_report_plugin.form.type.renderer.test' => [
['renderer' => 'test', 'label' => 'Test renderer'],
],
];
$container->findTaggedServiceIds('odiseo_sylius_report.renderer')->willReturn($rendererServices);
$container->findTaggedServiceIds('odiseo_sylius_report_plugin.renderer')->willReturn($rendererServices);

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

$this->process($container);
}

function it_does_not_process_if_container_has_not_proper_definition(ContainerBuilder $container)
{
$container->hasDefinition('odiseo_sylius_report.registry.renderer')->willReturn(false);
$container->getDefinition('odiseo_sylius_report.registry.renderer')->shouldNotBeCalled();
$container->hasDefinition('odiseo_sylius_report_plugin.registry.renderer')->willReturn(false);
$container->getDefinition('odiseo_sylius_report_plugin.registry.renderer')->shouldNotBeCalled();

$this->process($container);
}

function it_throws_exception_if_any_renderer_has_improper_attributes(ContainerBuilder $container, Definition $rendererDefinition)
{
$container->hasDefinition('odiseo_sylius_report.registry.renderer')->willReturn(true);
$container->getDefinition('odiseo_sylius_report.registry.renderer')->willReturn($rendererDefinition);
$container->hasDefinition('odiseo_sylius_report_plugin.registry.renderer')->willReturn(true);
$container->getDefinition('odiseo_sylius_report_plugin.registry.renderer')->willReturn($rendererDefinition);

$rendererServices = [
'odiseo_sylius_report.form.type.renderer.test' => [
'odiseo_sylius_report_plugin.form.type.renderer.test' => [
['renderer' => 'test'],
],
];
$container->findTaggedServiceIds('odiseo_sylius_report.renderer')->willReturn($rendererServices);
$rendererDefinition->addMethodCall('register', ['test', new Reference('odiseo_sylius_report.form.type.renderer.test')])->shouldNotBeCalled();
$container->findTaggedServiceIds('odiseo_sylius_report_plugin.renderer')->willReturn($rendererServices);
$rendererDefinition->addMethodCall('register', ['test', new Reference('odiseo_sylius_report_plugin.form.type.renderer.test')])->shouldNotBeCalled();

$this->shouldThrow(new \InvalidArgumentException('Tagged renderers needs to have `renderer` and `label` attributes.'))
->during('process', [$container]);
Expand Down
7 changes: 4 additions & 3 deletions spec/Model/ReportSpec.php → spec/Entity/ReportSpec.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?php

namespace spec\Odiseo\SyliusReportPlugin\Model;
declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Entity;

use Odiseo\SyliusReportPlugin\DataFetcher\DefaultDataFetchers;
use Odiseo\SyliusReportPlugin\Entity\Report;
use Odiseo\SyliusReportPlugin\Entity\ReportInterface;
use Odiseo\SyliusReportPlugin\Renderer\DefaultRenderers;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Resource\Model\CodeAwareInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\TimestampableInterface;

/**
* @author Diego D'amico <[email protected]>
*/
class ReportSpec extends ObjectBehavior
final class ReportSpec extends ObjectBehavior
{
function it_is_initializable()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\EventListener;

use Odiseo\SyliusReportPlugin\DataFetcher\DataFetcherInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\EventListener;

use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportRendererFormSubscriber;
Expand Down
4 changes: 3 additions & 1 deletion spec/Form/Type/DataFetcher/DataFetcherChoiceTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\DataFetcher;

use Odiseo\SyliusReportPlugin\Form\Type\DataFetcher\DataFetcherChoiceType;
Expand All @@ -8,7 +10,7 @@
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DataFetcherChoiceTypeSpec extends ObjectBehavior
final class DataFetcherChoiceTypeSpec extends ObjectBehavior
{
function let()
{
Expand Down
4 changes: 3 additions & 1 deletion spec/Form/Type/DataFetcher/NumberOfOrdersTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\DataFetcher;

use Odiseo\SyliusReportPlugin\Form\Builder\QueryFilterFormBuilderInterface;
Expand All @@ -12,7 +14,7 @@
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilder;

class NumberOfOrdersTypeSpec extends ObjectBehavior
final class NumberOfOrdersTypeSpec extends ObjectBehavior
{
function let(QueryFilterFormBuilderInterface $queryFilterFormBuilder)
{
Expand Down
4 changes: 3 additions & 1 deletion spec/Form/Type/DataFetcher/SalesTotalTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\DataFetcher;

use Odiseo\SyliusReportPlugin\Form\Builder\QueryFilterFormBuilderInterface;
Expand All @@ -12,7 +14,7 @@
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilder;

class SalesTotalTypeSpec extends ObjectBehavior
final class SalesTotalTypeSpec extends ObjectBehavior
{
function let(QueryFilterFormBuilderInterface $queryFilterFormBuilder)
{
Expand Down
4 changes: 3 additions & 1 deletion spec/Form/Type/DataFetcher/TimePeriodTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\DataFetcher;

use Odiseo\SyliusReportPlugin\Form\Type\DataFetcher\TimePeriodType;
Expand All @@ -11,7 +13,7 @@
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilder;

class TimePeriodTypeSpec extends ObjectBehavior
final class TimePeriodTypeSpec extends ObjectBehavior
{
function it_is_initializable()
{
Expand Down
4 changes: 3 additions & 1 deletion spec/Form/Type/DataFetcher/UserRegistrationTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\DataFetcher;

use Odiseo\SyliusReportPlugin\Form\Builder\QueryFilterFormBuilderInterface;
Expand All @@ -12,7 +14,7 @@
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilder;

class UserRegistrationTypeSpec extends ObjectBehavior
final class UserRegistrationTypeSpec extends ObjectBehavior
{
function let(QueryFilterFormBuilderInterface $queryFilterFormBuilder)
{
Expand Down
2 changes: 2 additions & 0 deletions spec/Form/Type/Renderer/ChartConfigurationTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\Renderer;

use PhpSpec\ObjectBehavior;
Expand Down
2 changes: 2 additions & 0 deletions spec/Form/Type/Renderer/RendererChoiceTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\Renderer;

use PhpSpec\ObjectBehavior;
Expand Down
2 changes: 2 additions & 0 deletions spec/Form/Type/Renderer/TableConfigurationTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type\Renderer;

use PhpSpec\ObjectBehavior;
Expand Down
8 changes: 5 additions & 3 deletions spec/Form/Type/ReportTypeSpec.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Form\Type;

use Odiseo\SyliusReportPlugin\DataFetcher\DataFetcherInterface;
use Odiseo\SyliusReportPlugin\Entity\Report;
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportDataFetcherFormSubscriber;
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportRendererFormSubscriber;
use Odiseo\SyliusReportPlugin\Form\Type\DataFetcher\DataFetcherChoiceType;
use Odiseo\SyliusReportPlugin\Form\Type\Renderer\RendererChoiceType;
use Odiseo\SyliusReportPlugin\Entity\Report;
use Odiseo\SyliusReportPlugin\Renderer\RendererInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportDataFetcherFormSubscriber;
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportRendererFormSubscriber;
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Sylius\Component\Registry\ServiceRegistryInterface;
Expand Down
3 changes: 2 additions & 1 deletion spec/Renderer/ChartRendererSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusReportPlugin\Renderer;

use Odiseo\SyliusReportPlugin\DataFetcher\Data;
Expand All @@ -8,7 +10,6 @@
use Odiseo\SyliusReportPlugin\Renderer\ChartRenderer;
use Odiseo\SyliusReportPlugin\Renderer\RendererInterface;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

/**
Expand Down
Loading

0 comments on commit 8e1e62a

Please sign in to comment.