DomainManagerTest::testDeleteThrowException()   C
last analyzed

Complexity

Conditions 10
Paths 3

Size

Total Lines 81
Code Lines 60

Duplication

Lines 81
Ratio 100 %

Importance

Changes 0
Metric Value
dl 81
loc 81
rs 5.5056
c 0
b 0
f 0
cc 10
eloc 60
nc 3
nop 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Resource\Tests\Domain;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use Lug\Component\Resource\Domain\DomainEvent;
16
use Lug\Component\Resource\Domain\DomainManager;
17
use Lug\Component\Resource\Domain\DomainManagerInterface;
18
use Lug\Component\Resource\Exception\DomainException;
19
use Lug\Component\Resource\Model\ResourceInterface;
20
use Lug\Component\Resource\Repository\RepositoryInterface;
21
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
22
use Symfony\Component\HttpFoundation\Response;
23
24
/**
25
 * @author GeLo <[email protected]>
26
 */
27
class DomainManagerTest extends \PHPUnit_Framework_TestCase
28
{
29
    /**
30
     * @var DomainManager
31
     */
32
    private $domainManager;
33
34
    /**
35
     * @var \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
36
     */
37
    private $resource;
38
39
    /**
40
     * @var \PHPUnit_Framework_MockObject_MockObject|EventDispatcherInterface
41
     */
42
    private $eventDispatcher;
43
44
    /**
45
     * @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager
46
     */
47
    private $objectManager;
48
49
    /**
50
     * @var \PHPUnit_Framework_MockObject_MockObject|RepositoryInterface
51
     */
52
    private $repository;
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    protected function setUp()
58
    {
59
        $this->resource = $this->createResourceMock();
60
        $this->eventDispatcher = $this->createEventDispatcherMock();
61
        $this->objectManager = $this->createObjectManagerMock();
62
        $this->repository = $this->createRepositoryMock();
63
64
        $this->domainManager = new DomainManager(
65
            $this->resource,
66
            $this->eventDispatcher,
67
            $this->objectManager,
68
            $this->repository
69
        );
70
    }
71
72
    public function testInheritance()
73
    {
74
        $this->assertInstanceOf(DomainManagerInterface::class, $this->domainManager);
75
    }
76
77
    public function testFind()
78
    {
79
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
80
            ->expects($this->exactly(2))
81
            ->method('getName')
82
            ->will($this->returnValue($name = 'name'));
83
84
        $this->repository
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\R...ory\RepositoryInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
85
            ->expects($this->once())
86
            ->method($repositoryMethod = 'findForShow')
87
            ->with(
88
                $this->identicalTo($criteria = ['criteria']),
89
                $this->identicalTo($sorting = ['sorting'])
90
            )
91
            ->will($this->returnValue($data = new \stdClass()));
92
93
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
94
            ->expects($this->at(0))
95
            ->method('dispatch')
96
            ->with(
97
                $this->identicalTo('lug.'.$name.'.pre_find.'.($action = 'action')),
98
                $this->callback(function (DomainEvent $event) use ($action) {
99
                    return $event->getResource() === $this->resource
100
                        && $event->getData() === null
101
                        && $event->getAction() === 'find.'.$action;
102
                })
103
            );
104
105
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
106
            ->expects($this->at(1))
107
            ->method('dispatch')
108
            ->with(
109
                $this->identicalTo('lug.'.$name.'.post_find.'.$action),
110
                $this->callback(function (DomainEvent $event) use ($data, $action) {
111
                    return $event->getResource() === $this->resource
112
                    && $event->getData() === $data
113
                    && $event->getAction() === 'find.'.$action;
114
                })
115
            );
116
117
        $this->assertSame($data, $this->domainManager->find($action, $repositoryMethod, $criteria, $sorting));
118
    }
119
120
    public function testFindThrowException()
121
    {
122
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
123
            ->expects($this->exactly(2))
124
            ->method('getName')
125
            ->will($this->returnValue($name = 'name'));
126
127
        $this->repository
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\R...ory\RepositoryInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
128
            ->expects($this->once())
129
            ->method($repositoryMethod = 'findForShow')
130
            ->with(
131
                $this->identicalTo($criteria = ['criteria']),
132
                $this->identicalTo($sorting = ['sorting'])
133
            )
134
            ->will($this->throwException(new \Exception()));
135
136
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
137
            ->expects($this->at(0))
138
            ->method('dispatch')
139
            ->with(
140
                $this->identicalTo('lug.'.$name.'.pre_find.'.($action = 'action')),
141
                $this->callback(function (DomainEvent $event) use ($action) {
142
                    return $event->getResource() === $this->resource
143
                        && $event->getData() === null
144
                        && $event->getAction() === 'find.'.$action;
145
                })
146
            );
147
148
        $statusCode = Response::HTTP_BAD_REQUEST;
149
        $message = 'message';
150
151
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
152
            ->expects($this->at(1))
153
            ->method('dispatch')
154
            ->with(
155
                $this->identicalTo('lug.'.$name.'.error_find.'.$action),
156
                $this->callback(function (DomainEvent $event) use ($action, $statusCode, $message) {
157
                    $result = $event->getResource() === $this->resource
158
                        && $event->getData() === null
159
                        && $event->getAction() === 'find.'.$action;
160
161
                    $event->setStatusCode($statusCode);
162
                    $event->setMessage($message);
163
164
                    return $result;
165
                })
166
            );
167
168
        try {
169
            $this->domainManager->find($action, $repositoryMethod, $criteria, $sorting);
170
            $this->fail();
171
        } catch (DomainException $e) {
172
            $this->assertSame($statusCode, $e->getStatusCode());
173
            $this->assertSame($message, $e->getMessage());
174
        }
175
    }
176
177
    public function testFindByPassException()
178
    {
179
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
180
            ->expects($this->exactly(2))
181
            ->method('getName')
182
            ->will($this->returnValue($name = 'name'));
183
184
        $this->repository
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\R...ory\RepositoryInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
185
            ->expects($this->once())
186
            ->method($repositoryMethod = 'findForShow')
187
            ->with(
188
                $this->identicalTo($criteria = ['criteria']),
189
                $this->identicalTo($sorting = ['sorting'])
190
            )
191
            ->will($this->throwException(new \Exception()));
192
193
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
194
            ->expects($this->at(0))
195
            ->method('dispatch')
196
            ->with(
197
                $this->identicalTo('lug.'.$name.'.pre_find.'.($action = 'action')),
198
                $this->callback(function (DomainEvent $event) use ($action) {
199
                    return $event->getResource() === $this->resource
200
                    && $event->getData() === null
201
                    && $event->getAction() === 'find.'.$action;
202
                })
203
            );
204
205
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
206
            ->expects($this->at(1))
207
            ->method('dispatch')
208
            ->with(
209
                $this->identicalTo('lug.'.$name.'.error_find.'.$action),
210
                $this->callback(function (DomainEvent $event) use ($action) {
211
                    $result = $event->getResource() === $this->resource
212
                        && $event->getData() === null
213
                        && $event->getAction() === 'find.'.$action;
214
215
                    $event->setStopped(false);
216
217
                    return $result;
218
                })
219
            );
220
221
        $this->assertNull($this->domainManager->find($action, $repositoryMethod, $criteria, $sorting));
222
    }
223
224 View Code Duplication
    public function testCreate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
225
    {
226
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
227
            ->expects($this->exactly(4))
228
            ->method('getName')
229
            ->will($this->returnValue($name = 'name'));
230
231
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
232
            ->expects($this->once())
233
            ->method('persist')
234
            ->with($this->identicalTo($data = new \stdClass()));
235
236
        $this->objectManager
237
            ->expects($this->once())
238
            ->method('flush');
239
240
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
241
            ->expects($this->at(0))
242
            ->method('dispatch')
243
            ->with(
244
                $this->identicalTo('lug.'.$name.'.pre_'.($createAction = 'create')),
245
                $this->callback(function (DomainEvent $event) use ($createAction, $data) {
246
                    return $event->getResource() === $this->resource
247
                        && $event->getData() === $data
248
                        && $event->getAction() === $createAction;
249
                })
250
            );
251
252
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
253
            ->expects($this->at(1))
254
            ->method('dispatch')
255
            ->with(
256
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
257
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
258
                    return $event->getResource() === $this->resource
259
                        && $event->getData() === $data
260
                        && $event->getAction() === $flushAction;
261
                })
262
            );
