testCanStartTheImportProcess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 2
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomationTests\ForecastDataImport;
13
14
use ForecastAutomation\Activity\ActivityFacade;
15
use ForecastAutomation\Activity\Shared\Dto\ActivityDto;
16
use ForecastAutomation\Activity\Shared\Dto\ActivityDtoCollection;
17
use ForecastAutomation\ForecastDataImport\ForecastDataImportFacade;
0 ignored issues
show
Bug introduced by
The type ForecastAutomation\Forec...orecastDataImportFacade was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use ForecastAutomation\ForecastDataImport\ForecastDataImportFactory;
0 ignored issues
show
Bug introduced by
The type ForecastAutomation\Forec...recastDataImportFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use ForecastAutomation\QueueClient\QueueClientFacade;
20
use PHPUnit\Framework\TestCase;
21
22
/**
23
 * @internal
24
 * @covers
25
 */
26
final class ForecastDataImportFacadeTest extends TestCase
27
{
28
    public function testCanStartTheImportProcess(): void
29
    {
30
        $writtenActivities = $this->createForecastDataImportFacade()->startImportProcess();
31
        static::assertSame(1, $writtenActivities);
32
    }
33
34
    private function createForecastDataImportFacade(): ForecastDataImportFacade
35
    {
36
        $activityFacadeMock = $this->getMockBuilder(ActivityFacade::class)
37
            ->onlyMethods(['collect'])
38
            ->getMock()
39
        ;
40
        $activityFacadeMock
41
            ->method('collect')
42
            ->willReturn(
43
                new ActivityDtoCollection(
44
                    new ActivityDto('test-needle', 'test-description', new \DateTime(), 100)
45
                )
46
            )
47
        ;
48
49
        $forecastClientFacadeMock = $this->getMockBuilder(QueueClientFacade::class)
50
            ->getMock()
51
        ;
52
53
        $forecastDataImportFactoryMock = $this->getMockBuilder(ForecastDataImportFactory::class)
54
            ->onlyMethods(['getActivityFacade', 'getQueueClientFacade'])
55
            ->getMock()
56
        ;
57
        $forecastDataImportFactoryMock
58
            ->method('getActivityFacade')
59
            ->willReturn($activityFacadeMock)
60
        ;
61
        $forecastDataImportFactoryMock
62
            ->method('getQueueClientFacade')
63
            ->willReturn($forecastClientFacadeMock)
64
        ;
65
66
        $forecastDataImportFacadeMock = $this->getMockBuilder(ForecastDataImportFacade::class)
67
            ->onlyMethods(['getFactory'])
68
            ->getMock()
69
        ;
70
        $forecastDataImportFacadeMock
71
            ->method('getFactory')
72
            ->willReturn($forecastDataImportFactoryMock)
73
        ;
74
75
        return $forecastDataImportFacadeMock;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $forecastDataImportFacadeMock returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return ForecastAutomation\Forec...orecastDataImportFacade.
Loading history...
76
    }
77
}
78