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 ( f845d1...f19061 )
by Andreas
04:47
created

CustomerBuilderTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Test\Unit\Gateway\Request;
7
8
use CommerceLeague\ActiveCampaign\Gateway\Request\CustomerBuilder;
9
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
10
use Magento\Customer\Api\Data\CustomerInterface as MagentoCustomerInterface;
11
use Magento\Framework\Api\ExtensionAttributesInterface;
12
use PHPUnit\Framework\MockObject\MockObject;
13
use PHPUnit\Framework\TestCase;
14
15
class CustomerBuilderTest extends TestCase
16
{
17
    /**
18
     * @var MockObject|ConfigHelper
19
     */
20
    protected $configHelper;
21
22
    /**
23
     * @var MockObject|MagentoCustomerInterface
24
     */
25
    protected $magentoCustomer;
26
27
    /**
28
     * @var MockObject|ExtensionAttributesInterface
29
     */
30
    protected $extensionAttributes;
31
32
    /**
33
     * @var CustomerBuilder
34
     */
35
    protected $customerBuilder;
36
37
    protected function setUp()
38
    {
39
        $this->configHelper = $this->createMock(ConfigHelper::class);
40
        $this->magentoCustomer = $this->createMock(MagentoCustomerInterface::class);
41
        $this->extensionAttributes = $this->getMockBuilder(ExtensionAttributesInterface::class)
42
            ->setMethods(['getIsSubscribed'])
43
            ->getMockForAbstractClass();
44
45
        $this->customerBuilder = new CustomerBuilder(
46
            $this->configHelper
47
        );
48
    }
49
50
    public function testBuildUnsubscribed()
51
    {
52
        $connectionId = 123;
53
        $magentoCustomerId = 456;
54
        $email = '[email protected]';
55
56
        $this->magentoCustomer->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Magento\Customer\Api\Data\CustomerInterface. ( Ignorable by Annotation )

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

56
        $this->magentoCustomer->/** @scrutinizer ignore-call */ 
57
                                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...
57
            ->method('getExtensionAttributes')
58
            ->willReturn($this->extensionAttributes);
59
60
        $this->extensionAttributes->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Magento\Framework\Api\ExtensionAttributesInterface. It seems like you code against a sub-type of Magento\Framework\Api\ExtensionAttributesInterface such as Magento\Ui\Model\Bookmark. ( Ignorable by Annotation )

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

60
        $this->extensionAttributes->/** @scrutinizer ignore-call */ 
61
                                    expects($this->once())
Loading history...
61
            ->method('getIsSubscribed')
62
            ->willReturn(false);
63
64
        $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

64
        $this->configHelper->/** @scrutinizer ignore-call */ 
65
                             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...
65
            ->method('getConnectionId')
66
            ->willReturn($connectionId);
67
68
        $this->magentoCustomer->expects($this->once())
69
            ->method('getId')
70
            ->willReturn($magentoCustomerId);
71
72
        $this->magentoCustomer->expects($this->once())
73
            ->method('getEmail')
74
            ->willReturn($email);
75
76
        $expected = [
77
            'connectionid' => $connectionId,
78
            'externalid' => $magentoCustomerId,
79
            'email' => $email,
80
            'acceptsMarketing' => 0
81
        ];
82
83
        $this->assertEquals(
84
            $expected,
85
            $this->customerBuilder->build($this->magentoCustomer)
86
        );
87
    }
88
89
    public function testBuildSubscribed()
90
    {
91
        $connectionId = 123;
92
        $magentoCustomerId = 456;
93
        $email = '[email protected]';
94
95
        $this->magentoCustomer->expects($this->once())
96
            ->method('getExtensionAttributes')
97
            ->willReturn($this->extensionAttributes);
98
99
        $this->extensionAttributes->expects($this->once())
100
            ->method('getIsSubscribed')
101
            ->willReturn(true);
102
103
        $this->configHelper->expects($this->once())
104
            ->method('getConnectionId')
105
            ->willReturn($connectionId);
106
107
        $this->magentoCustomer->expects($this->once())
108
            ->method('getId')
109
            ->willReturn($magentoCustomerId);
110
111
        $this->magentoCustomer->expects($this->once())
112
            ->method('getEmail')
113
            ->willReturn($email);
114
115
        $expected = [
116
            'connectionid' => $connectionId,
117
            'externalid' => $magentoCustomerId,
118
            'email' => $email,
119
            'acceptsMarketing' => 1
120
        ];
121
122
        $this->assertEquals(
123
            $expected,
124
            $this->customerBuilder->build($this->magentoCustomer)
125
        );
126
    }
127
128
129
}
130