263
264
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
265
            ->expects($this->at(2))
266
            ->method('dispatch')
267
            ->with(
268
                $this->identicalTo('lug.'.$name.'.post_'.$flushAction),
269
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
270
                    return $event->getResource() === $this->resource
271
                        && $event->getData() === $data
272
                        && $event->getAction() === $flushAction;
273
                })
274
            );
275
276
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
277
            ->expects($this->at(3))
278
            ->method('dispatch')
279
            ->with(
280
                $this->identicalTo('lug.'.$name.'.post_'.$createAction),
281
                $this->callback(function (DomainEvent $event) use ($data, $createAction) {
282
                    return $event->getResource() === $this->resource
283
                        && $event->getData() === $data
284
                        && $event->getAction() === $createAction;
285
                })
286
            );
287
288
        $this->domainManager->create($data);
289
    }
290
291 View Code Duplication
    public function testCreateWithoutFlush()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
292
    {
293
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
294
            ->expects($this->exactly(2))
295
            ->method('getName')
296
            ->will($this->returnValue($name = 'name'));
297
298
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
299
            ->expects($this->once())
300
            ->method('persist')
301
            ->with($this->identicalTo($data = new \stdClass()));
302
303
        $this->objectManager
304
            ->expects($this->never())
305
            ->method('flush');
306
307
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
308
            ->expects($this->at(0))
309
            ->method('dispatch')
310
            ->with(
311
                $this->identicalTo('lug.'.$name.'.pre_'.($createAction = 'create')),
312
                $this->callback(function (DomainEvent $event) use ($createAction, $data) {
313
                    return $event->getResource() === $this->resource
314
                    && $event->getData() === $data
315
                    && $event->getAction() === $createAction;
316
                })
317
            );
318
319
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
320
            ->expects($this->at(1))
321
            ->method('dispatch')
322
            ->with(
323
                $this->identicalTo('lug.'.$name.'.post_'.$createAction),
324
                $this->callback(function (DomainEvent $event) use ($data, $createAction) {
325
                    return $event->getResource() === $this->resource
326
                    && $event->getData() === $data
327
                    && $event->getAction() === $createAction;
328
                })
329
            );
330
331
        $this->domainManager->create($data, false);
332
    }
