GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 416677...d8aab5 )
by Andreas
03:56
created

ExportOmittedOrdersTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 14
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 21
rs 9.7998
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Test\Unit\Cron;
7
8
use CommerceLeague\ActiveCampaign\Cron\ExportOmittedOrders;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
11
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\Collection as OrderCollection;
12
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...Order\CollectionFactory 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...
13
use Magento\Framework\MessageQueue\PublisherInterface;
14
use PHPUnit\Framework\MockObject\MockObject;
15
use PHPUnit\Framework\TestCase;
16
17
class ExportOmittedOrdersTest extends TestCase
18
{
19
    /**
20
     * @var MockObject|ConfigHelper
21
     */
22
    protected $configHelper;
23
24
    /**
25
     * @var MockObject|OrderCollectionFactory
26
     */
27
    protected $orderCollectionFactory;
28
29
    /**
30
     * @var MockObject|OrderCollection
31
     */
32
    protected $orderCollection;
33
34
    /**
35
     * @var MockObject|PublisherInterface
36
     */
37
    protected $publisher;
38
39
    /**
40
     * @var ExportOmittedOrders
41
     */
42
    protected $exportOmittedOrders;
43
44
    protected function setUp()
45
    {
46
        $this->configHelper = $this->createMock(ConfigHelper::class);
47
48
        $this->orderCollectionFactory = $this->getMockBuilder(OrderCollectionFactory::class)
49
            ->disableOriginalConstructor()
50
            ->setMethods(['create'])
51
            ->getMock();
52
53
        $this->orderCollection = $this->createMock(OrderCollection::class);
54
55
        $this->orderCollectionFactory->expects($this->any())
56
            ->method('create')
57
            ->willReturn($this->orderCollection);
58
59
        $this->publisher = $this->createMock(PublisherInterface::class);
60
61
        $this->exportOmittedOrders = new ExportOmittedOrders(
62
            $this->configHelper,
63
            $this->orderCollectionFactory,
64
            $this->publisher
65
        );
66
    }
67
68
    public function testExecuteDisabled()
69
    {
70
        $this->configHelper->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCampaign\Helper\Config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        $this->configHelper->/** @scrutinizer ignore-call */ 
71
                             expects($this->once())

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...
71
            ->method('isEnabled')
72
            ->willReturn(false);
73
74
        $this->orderCollection->expects($this->never())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCam...eModel\Order\Collection. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
        $this->orderCollection->/** @scrutinizer ignore-call */ 
75
                                expects($this->never())

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...
75
            ->method('addExcludeGuestFilter');
76
77
        $this->exportOmittedOrders->run();
78
    }
79
80
    public function testExecuteOrderExportDisabled()
81
    {
82
        $this->configHelper->expects($this->once())
83
            ->method('isEnabled')
84
            ->willReturn(true);
85
86
        $this->configHelper->expects($this->once())
87
            ->method('isOrderExportEnabled')
88
            ->willReturn(false);
89
90
        $this->orderCollection->expects($this->never())
91
            ->method('addExcludeGuestFilter');
92
93
        $this->exportOmittedOrders->run();
94
    }
95
96
    public function testRun()
97
    {
98
        $orderIds = [123, 456];
99
100
        $this->configHelper->expects($this->once())
101
            ->method('isEnabled')
102
            ->willReturn(true);
103
104
        $this->configHelper->expects($this->once())
105
            ->method('isOrderExportEnabled')
106
            ->willReturn(true);
107
108
        $this->orderCollection->expects($this->once())
109
            ->method('addExcludeGuestFilter')
110
            ->willReturnSelf();
111
112
        $this->orderCollection->expects($this->once())
113
            ->method('addOmittedFilter')
114
            ->willReturnSelf();
115
116
        $this->orderCollection->expects($this->once())
117
            ->method('getAllIds')
118
            ->willReturn($orderIds);
119
120
        $this->publisher->expects($this->exactly(2))
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Magento\Framework\MessageQueue\PublisherInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

120
        $this->publisher->/** @scrutinizer ignore-call */ 
121
                          expects($this->exactly(2))

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...
121
            ->method('publish');
122
123
        $this->publisher->expects($this->at(0))
124
            ->method('publish')
125
            ->with(
126
                Topics::SALES_ORDER_EXPORT,
127
                json_encode(['magento_order_id' => $orderIds[0]])
128
            );
129
130
        $this->publisher->expects($this->at(1))
131
            ->method('publish')
132
            ->with(
133
                Topics::SALES_ORDER_EXPORT,
134
                json_encode(['magento_order_id' => $orderIds[1]])
135
            );
136
137
        $this->exportOmittedOrders->run();
138
    }
139
}
140