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.

ExportOmittedAbandonedCartsTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 64
c 1
b 0
f 1
dl 0
loc 121
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testRun() 0 42 1
A testExecuteDisabled() 0 10 1
A testExecuteAbandonedCartExportDisabled() 0 14 1
A setUp() 0 21 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Test\Unit\Cron;
7
8
use CommerceLeague\ActiveCampaign\Cron\ExportOmittedAbandonedCarts;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
11
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote\Collection as QuoteCollection;
12
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...Quote\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 ExportOmittedAbandonedCartsTest extends TestCase
18
{
19
    /**
20
     * @var MockObject|ConfigHelper
21
     */
22
    protected $configHelper;
23
24
    /**
25
     * @var MockObject|QuoteCollectionFactory
26
     */
27
    protected $quoteCollectionFactory;
28
29
    /**
30
     * @var MockObject|QuoteCollection
31
     */
32
    protected $quoteCollection;
33
34
    /**
35
     * @var MockObject|PublisherInterface
36
     */
37
    protected $publisher;
38
39
    /**
40
     * @var ExportOmittedAbandonedCarts
41
     */
42
    protected $exportOmittedAbandonedCarts;
43
44
    protected function setUp()
45
    {
46
        $this->configHelper = $this->createMock(ConfigHelper::class);
47
48
        $this->quoteCollectionFactory = $this->getMockBuilder(QuoteCollectionFactory::class)
49
            ->disableOriginalConstructor()
50
            ->setMethods(['create'])
51
            ->getMock();
52
53
        $this->quoteCollection = $this->createMock(QuoteCollection::class);
54
55
        $this->quoteCollectionFactory->expects($this->any())
56
            ->method('create')
57
            ->willReturn($this->quoteCollection);
58
59
        $this->publisher = $this->createMock(PublisherInterface::class);
60
61
        $this->exportOmittedAbandonedCarts = new ExportOmittedAbandonedCarts(
62
            $this->configHelper,
63
            $this->quoteCollectionFactory,
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->quoteCollection->expects($this->never())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCam...eModel\Quote\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->quoteCollection->/** @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('addAbandonedFilter');
76
77
        $this->exportOmittedAbandonedCarts->run();
78
    }
79
80
    public function testExecuteAbandonedCartExportDisabled()
81
    {
82
        $this->configHelper->expects($this->once())
83
            ->method('isEnabled')
84
            ->willReturn(true);
85
86
        $this->configHelper->expects($this->once())
87
            ->method('isAbandonedCartExportEnabled')
88
            ->willReturn(false);
89
90
        $this->quoteCollection->expects($this->never())
91
            ->method('addAbandonedFilter');
92
93
        $this->exportOmittedAbandonedCarts->run();
94
    }
95
96
    public function testRun()
97
    {
98
        $quoteIds = [123, 456];
99
100
        $this->configHelper->expects($this->once())
101
            ->method('isEnabled')
102
            ->willReturn(true);
103
104
        $this->configHelper->expects($this->once())
105
            ->method('isAbandonedCartExportEnabled')
106
            ->willReturn(true);
107
108
        $this->quoteCollection->expects($this->once())
109
            ->method('addAbandonedFilter')
110
            ->willReturnSelf();
111
112
        $this->quoteCollection->expects($this->once())
113
            ->method('addOmittedFilter')
114
            ->willReturnSelf();
115
116
        $this->quoteCollection->expects($this->once())
117
            ->method('getAllIds')
118
            ->willReturn($quoteIds);
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::QUOTE_ABANDONED_CART_EXPORT,
127
                json_encode(['quote_id' => $quoteIds[0]])
128
            );
129
130
        $this->publisher->expects($this->at(1))
131
            ->method('publish')
132
            ->with(
133
                Topics::QUOTE_ABANDONED_CART_EXPORT,
134
                json_encode(['quote_id' => $quoteIds[1]])
135
            );
136
137
        $this->exportOmittedAbandonedCarts->run();
138
    }
139
}
140