333
334 View Code Duplication
    public function testCreateThrowException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
335
    {
336
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
337
            ->expects($this->exactly(4))
338
            ->method('getName')
339
            ->will($this->returnValue($name = 'name'));
340
341
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
342
            ->expects($this->once())
343
            ->method('persist')
344
            ->with($this->identicalTo($data = new \stdClass()));
345
346
        $this->objectManager
347
            ->expects($this->once())
348
            ->method('flush')
349
            ->will($this->throwException(new \Exception()));
350
351
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
352
            ->expects($this->at(0))
353
            ->method('dispatch')
354
            ->with(
355
                $this->identicalTo('lug.'.$name.'.pre_'.($createAction = 'create')),
356
                $this->callback(function (DomainEvent $event) use ($createAction, $data) {
357
                    return $event->getResource() === $this->resource
358
                        && $event->getData() === $data
359
                        && $event->getAction() === $createAction;
360
                })
361
            );
362
363
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
364
            ->expects($this->at(1))
365
            ->method('dispatch')
366
            ->with(
367
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
368
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
369
                    return $event->getResource() === $this->resource
370
                        && $event->getData() === $data
371
                        && $event->getAction() === $flushAction;
372
                })
373
            );
374
375
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
376
            ->expects($this->at(2))
377
            ->method('dispatch')
378
            ->with(
379
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
380
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
381
                    return $event->getResource() === $this->resource
382
                        && $event->getData() === $data
383
                        && $event->getAction() === $flushAction;
384
                })
385
            );
386
387
        $statusCode = Response::HTTP_BAD_REQUEST;
388
        $message = 'message';
389
390
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
391
            ->expects($this->at(3))
392
            ->method('dispatch')
393
            ->with(
394
                $this->identicalTo('lug.'.$name.'.error_'.$createAction),
395
                $this->callback(function (DomainEvent $event) use ($data, $createAction, $statusCode, $message) {
396
                    $result = $event->getResource() === $this->resource
397
                        && $event->getData() === $data
398
                        && $event->getAction() === $createAction;
399
400
                    $event->setStatusCode($statusCode);
401
                    $event->setMessage($message);
402
403
                    return $result;
404
                })
405
            );
406
407
        try {
408
            $this->domainManager->create($data);
409
            $this->fail();
410
        } catch (DomainException $e) {
411
            $this->assertSame($statusCode, $e->getStatusCode());
412
            $this->assertSame($message, $e->getMessage());
413
        }
414
    }
415
416 View Code Duplication
    public function testCreateByPassException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
417
    {
418
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
419
            ->expects($this->exactly(4))
420
            ->method('getName')
421
            ->will($this->returnValue($name = 'name'));
422
423
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
424
            ->expects($this->once())
425
            ->method('persist')
426
            ->with($this->identicalTo($data = new \stdClass()));
427
428
        $this->objectManager
429
            ->expects($this->once())
430
            ->method('flush')
431
            ->will($this->throwException(new \Exception()));
432
433
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
434
            ->expects($this->at(0))
435
            ->method('dispatch')
436
            ->with(
437
                $this->identicalTo('lug.'.$name.'.pre_'.($createAction = 'create')),
438
                $this->callback(function (DomainEvent $event) use ($createAction, $data) {
439
                    return $event->getResource() === $this->resource
440
                    && $event->getData() === $data
441
                    && $event->getAction() === $createAction;
442
                })
443
            );
444
445
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
446
            ->expects($this->at(1))
447
            ->method('dispatch')
448
            ->with(
449
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
450
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
451
                    return $event->getResource() === $this->resource
452
                    && $event->getData() === $data
453
                    && $event->getAction() === $flushAction;
454
                })
455
            );
456
457
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
458
            ->expects($this->at(2))
459
            ->method('dispatch')
460
            ->with(
461
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
462
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
463
                    return $event->getResource() === $this->resource
464
                    && $event->getData() === $data
465
                    && $event->getAction() === $flushAction;
466
                })
467
            );
468
469
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
470
            ->expects($this->at(3))
471
            ->method('dispatch')
472
            ->with(
473
                $this->identicalTo('lug.'.$name.'.error_'.$createAction),
474
                $this->callback(function (DomainEvent $event) use ($data, $createAction) {
475
                    $result = $event->getResource() === $this->resource
476
                        && $event->getData() === $data
477
                        && $event->getAction() === $createAction;
478
479
                    $event->setStopped(false);
480
481
                    return $result;
482
                })
483
            );
484
485
        $this->domainManager->create($data);
486
    }
487
488 View Code Duplication
    public function testUpdateWithManagedObject()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
