Test Failed
Push — master ( 8ed5a4...5d2c20 )
by Patrick
03:21
created

ForecastDataImportFacadeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 37
c 1
b 0
f 1
dl 0
loc 60
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanStartTheImportProcess() 0 4 1
A createForecastDataImportFacade() 0 52 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\ActivityFactory;
16
use ForecastAutomation\Activity\Shared\Dto\ActivityDto;
17
use ForecastAutomation\Activity\Shared\Dto\ActivityDtoCollection;
18
use ForecastAutomation\Activity\Shared\Plugin\ActivityPluginCollection;
19
use ForecastAutomation\Activity\Shared\Plugin\ActivityPluginInterface;
20
use ForecastAutomation\ForecastClient\ForecastClientFacade;
21
use ForecastAutomation\ForecastDataImport\Business\Writer\ForecastActivityWriter;
22
use ForecastAutomation\ForecastDataImport\ForecastDataImportFacade;
23
use ForecastAutomation\ForecastDataImport\ForecastDataImportFactory;
24
use PHPUnit\Framework\TestCase;
25
26
/**
27
 * @internal
28
 * @covers
29
 */
30
final class ForecastDataImportFacadeTest extends TestCase
31
{
32
    public function testCanStartTheImportProcess(): void
33
    {
34
        $writtenActivities = $this->createForecastDataImportFacade()->startImportProcess();
35
        static::assertSame(1,$writtenActivities);
36
    }
37
38
    private function createForecastDataImportFacade(): ForecastDataImportFacade
39
    {
40
        $activityFacadeMock = $this->getMockBuilder(ActivityFacade::class)
41
            ->onlyMethods(['collect'])
42
            ->getMock()
43
        ;
44
        $activityFacadeMock
45
            ->method('collect')
46
            ->willReturn(
47
                new ActivityDtoCollection(
48
                    new ActivityDto(
49
                        self::TEST_NEEDLE_1,
0 ignored issues
show
Bug introduced by
The constant ForecastAutomationTests\...cadeTest::TEST_NEEDLE_1 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
                        self::TEST_DESCRIPTION,
0 ignored issues
show
Bug introduced by
The constant ForecastAutomationTests\...eTest::TEST_DESCRIPTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
51
                        new \DateTime(self::TEST_CREATED),
0 ignored issues
show
Bug introduced by
The constant ForecastAutomationTests\...acadeTest::TEST_CREATED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
52
                        self::TEST_DURATION
0 ignored issues
show
Bug introduced by
The constant ForecastAutomationTests\...cadeTest::TEST_DURATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
53
                    )
54
                )
55
            )
56
        ;
57
58
        $forecastClientFacadeMock = $this->getMockBuilder(ForecastClientFacade::class)
59
            ->onlyMethods(['writeActivities'])
60
            ->getMock();
61
62
        $forecastClientFacadeMock
63
            ->method('writeActivities')
64
            ->willReturn(1);
65
66
67
        $forecastDataImportFactoryMock = $this->getMockBuilder(ForecastDataImportFactory::class)
68
            ->onlyMethods(['getActivityFacade','getForecastClientFacade'])
69
            ->getMock()
70
        ;
71
        $forecastDataImportFactoryMock
72
            ->method('getActivityFacade')
73
            ->willReturn($activityFacadeMock)
74
        ;
75
        $forecastDataImportFactoryMock
76
            ->method('getForecastClientFacade')
77
            ->willReturn($forecastClientFacadeMock)
78
        ;
79
80
        $forecastDataImportFacadeMock = $this->getMockBuilder(ForecastDataImportFacade::class)
81
            ->onlyMethods(['getFactory'])
82
            ->getMock()
83
        ;
84
        $forecastDataImportFacadeMock
85
            ->method('getFactory')
86
            ->willReturn($forecastDataImportFactoryMock)
87
        ;
88
89
        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...
90
    }
91
}
92