TeamModeTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 47
loc 47
c 0
b 0
f 0
rs 10
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testProperty() 11 11 1
A testPropertyException() 9 9 1
A mock() 4 4 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: 10/1/17
7
 * Time: 12:05 PM
8
 */
9
10
namespace Tfboe\FmLib\Tests\Unit\Entity\CategoryTraits;
11
12
use Tfboe\FmLib\Entity\Categories\TeamMode;
13
use Tfboe\FmLib\Exceptions\ValueNotValid;
14
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
15
16
/**
17
 * Class TeamModeTest
18
 * @package Tfboe\FmLib\Tests\Unit\Entity\CategoryTraits
19
 */
20 View Code Duplication
class TeamModeTest extends UnitTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
21
{
22
//<editor-fold desc="Public Methods">
23
24
  /**
25
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::getTeamMode
26
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode
27
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
28
   */
29
  public function testProperty()
30
  {
31
    $mock = $this->mock();
32
    self::assertNull($mock->getTeamMode());
33
    /** @noinspection PhpUnhandledExceptionInspection */
34
    $mock->setTeamMode(TeamMode::DOUBLE);
35
    self::assertEquals(TeamMode::DOUBLE, $mock->getTeamMode());
36
    /** @noinspection PhpUnhandledExceptionInspection */
37
    $mock->setTeamMode(null);
38
    self::assertNull($mock->getTeamMode());
39
  }
40
41
  /**
42
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode
43
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
44
   * @uses   \Tfboe\FmLib\Exceptions\ValueNotValid::__construct
45
   */
46
  public function testPropertyException()
47
  {
48
    $mock = $this->mock();
49
    $this->expectException(ValueNotValid::class);
50
    $this->expectExceptionMessage(
51
      'The following value is not valid: 100 in Tfboe\FmLib\Entity\Categories\TeamMode. Possible values: 0, 1, 2.');
52
    /** @noinspection PhpUnhandledExceptionInspection */
53
    $mock->setTeamMode(100);
54
  }
55
//</editor-fold desc="Public Methods">
56
57
//<editor-fold desc="Private Methods">
58
  /**
59
   * @return \PHPUnit_Framework_MockObject_MockObject|\Tfboe\FmLib\Entity\CategoryTraits\TeamMode
60
   */
61
  private function mock(): \PHPUnit_Framework_MockObject_MockObject
62
  {
63
    return $this->getMockForTrait(\Tfboe\FmLib\Entity\CategoryTraits\TeamMode::class);
64
  }
65
//</editor-fold desc="Private Methods">
66
}