489
    {
490
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
491
            ->expects($this->exactly(4))
492
            ->method('getName')
493
            ->will($this->returnValue($name = 'name'));
494
495
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
496
            ->expects($this->once())
497
            ->method('contains')
498
            ->with($this->identicalTo($data = new \stdClass()))
499
            ->will($this->returnValue(true));
500
501
        $this->objectManager
502
            ->expects($this->never())
503
            ->method('persist');
504
505
        $this->objectManager
506
            ->expects($this->once())
507
            ->method('flush');
508
509
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
510
            ->expects($this->at(0))
511
            ->method('dispatch')
512
            ->with(
513
                $this->identicalTo('lug.'.$name.'.pre_'.($updateAction = 'update')),
514
                $this->callback(function (DomainEvent $event) use ($updateAction, $data) {
515
                    return $event->getResource() === $this->resource
516
                    && $event->getData() === $data
517
                    && $event->getAction() === $updateAction;
518
                })
519
            );
520
521
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
522
            ->expects($this->at(1))
523
            ->method('dispatch')
524
            ->with(
525
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
526
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
527
                    return $event->getResource() === $this->resource
528
                    && $event->getData() === $data
529
                    && $event->getAction() === $flushAction;
530
                })
531
            );
532
533
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
534
            ->expects($this->at(2))
535
            ->method('dispatch')
536
            ->with(
537
                $this->identicalTo('lug.'.$name.'.post_'.$flushAction),
538
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
539
                    return $event->getResource() === $this->resource
540
                    && $event->getData() === $data
541
                    && $event->getAction() === $flushAction;
542
                })
543
            );
544
545
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
546
            ->expects($this->at(3))
547
            ->method('dispatch')
548
            ->with(
549
                $this->identicalTo('lug.'.$name.'.post_'.$updateAction),
550
                $this->callback(function (DomainEvent $event) use ($data, $updateAction) {
551
                    return $event->getResource() === $this->resource
552
                    && $event->getData() === $data
553
                    && $event->getAction() === $updateAction;
554
                })
555
            );
556
557
        $this->domainManager->update($data);
558
    }
559
560 View Code Duplication
    public function testUpdateWithoutManagedObject()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
561
    {
562
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
563
            ->expects($this->exactly(4))
564
            ->method('getName')
565
            ->will($this->returnValue($name = 'name'));
566
567
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
568
            ->expects($this->once())
569
            ->method('contains')
570
            ->with($this->identicalTo($data = new \stdClass()))
571
            ->will($this->returnValue(false));
572
573
        $this->objectManager
574
            ->expects($this->once())
575
            ->method('persist')
576
            ->with($this->identicalTo($data));
577
578
        $this->objectManager
579
            ->expects($this->once())
580
            ->method('flush');
581
582
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
583
            ->expects($this->at(0))
584
            ->method('dispatch')
585
            ->with(
586
                $this->identicalTo('lug.'.$name.'.pre_'.($updateAction = 'update')),
587
                $this->callback(function (DomainEvent $event) use ($updateAction, $data) {
588
                    return $event->getResource() === $this->resource
589
                    && $event->getData() === $data
590
                    && $event->getAction() === $updateAction;
591
                })
592
            );
593
594
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
595
            ->expects($this->at(1))
596
            ->method('dispatch')
597
            ->with(
598
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
599
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
600
                    return $event->getResource() === $this->resource
601
                    && $event->getData() === $data
602
                    && $event->getAction() === $flushAction;
603
                })
604
            );
605
606
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
607
            ->expects($this->at(2))
608
            ->method('dispatch')
609
            ->with(
610
                $this->identicalTo('lug.'.$name.'.post_'.$flushAction),
611
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
612
                    return $event->getResource() === $this->resource
613
                    && $event->getData() === $data
614
                    && $event->getAction() === $flushAction;
615
                })
616
            );
617
618
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
619
            ->expects($this->at(3))
620
            ->method('dispatch')
621
            ->with(
622
                $this->identicalTo('lug.'.$name.'.post_'.$updateAction),
623
                $this->callback(function (DomainEvent $event) use ($data, $updateAction) {
624
                    return $event->getResource() === $this->resource
625
                    && $event->getData() === $data
626
                    && $event->getAction() === $updateAction;
627
                })
628
            );
629
630
        $this->domainManager->update($data);
631
    }
632
633 View Code Duplication
    public function testUpdateWithoutFlush()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
634
    {
635
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
636
            ->expects($this->exactly(2))
637
            ->method('getName')
638
            ->will($this->returnValue($name = 'name'));
639
640
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
641
            ->expects($this->once())
642
            ->method('persist')
643
            ->with($this->identicalTo($data = new \stdClass()));
644
645
        $this->objectManager
646
            ->expects($this->never())
647
            ->method('flush');
648
649
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
650
            ->expects($this->at(0))
651
            ->method('dispatch')
652
            ->with(
653
                $this->identicalTo('lug.'.$name.'.pre_'.($updateAction = 'update')),
654
                $this->callback(function (DomainEvent $event) use ($updateAction, $data) {
655
                    return $event->getResource() === $this->resource
656
                    && $event->getData() === $data
657
                    && $event->getAction() === $updateAction;
658
                })
659
            );
660
661
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
662
            ->expects($this->at(1))
663
            ->method('dispatch')
664
            ->with(
665
                $this->identicalTo('lug.'.$name.'.post_'.$updateAction),
666
                $this->callback(function (DomainEvent $event) use ($data, $updateAction) {
667
                    return $event->getResource() === $this->resource
668
                    && $event->getData() === $data
669
                    && $event->getAction() === $updateAction;
670
                })
671
            );
672
673
        $this->domainManager->update($data, false);
674
    }
