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

ExportOmittedCustomersTest::testRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 26
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 38
rs 9.504
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Test\Unit\Cron;
7
8
use CommerceLeague\ActiveCampaign\Cron\ExportOmittedCustomers;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
11
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\Collection as CustomerCollection;
12
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...tomer\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 ExportOmittedCustomersTest extends TestCase
18
{
19
    /**
20
     * @var MockObject|ConfigHelper
21
     */
22
    protected $configHelper;
23
24
    /**
25
     * @var MockObject|CustomerCollectionFactory
26
     */
27
    protected $customerCollectionFactory;
28
29
    /**
30
     * @var MockObject|CustomerCollection
31
     */
32
    protected $customerCollection;
33
34
    /**
35
     * @var MockObject|PublisherInterface
36
     */
37
    protected $publisher;
38
39
    /**
40
     * @var ExportOmittedCustomers
41
     */
42
    protected $exportOmittedCustomers;
43
44
    protected function setUp()
45
    {
46
        $this->configHelper = $this->createMock(ConfigHelper::class);
47
48
        $this->customerCollectionFactory = $this->getMockBuilder(CustomerCollectionFactory::class)
49
            ->disableOriginalConstructor()
50
            ->setMethods(['create'])
51
            ->getMock();
52
53
        $this->customerCollection = $this->createMock(CustomerCollection::class);
54
55
        $this->customerCollectionFactory->expects($this->any())
56
            ->method('create')
57
            ->willReturn($this->customerCollection);
58
59
        $this->publisher = $this->createMock(PublisherInterface::class);
60
61
        $this->exportOmittedCustomers = new ExportOmittedCustomers(
62
            $this->configHelper,
63
            $this->customerCollectionFactory,
64
            $this->publisher
65
        );
66
    }
67
68
    public function testRunDisabled()
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->customerCollection->expects($this->never())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCam...del\Customer\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->customerCollection->/** @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('addCustomerOmittedFilter');
76
77
        $this->exportOmittedCustomers->run();
78
    }
79
80
    public function testRunContactExportDisabled()
81
    {
82
        $this->configHelper->expects($this->once())
83
            ->method('isEnabled')
84
            ->willReturn(true);
85
86
        $this->configHelper->expects($this->once())
87
            ->method('isCustomerExportEnabled')
88
            ->willReturn(false);
89
90
        $this->customerCollection->expects($this->never())
91
            ->method('addCustomerOmittedFilter');
92
93
        $this->exportOmittedCustomers->run();
94
    }
95
96
    public function testRun()
97
    {
98
        $customerIds = [123, 456];
99
100
        $this->configHelper->expects($this->once())
101
            ->method('isEnabled')
102
            ->willReturn(true);
103
104
        $this->configHelper->expects($this->once())
105
            ->method('isCustomerExportEnabled')
106
            ->willReturn(true);
107
108
        $this->customerCollection->expects($this->once())
109
            ->method('addCustomerOmittedFilter')
110
            ->willReturnSelf();
111
112
        $this->customerCollection->expects($this->once())
113
            ->method('getAllIds')
114
            ->willReturn($customerIds);
115
116
        $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

116
        $this->publisher->/** @scrutinizer ignore-call */ 
117
                          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...
117
            ->method('publish');
118
119
        $this->publisher->expects($this->at(0))
120
            ->method('publish')
121
            ->with(
122
                Topics::CUSTOMER_CUSTOMER_EXPORT,
123
                json_encode(['magento_customer_id' => $customerIds[0]])
124
            );
125
126
        $this->publisher->expects($this->at(1))
127
            ->method('publish')
128
            ->with(
129
                Topics::CUSTOMER_CUSTOMER_EXPORT,
130
                json_encode(['magento_customer_id' => $customerIds[1]])
131
            );
132
133
        $this->exportOmittedCustomers->run();
134
    }
135
}
136