odiseoteam /
SyliusReportPlugin
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace spec\Odiseo\SyliusReportPlugin\DataFetcher; |
||||||
| 4 | |||||||
| 5 | use Odiseo\SyliusReportPlugin\DataFetcher\Data; |
||||||
| 6 | use Odiseo\SyliusReportPlugin\DataFetcher\DataFetcherInterface; |
||||||
| 7 | use Odiseo\SyliusReportPlugin\DataFetcher\DefaultDataFetchers; |
||||||
| 8 | use Odiseo\SyliusReportPlugin\DataFetcher\DelegatingDataFetcher; |
||||||
| 9 | use Odiseo\SyliusReportPlugin\DataFetcher\DelegatingDataFetcherInterface; |
||||||
| 10 | use Odiseo\SyliusReportPlugin\DataFetcher\UserRegistrationDataFetcher; |
||||||
| 11 | use Odiseo\SyliusReportPlugin\Model\ReportInterface; |
||||||
| 12 | use PhpSpec\ObjectBehavior; |
||||||
| 13 | use Sylius\Component\Registry\ServiceRegistryInterface; |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * @author Diego D'amico <[email protected]> |
||||||
| 17 | */ |
||||||
| 18 | class DelegatingDataFetcherSpec extends ObjectBehavior |
||||||
| 19 | { |
||||||
| 20 | function let(ServiceRegistryInterface $registry) |
||||||
|
0 ignored issues
–
show
|
|||||||
| 21 | { |
||||||
| 22 | $this->beConstructedWith($registry); |
||||||
| 23 | } |
||||||
| 24 | |||||||
| 25 | function it_is_initializable() |
||||||
|
0 ignored issues
–
show
|
|||||||
| 26 | { |
||||||
| 27 | $this->shouldHaveType(DelegatingDataFetcher::class); |
||||||
| 28 | } |
||||||
| 29 | |||||||
| 30 | function it_should_implement_delegating_data_fetcher_interface() |
||||||
| 31 | { |
||||||
| 32 | $this->shouldImplement(DelegatingDataFetcherInterface::class); |
||||||
| 33 | } |
||||||
| 34 | |||||||
| 35 | function it_get_the_data_fetcher_with_given_report(ReportInterface $report, ServiceRegistryInterface $registry, UserRegistrationDataFetcher $userRegistrationDataFetcher) |
||||||
| 36 | { |
||||||
| 37 | $report->getDataFetcher()->willReturn(DefaultDataFetchers::USER_REGISTRATION); |
||||||
| 38 | $registry->get(DefaultDataFetchers::USER_REGISTRATION)->willReturn($userRegistrationDataFetcher); |
||||||
| 39 | $this->getDataFetcher($report)->shouldReturn($userRegistrationDataFetcher); |
||||||
|
0 ignored issues
–
show
The method
getDataFetcher() does not exist on spec\Odiseo\SyliusReport...legatingDataFetcherSpec. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | function it_fetch_the_data_with_given_report_configuration(ReportInterface $report, DataFetcherInterface $dataFetcher, ServiceRegistryInterface $registry) |
||||||
| 43 | { |
||||||
| 44 | $reportConfiguration = [ |
||||||
| 45 | 'start' => new \DateTime('1918-01-01 00:00:00.000000'), |
||||||
| 46 | 'end' => new \DateTime(), |
||||||
| 47 | 'period' => 'month', |
||||||
| 48 | 'empty_records' => false |
||||||
| 49 | ]; |
||||||
| 50 | $otherConfiguration = [ |
||||||
| 51 | ]; |
||||||
| 52 | $data = new Data(); |
||||||
| 53 | |||||||
| 54 | $report->getDataFetcher()->willReturn(DefaultDataFetchers::USER_REGISTRATION); |
||||||
| 55 | $registry->get(DefaultDataFetchers::USER_REGISTRATION)->willReturn($dataFetcher); |
||||||
| 56 | $report->getDataFetcherConfiguration()->willReturn($reportConfiguration); |
||||||
| 57 | $dataFetcher->fetch($reportConfiguration)->willReturn($data); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on Odiseo\SyliusReportPlugin\DataFetcher\Data.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 58 | |||||||
| 59 | $this->fetch($report, $otherConfiguration)->shouldReturn($data); |
||||||
|
0 ignored issues
–
show
The method
fetch() does not exist on spec\Odiseo\SyliusReport...legatingDataFetcherSpec. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 60 | } |
||||||
| 61 | |||||||
| 62 | function it_fetch_the_data_with_given_parameter_configuration(ReportInterface $report, DataFetcherInterface $dataFetcher, ServiceRegistryInterface $registry) |
||||||
| 63 | { |
||||||
| 64 | $reportConfiguration = [ |
||||||
| 65 | 'start' => new \DateTime('1918-01-01 00:00:00.000000'), |
||||||
| 66 | 'end' => new \DateTime(), |
||||||
| 67 | 'period' => 'month', |
||||||
| 68 | 'empty_records' => false |
||||||
| 69 | ]; |
||||||
| 70 | $otherConfiguration = [ |
||||||
| 71 | 'otherConfiguration' => 'test' |
||||||
| 72 | ]; |
||||||
| 73 | $data = new Data(); |
||||||
| 74 | |||||||
| 75 | $report->getDataFetcher()->willReturn(DefaultDataFetchers::USER_REGISTRATION); |
||||||
| 76 | $registry->get(DefaultDataFetchers::USER_REGISTRATION)->willReturn($dataFetcher); |
||||||
| 77 | $report->getDataFetcherConfiguration()->willReturn($reportConfiguration); |
||||||
| 78 | $dataFetcher->fetch($otherConfiguration)->willReturn($data); |
||||||
| 79 | |||||||
| 80 | $this->fetch($report, $otherConfiguration)->shouldReturn($data); |
||||||
| 81 | } |
||||||
| 82 | } |
||||||
| 83 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.