675
676
    public function testUpdateThrowException()
677
    {
678
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
679
            ->expects($this->exactly(4))
680
            ->method('getName')
681
            ->will($this->returnValue($name = 'name'));
682
683
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
684
            ->expects($this->once())
685
            ->method('contains')
686
            ->with($this->identicalTo($data = new \stdClass()))
687
            ->will($this->returnValue(false));
688
689
        $this->objectManager
690
            ->expects($this->once())
691
            ->method('persist')
692
            ->with($this->identicalTo($data));
693
694
        $this->objectManager
695
            ->expects($this->once())
696
            ->method('flush')
697
            ->will($this->throwException(new \Exception()));
698
699
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
700
            ->expects($this->at(0))
701
            ->method('dispatch')
702
            ->with(
703
                $this->identicalTo('lug.'.$name.'.pre_'.($updateAction = 'update')),
704
                $this->callback(function (DomainEvent $event) use ($updateAction, $data) {
705
                    return $event->getResource() === $this->resource
706
                    && $event->getData() === $data
707
                    && $event->getAction() === $updateAction;
708
                })
709
            );
710
711
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
712
            ->expects($this->at(1))
713
            ->method('dispatch')
714
            ->with(
715
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
716
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
717
                    return $event->getResource() === $this->resource
718
                    && $event->getData() === $data
719
                    && $event->getAction() === $flushAction;
720
                })
721
            );
722
723
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
724
            ->expects($this->at(2))
725
            ->method('dispatch')
726
            ->with(
727
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
728
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
729
                    return $event->getResource() === $this->resource
730
                    && $event->getData() === $data
731
                    && $event->getAction() === $flushAction;
732
                })
733
            );
734
735
        $statusCode = Response::HTTP_BAD_REQUEST;
736
        $message = 'message';
737
738
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
739
            ->expects($this->at(3))
740
            ->method('dispatch')
741
            ->with(
742
                $this->identicalTo('lug.'.$name.'.error_'.$updateAction),
743
                $this->callback(function (DomainEvent $event) use ($data, $updateAction, $statusCode, $message) {
744
                    $result = $event->getResource() === $this->resource
745
                        && $event->getData() === $data
746
                        && $event->getAction() === $updateAction;
747
748
                    $event->setStatusCode($statusCode);
749
                    $event->setMessage($message);
750
751
                    return $result;
752
                })
753
            );
754
755
        try {
756
            $this->domainManager->update($data);
757
            $this->fail();
758
        } catch (DomainException $e) {
759
            $this->assertSame($statusCode, $e->getStatusCode());
760
            $this->assertSame($message, $e->getMessage());
761
        }
762
    }
763
764
    public function testUpdateByPassException()
765
    {
766
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
767
            ->expects($this->exactly(4))
768
            ->method('getName')
769
            ->will($this->returnValue($name = 'name'));
770
771
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
772
            ->expects($this->once())
773
            ->method('contains')
774
            ->with($this->identicalTo($data = new \stdClass()))
775
            ->will($this->returnValue(false));
776
777
        $this->objectManager
778
            ->expects($this->once())
779
            ->method('persist')
780
            ->with($this->identicalTo($data));
781
782
        $this->objectManager
783
            ->expects($this->once())
784
            ->method('flush')
785
            ->will($this->throwException(new \Exception()));
786
787
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
788
            ->expects($this->at(0))
789
            ->method('dispatch')
790
            ->with(
791
                $this->identicalTo('lug.'.$name.'.pre_'.($updateAction = 'update')),
792
                $this->callback(function (DomainEvent $event) use ($updateAction, $data) {
793
                    return $event->getResource() === $this->resource
794
                    && $event->getData() === $data
795
                    && $event->getAction() === $updateAction;
796
                })
797
            );
798
799
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
800
            ->expects($this->at(1))
801
            ->method('dispatch')
802
            ->with(
803
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
804
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
805
                    return $event->getResource() === $this->resource
806
                    && $event->getData() === $data
807
                    && $event->getAction() === $flushAction;
808
                })
809
            );
810
811
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
812
            ->expects($this->at(2))
813
            ->method('dispatch')
814
            ->with(
815
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
816
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
817
                    return $event->getResource() === $this->resource
818
                    && $event->getData() === $data
819
                    && $event->getAction() === $flushAction;
820
                })
821
            );
822
823
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
824
            ->expects($this->at(3))
825
            ->method('dispatch')
826
            ->with(
827
                $this->identicalTo('lug.'.$name.'.error_'.$updateAction),
828
                $this->callback(function (DomainEvent $event) use ($data, $updateAction) {
829
                    $result = $event->getResource() === $this->resource
830
                        && $event->getData() === $data
831
                        && $event->getAction() === $updateAction;
832
833
                    $event->setStopped(false);
834
835
                    return $result;
836
                })
837
            );
