OrganizingModeTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 46
loc 46
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\OrganizingMode;
13
use Tfboe\FmLib\Exceptions\ValueNotValid;
14
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
15
16
/**
17
 * Class OrganizingModeTest
18
 * @package Tfboe\FmLib\Tests\Unit\Entity\CategoryTraits
19
 */
20 View Code Duplication
class OrganizingModeTest 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
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\OrganizingMode::getOrganizingMode
25
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\OrganizingMode::setOrganizingMode
26
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
27
   */
28
  public function testProperty()
29
  {
30
    $mock = $this->mock();
31
    self::assertNull($mock->getOrganizingMode());
32
    /** @noinspection PhpUnhandledExceptionInspection */
33
    $mock->setOrganizingMode(OrganizingMode::ELIMINATION);
34
    self::assertEquals(OrganizingMode::ELIMINATION, $mock->getOrganizingMode());
35
    /** @noinspection PhpUnhandledExceptionInspection */
36
    $mock->setOrganizingMode(null);
37
    self::assertNull($mock->getOrganizingMode());
38
  }
39
40
  /**
41
   * @covers \Tfboe\FmLib\Entity\CategoryTraits\OrganizingMode::setOrganizingMode
42
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
43
   * @uses   \Tfboe\FmLib\Exceptions\ValueNotValid::__construct
44
   */
45
  public function testPropertyException()
46
  {
47
    $mock = $this->mock();
48
    $this->expectException(ValueNotValid::class);
49
    $this->expectExceptionMessage(
50
      'The following value is not valid: 100 in Tfboe\FmLib\Entity\Categories\OrganizingMode. Possible values: 0, 1.');
51
    /** @noinspection PhpUnhandledExceptionInspection */
52
    $mock->setOrganizingMode(100);
53
  }
54
//</editor-fold desc="Public Methods">
55
56
//<editor-fold desc="Private Methods">
57
  /**
58
   * @return \PHPUnit_Framework_MockObject_MockObject|\Tfboe\FmLib\Entity\CategoryTraits\OrganizingMode
59
   */
60
  private function mock(): \PHPUnit_Framework_MockObject_MockObject
61
  {
62
    return $this->getMockForTrait(\Tfboe\FmLib\Entity\CategoryTraits\OrganizingMode::class);
63
  }
64
//</editor-fold desc="Private Methods">
65
}