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.
Passed
Push — master ( 3bfcba...f91474 )
by Andreas
04:15
created

CreateUpdateMessageBuilderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 74
c 1
b 0
f 0
dl 0
loc 131
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testBuildWithSubscriber() 0 32 1
A setUp() 0 14 1
A testBuildWithCustomer() 0 47 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Test\Unit\MessageQueue\Contact;
7
8
use CommerceLeague\ActiveCampaign\Api\Data\ContactInterface;
9
use CommerceLeague\ActiveCampaign\MessageQueue\Contact\CreateUpdateMessage;
10
use CommerceLeague\ActiveCampaign\MessageQueue\Contact\CreateUpdateMessageBuilder;
11
use CommerceLeague\ActiveCampaign\MessageQueue\Contact\CreateUpdateMessageFactory;
0 ignored issues
show
Bug introduced by
The type CommerceLeague\ActiveCam...ateUpdateMessageFactory 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...
12
use Magento\Customer\Model\Customer;
13
use Magento\Newsletter\Model\Subscriber;
14
use PHPUnit\Framework\MockObject\MockObject;
15
use PHPUnit\Framework\TestCase;
16
17
class CreateUpdateMessageBuilderTest extends TestCase
18
{
19
    /**
20
     * @var MockObject|CreateUpdateMessageFactory
21
     */
22
    protected $createUpdateMessageFactory;
23
24
    /**
25
     * @var MockObject|CreateUpdateMessage
26
     */
27
    protected $createUpdateMessage;
28
29
    /**
30
     * @var MockObject|ContactInterface
31
     */
32
    protected $contact;
33
34
    /**
35
     * @var MockObject|Customer
36
     */
37
    protected $customer;
38
39
    /**
40
     * @var MockObject|Subscriber
41
     */
42
    protected $subscriber;
43
44
    /**
45
     * @var CreateUpdateMessageBuilder
46
     */
47
    protected $createUpdateMessageBuilder;
48
49
    protected function setUp()
50
    {
51
        $this->createUpdateMessageFactory = $this->getMockBuilder(CreateUpdateMessageFactory::class)
52
            ->setMethods(['create'])
53
            ->disableOriginalConstructor()
54
            ->getMock();
55
56
        $this->createUpdateMessage = $this->createMock(CreateUpdateMessage::class);
57
        $this->contact = $this->createMock(ContactInterface::class);
58
        $this->customer = $this->createMock(Customer::class);
59
        $this->subscriber = $this->createMock(Subscriber::class);
60
61
        $this->createUpdateMessageBuilder = new CreateUpdateMessageBuilder(
62
            $this->createUpdateMessageFactory
63
        );
64
    }
65
66
    public function testBuildWithCustomer()
67
    {
68
        $email = '[email protected]';
69
        $firstName = 'firstName';
70
        $lastName = 'lastName';
71
72
        $this->customer->expects($this->at(0))
73
            ->method('getData')
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

73
            ->/** @scrutinizer ignore-call */ method('getData')

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...
74
            ->with('email')
0 ignored issues
show
Bug introduced by
The method with() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

74
            ->/** @scrutinizer ignore-call */ with('email')

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
            ->willReturn($email);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

75
            ->/** @scrutinizer ignore-call */ willReturn($email);

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...
76
77
        $this->customer->expects($this->at(1))
78
            ->method('getData')
79
            ->with('firstname')
80
            ->willReturn($firstName);
81
82
        $this->customer->expects($this->at(2))
83
            ->method('getData')
84
            ->with('lastname')
85
            ->willReturn($lastName);
86
87
        $this->createUpdateMessageFactory->expects($this->once())
88
            ->method('create')
89
            ->willReturn($this->createUpdateMessage);
90
91
        $this->contact->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCam...i\Data\ContactInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to CommerceLeague\ActiveCam...i\Data\ContactInterface. ( Ignorable by Annotation )

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

91
        $this->contact->/** @scrutinizer ignore-call */ 
92
                        expects($this->once())
Loading history...
92
            ->method('getId')
93
            ->willReturn('123');
94
95
        $this->createUpdateMessage->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on CommerceLeague\ActiveCam...act\CreateUpdateMessage. ( Ignorable by Annotation )

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

95
        $this->createUpdateMessage->/** @scrutinizer ignore-call */ 
96
                                    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...
96
            ->method('setContactId')
97
            ->with(123)
98
            ->willReturnSelf();
99
100
        $request = [
101
            'email' => $email,
102
            'firstName' => $firstName,
103
            'lastName' => $lastName
104
        ];
105
106
        $this->createUpdateMessage->expects($this->once())
107
            ->method('setSerializedRequest')
108
            ->with(json_encode($request));
109
110
        $this->assertSame(
111
            $this->createUpdateMessage,
112
            $this->createUpdateMessageBuilder->buildWithCustomer($this->contact, $this->customer)
113
        );
114
    }
115
116
    public function testBuildWithSubscriber()
117
    {
118
        $email = '[email protected]';
119
120
        $this->createUpdateMessageFactory->expects($this->once())
121
            ->method('create')
122
            ->willReturn($this->createUpdateMessage);
123
124
        $this->subscriber->expects($this->at(0))
125
            ->method('getEmail')
126
            ->willReturn($email);
127
128
        $this->contact->expects($this->once())
129
            ->method('getId')
130
            ->willReturn('123');
131
132
        $this->createUpdateMessage->expects($this->once())
133
            ->method('setContactId')
134
            ->with(123)
135
            ->willReturnSelf();
136
137
        $request = [
138
            'email' => $email
139
        ];
140
141
        $this->createUpdateMessage->expects($this->once())
142
            ->method('setSerializedRequest')
143
            ->with(json_encode($request));
144
145
        $this->assertSame(
146
            $this->createUpdateMessage,
147
            $this->createUpdateMessageBuilder->buildWithSubscriber($this->contact, $this->subscriber)
148
        );
149
    }
150
}
151