838
839
        $this->domainManager->update($data);
840
    }
841
842 View Code Duplication
    public function testDelete()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
843
    {
844
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
845
            ->expects($this->exactly(4))
846
            ->method('getName')
847
            ->will($this->returnValue($name = 'name'));
848
849
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
850
            ->expects($this->once())
851
            ->method('remove')
852
            ->with($this->identicalTo($data = new \stdClass()));
853
854
        $this->objectManager
855
            ->expects($this->once())
856
            ->method('flush');
857
858
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
859
            ->expects($this->at(0))
860
            ->method('dispatch')
861
            ->with(
862
                $this->identicalTo('lug.'.$name.'.pre_'.($deleteAction = 'delete')),
863
                $this->callback(function (DomainEvent $event) use ($deleteAction, $data) {
864
                    return $event->getResource() === $this->resource
865
                    && $event->getData() === $data
866
                    && $event->getAction() === $deleteAction;
867
                })
868
            );
869
870
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
871
            ->expects($this->at(1))
872
            ->method('dispatch')
873
            ->with(
874
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
875
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
876
                    return $event->getResource() === $this->resource
877
                    && $event->getData() === $data
878
                    && $event->getAction() === $flushAction;
879
                })
880
            );
881
882
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
883
            ->expects($this->at(2))
884
            ->method('dispatch')
885
            ->with(
886
                $this->identicalTo('lug.'.$name.'.post_'.$flushAction),
887
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
888
                    return $event->getResource() === $this->resource
889
                    && $event->getData() === $data
890
                    && $event->getAction() === $flushAction;
891
                })
892
            );
893
894
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
895
            ->expects($this->at(3))
896
            ->method('dispatch')
897
            ->with(
898
                $this->identicalTo('lug.'.$name.'.post_'.$deleteAction),
899
                $this->callback(function (DomainEvent $event) use ($data, $deleteAction) {
900
                    return $event->getResource() === $this->resource
901
                    && $event->getData() === $data
902
                    && $event->getAction() === $deleteAction;
903
                })
904
            );
905
906
        $this->domainManager->delete($data);
907
    }
908
909 View Code Duplication
    public function testDeleteWithoutFlush()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
910
    {
911
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
912
            ->expects($this->exactly(2))
913
            ->method('getName')
914
            ->will($this->returnValue($name = 'name'));
915
916
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
917
            ->expects($this->once())
918
            ->method('remove')
919
            ->with($this->identicalTo($data = new \stdClass()));
920
921
        $this->objectManager
922
            ->expects($this->never())
923
            ->method('flush');
924
925
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
926
            ->expects($this->at(0))
927
            ->method('dispatch')
928
            ->with(
929
                $this->identicalTo('lug.'.$name.'.pre_'.($deleteAction = 'delete')),
930
                $this->callback(function (DomainEvent $event) use ($deleteAction, $data) {
931
                    return $event->getResource() === $this->resource
932
                    && $event->getData() === $data
933
                    && $event->getAction() === $deleteAction;
934
                })
935
            );
936
937
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
938
            ->expects($this->at(1))
939
            ->method('dispatch')
940
            ->with(
941
                $this->identicalTo('lug.'.$name.'.post_'.$deleteAction),
942
                $this->callback(function (DomainEvent $event) use ($data, $deleteAction) {
943
                    return $event->getResource() === $this->resource
944
                    && $event->getData() === $data
945
                    && $event->getAction() === $deleteAction;
946
                })
947
            );
948
949
        $this->domainManager->delete($data, false);
950
    }
951
952 View Code Duplication
    public function testDeleteThrowException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
953
    {
954
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
955
            ->expects($this->exactly(4))
956
            ->method('getName')
957
            ->will($this->returnValue($name = 'name'));
958
959
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
960
            ->expects($this->once())
961
            ->method('remove')
962
            ->with($this->identicalTo($data = new \stdClass()));
963
964
        $this->objectManager
965
            ->expects($this->once())
966
            ->method('flush')
967
            ->will($this->throwException(new \Exception()));
968
969
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
970
            ->expects($this->at(0))
971
            ->method('dispatch')
972
            ->with(
973
                $this->identicalTo('lug.'.$name.'.pre_'.($deleteAction = 'delete')),
974
                $this->callback(function (DomainEvent $event) use ($deleteAction, $data) {
975
                    return $event->getResource() === $this->resource
976
                    && $event->getData() === $data
977
                    && $event->getAction() === $deleteAction;
978
                })
979
            );
980
981
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
982
            ->expects($this->at(1))
983
            ->method('dispatch')
984
            ->with(
985
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
986
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
987
                    return $event->getResource() === $this->resource
988
                    && $event->getData() === $data
989
                    && $event->getAction() === $flushAction;
990
                })
991
            );
992
993
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
994
            ->expects($this->at(2))
995
            ->method('dispatch')
996
            ->with(
997
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
998
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
999
                    return $event->getResource() === $this->resource
1000
                    && $event->getData() === $data
1001
                    && $event->getAction() === $flushAction;
1002
                })
