Completed
Push — master ( 7f572e...bf04a1 )
by Benedikt
02:39
created

DeletionServiceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 28.13 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 9
loc 32
c 0
b 0
f 0
rs 10
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 9 9 1
A testDeletePlayer() 0 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 1/3/18
7
 * Time: 3:53 PM
8
 */
9
10
namespace Tfboe\FmLib\Tests\Unit\Service;
11
12
use Doctrine\ORM\EntityManagerInterface;
13
use Tfboe\FmLib\Entity\PlayerInterface;
14
use Tfboe\FmLib\Service\DeletionService;
15
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
16
17
18
/**
19
 * Class DeletionServiceTest
20
 * @package Tfboe\FmLib\Tests\Unit\Service
21
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22
 */
23
class DeletionServiceTest extends UnitTestCase
24
{
25
//<editor-fold desc="Public Methods">
26
  /**
27
   * @covers \Tfboe\FmLib\Service\DeletionService::__construct
28
   */
29 View Code Duplication
  public function testConstruct()
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...
30
  {
31
    /** @var EntityManagerInterface $entityManager */
32
    $entityManager = $this->getMockForAbstractClass(EntityManagerInterface::class);
33
    $service = new DeletionService($entityManager);
34
    self::assertInstanceOf(DeletionService::class, $service);
35
    /** @noinspection PhpUnhandledExceptionInspection */
36
    self::assertEquals($entityManager, self::getProperty(get_class($service), 'entityManager')->getValue($service));
37
  }
38
39
  /**
40
   * @covers \Tfboe\FmLib\Service\DeletionService::deletePlayer
41
   * @uses   \Tfboe\FmLib\Service\DeletionService::__construct
42
   */
43
  public function testDeletePlayer()
44
  {
45
    /** @var PlayerInterface $player */
46
    $player = $this->createMock(PlayerInterface::class);
47
    $entityManager = $this->createMock(EntityManagerInterface::class);
48
    $entityManager->expects(self::once())->method('remove')->with($player);
49
    /** @var EntityManagerInterface $entityManager */
50
    $service = new DeletionService($entityManager);
51
    $service->deletePlayer($player);
52
  }
53
//</editor-fold desc="Public Methods">
54
}