These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Tests\EventListener; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Entity\AbstractEntity; |
||
6 | use Kunstmaan\AdminBundle\Entity\DeepCloneInterface; |
||
7 | use Kunstmaan\AdminBundle\Event\DeepCloneAndSaveEvent; |
||
8 | use Kunstmaan\AdminBundle\EventListener\CloneListener; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | |||
11 | class CloneListenerTest extends TestCase |
||
12 | { |
||
13 | View Code Duplication | public function testOnDeepCloneAndSaveWithAbstractEntity() |
|
0 ignored issues
–
show
|
|||
14 | { |
||
15 | $listener = new CloneListener(); |
||
16 | |||
17 | /** @var AbstractEntity $entityMock */ |
||
18 | $entityMock = $this->getMockForAbstractClass(AbstractEntity::class); |
||
19 | $entityMock->setId(747); |
||
20 | |||
21 | $event = $this->createMock(DeepCloneAndSaveEvent::class); |
||
22 | $event->expects($this->any())->method('getClonedEntity')->willReturn($entityMock); |
||
23 | |||
24 | $listener->onDeepCloneAndSave($event); |
||
25 | $this->assertNull($entityMock->getId()); |
||
26 | } |
||
27 | |||
28 | View Code Duplication | public function testOnDeepCloneAndSaveWithDeepCloneInterface() |
|
0 ignored issues
–
show
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...
|
|||
29 | { |
||
30 | $listener = new CloneListener(); |
||
31 | |||
32 | $deepCloneInterfaceMock = $this->createMock(DeepCloneInterface::class); |
||
33 | $deepCloneInterfaceMock->expects($this->once())->method('deepClone'); |
||
34 | |||
35 | $event = $this->createMock(DeepCloneAndSaveEvent::class); |
||
36 | $event->expects($this->any())->method('getClonedEntity')->willReturn($deepCloneInterfaceMock); |
||
37 | |||
38 | $listener->onDeepCloneAndSave($event); |
||
39 | } |
||
40 | } |
||
41 |
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.