1003
            );
1004
1005
        $statusCode = Response::HTTP_BAD_REQUEST;
1006
        $message = 'message';
1007
1008
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1009
            ->expects($this->at(3))
1010
            ->method('dispatch')
1011
            ->with(
1012
                $this->identicalTo('lug.'.$name.'.error_'.$deleteAction),
1013
                $this->callback(function (DomainEvent $event) use ($data, $deleteAction, $statusCode, $message) {
1014
                    $result = $event->getResource() === $this->resource
1015
                        && $event->getData() === $data
1016
                        && $event->getAction() === $deleteAction;
1017
1018
                    $event->setStatusCode($statusCode);
1019
                    $event->setMessage($message);
1020
1021
                    return $result;
1022
                })
1023
            );
1024
1025
        try {
1026
            $this->domainManager->delete($data);
1027
            $this->fail();
1028
        } catch (DomainException $e) {
1029
            $this->assertSame($statusCode, $e->getStatusCode());
1030
            $this->assertSame($message, $e->getMessage());
1031
        }
1032
    }
1033
1034 View Code Duplication
    public function testDeleteByPassException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1035
    {
1036
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1037
            ->expects($this->exactly(4))
1038
            ->method('getName')
1039
            ->will($this->returnValue($name = 'name'));
1040
1041
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1042
            ->expects($this->once())
1043
            ->method('remove')
1044
            ->with($this->identicalTo($data = new \stdClass()));
1045
1046
        $this->objectManager
1047
            ->expects($this->once())
1048
            ->method('flush')
1049
            ->will($this->throwException(new \Exception()));
1050
1051
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1052
            ->expects($this->at(0))
1053
            ->method('dispatch')
1054
            ->with(
1055
                $this->identicalTo('lug.'.$name.'.pre_'.($deleteAction = 'delete')),
1056
                $this->callback(function (DomainEvent $event) use ($deleteAction, $data) {
1057
                    return $event->getResource() === $this->resource
1058
                    && $event->getData() === $data
1059
                    && $event->getAction() === $deleteAction;
1060
                })
1061
            );
1062
1063
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1064
            ->expects($this->at(1))
1065
            ->method('dispatch')
1066
            ->with(
1067
                $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')),
1068
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
1069
                    return $event->getResource() === $this->resource
1070
                    && $event->getData() === $data
1071
                    && $event->getAction() === $flushAction;
1072
                })
1073
            );
1074
1075
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1076
            ->expects($this->at(2))
1077
            ->method('dispatch')
1078
            ->with(
1079
                $this->identicalTo('lug.'.$name.'.error_'.$flushAction),
1080
                $this->callback(function (DomainEvent $event) use ($flushAction, $data) {
1081
                    return $event->getResource() === $this->resource
1082
                    && $event->getData() === $data
1083
                    && $event->getAction() === $flushAction;
1084
                })
1085
            );
1086
1087
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1088
            ->expects($this->at(3))
1089
            ->method('dispatch')
1090
            ->with(
1091
                $this->identicalTo('lug.'.$name.'.error_'.$deleteAction),
1092
                $this->callback(function (DomainEvent $event) use ($data, $deleteAction) {
1093
                    $result = $event->getResource() === $this->resource
1094
                        && $event->getData() === $data
1095
                        && $event->getAction() === $deleteAction;
1096
1097
                    $event->setStopped(false);
1098
1099
                    return $result;
1100
                })
1101
            );
1102
1103
        $this->domainManager->delete($data);
1104
    }
1105
1106
    public function testFlush()
1107
    {
1108
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1109
            ->expects($this->exactly(2))
1110
            ->method('getName')
1111
            ->will($this->returnValue($name = 'name'));
1112
1113
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1114
            ->expects($this->once())
1115
            ->method('flush');
1116
1117
        $data = new \stdClass();
1118
1119
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1120
            ->expects($this->at(0))
1121
            ->method('dispatch')
1122
            ->with(
1123
                $this->identicalTo('lug.'.$name.'.pre_'.($action = 'flush')),
1124
                $this->callback(function (DomainEvent $event) use ($action, $data) {
1125
                    return $event->getResource() === $this->resource
1126
                    && $event->getData() === $data
1127
                    && $event->getAction() === $action;
1128
                })
1129
            );
1130
1131
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1132
            ->expects($this->at(1))
1133
            ->method('dispatch')
1134
            ->with(
1135
                $this->identicalTo('lug.'.$name.'.post_'.$action),
1136
                $this->callback(function (DomainEvent $event) use ($action, $data) {
1137
                    return $event->getResource() === $this->resource
1138
                    && $event->getData() === $data
1139
                    && $event->getAction() === $action;
1140
                })
1141
            );
1142
1143
        $this->domainManager->flush($data);
1144
    }
1145
1146
    public function testFlushWithoutObject()
1147
    {
1148
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1149
            ->expects($this->exactly(2))
1150
            ->method('getName')
1151
            ->will($this->returnValue($name = 'name'));
1152
1153
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1154
            ->expects($this->once())
1155
            ->method('flush');
1156
1157
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1158
            ->expects($this->at(0))
1159
            ->method('dispatch')
1160
            ->with(
1161
                $this->identicalTo('lug.'.$name.'.pre_'.($action = 'flush')),
1162
                $this->callback(function (DomainEvent $event) use ($action) {
1163
                    return $event->getResource() === $this->resource
1164
                    && $event->getData() === null
1165
                    && $event->getAction() === $action;
1166
                })
1167
            );
1168
1169
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1170
            ->expects($this->at(1))
1171
            ->method('dispatch')
1172
            ->with(
1173
                $this->identicalTo('lug.'.$name.'.post_'.$action),
1174
                $this->callback(function (DomainEvent $event) use ($action) {
1175
                    return $event->getResource() === $this->resource
1176
                    && $event->getData() === null
1177
                    && $event->getAction() === $action;
1178
                })
1179
            );
1180
1181
        $this->domainManager->flush();
1182
    }
1183
1184
    public function testFlushThrowException()
1185
    {
1186
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1187
            ->expects($this->exactly(2))
1188
            ->method('getName')
1189
            ->will($this->returnValue($name = 'name'));
1190
1191
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1192
            ->expects($this->once())
1193
            ->method('flush')
1194
            ->will($this->throwException(new \Exception()));
1195
1196
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1197
            ->expects($this->at(0))
1198
            ->method('dispatch')
1199
            ->with(
1200
                $this->identicalTo('lug.'.$name.'.pre_'.($action = 'flush')),
1201
                $this->callback(function (DomainEvent $event) use ($action) {
1202
                    return $event->getResource() === $this->resource
1203
                    && $event->getData() === null
1204
                    && $event->getAction() === $action;
1205
                })
1206
            );
1207
1208
        $statusCode = Response::HTTP_BAD_REQUEST;
1209
        $message = 'message';
1210
1211
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1212
            ->expects($this->at(1))
1213
            ->method('dispatch')
1214
            ->with(
1215
                $this->identicalTo('lug.'.$name.'.error_'.$action),
1216
                $this->callback(function (DomainEvent $event) use ($action, $statusCode, $message) {
1217
                    $result = $event->getResource() === $this->resource
1218
                        && $event->getData() === null
1219
                        && $event->getAction() === $action;
1220
1221
                    $event->setStatusCode($statusCode);
1222
                    $event->setMessage($message);
1223
1224
                    return $result;
1225
                })
1226
            );
1227
1228
        try {
1229
            $this->domainManager->flush();
1230
            $this->fail();
1231
        } catch (DomainException $e) {
1232
            $this->assertSame($statusCode, $e->getStatusCode());
1233
            $this->assertSame($message, $e->getMessage());
1234
        }
1235
    }
1236
1237
    public function testFlushByPassException()
1238
    {
1239
        $this->resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1240
            ->expects($this->exactly(2))
1241
            ->method('getName')
1242
            ->will($this->returnValue($name = 'name'));
1243
1244
        $this->objectManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\Common\Persistence\ObjectManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1245
            ->expects($this->once())
1246
            ->method('flush')
1247
            ->will($this->throwException(new \Exception()));
1248
1249
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1250
            ->expects($this->at(0))
1251
            ->method('dispatch')
1252
            ->with(
1253
                $this->identicalTo('lug.'.$name.'.pre_'.($action = 'flush')),
1254
                $this->callback(function (DomainEvent $event) use ($action) {
1255
                    return $event->getResource() === $this->resource
1256
                        && $event->getData() === null
1257
                        && $event->getAction() === $action;
1258
                })
1259
            );
1260
1261
        $this->eventDispatcher
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\EventD...ventDispatcherInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
1262
            ->expects($this->at(1))
1263
            ->method('dispatch')
1264
            ->with(
1265
                $this->identicalTo('lug.'.$name.'.error_'.$action),
1266
                $this->callback(function (DomainEvent $event) use ($action) {
1267
                    $result = $event->getResource() === $this->resource
1268
                        && $event->getData() === null
1269
                        && $event->getAction() === $action;
1270
1271
                    $event->setStopped(false);
1272
1273
                    return $result;
1274
                })
1275
            );
1276
1277
        $this->domainManager->flush();
1278
    }
1279
1280
    /**
1281
     * @return \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
1282
     */
1283
    private function createResourceMock()
1284
    {
1285
        return $this->createMock(ResourceInterface::class);
1286
    }
1287
1288
    /**
1289
     * @return \PHPUnit_Framework_MockObject_MockObject|EventDispatcherInterface
1290
     */
1291
    private function createEventDispatcherMock()
1292
    {
1293
        return $this->createMock(EventDispatcherInterface::class);
1294
    }
1295
1296
    /**
1297
     * @return \PHPUnit_Framework_MockObject_MockObject|ObjectManager
1298
     */
1299
    private function createObjectManagerMock()
1300
    {
1301
        return $this->createMock(ObjectManager::class);
1302
    }
1303
1304
    /**
1305
     * @return \PHPUnit_Framework_MockObject_MockObject|RepositoryInterface
1306
     */
1307
    private function createRepositoryMock()
1308
    {
1309
        return $this->createMock(RepositoryInterface::class);
1310
    }
1311
}
1312