DynamicServiceLoadingServiceTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 23.08 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 9 9 1
A testLoadRankingSystemService() 0 14 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 Illuminate\Contracts\Container\Container;
13
use Tfboe\FmLib\Service\DynamicServiceLoadingService;
14
use Tfboe\FmLib\Service\RankingSystem\RankingSystemInterface;
15
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
16
17
/**
18
 * Class EloRankingTest
19
 * @packageTfboe\FmLib\Tests\Unit\Service
20
 */
21
class DynamicServiceLoadingServiceTest extends UnitTestCase
22
{
23
//<editor-fold desc="Public Methods">
24
25
  /**
26
   * @covers \Tfboe\FmLib\Service\DynamicServiceLoadingService::__construct
27
   */
28 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...
29
  {
30
    $app = $this->getMockForAbstractClass(Container::class);
31
    /** @var Container $app */
32
    $entity = new DynamicServiceLoadingService($app);
33
    self::assertInstanceOf(DynamicServiceLoadingService::class, $entity);
34
    /** @noinspection PhpUnhandledExceptionInspection */
35
    self::assertEquals($app, self::getProperty(get_class($entity), 'app')->getValue($entity));
36
  }
37
38
39
  /**
40
   * @covers \Tfboe\FmLib\Service\DynamicServiceLoadingService::loadRankingSystemService
41
   * @covers \Tfboe\FmLib\Service\DynamicServiceLoadingService::getClassWithNamespace
42
   * @uses   \Tfboe\FmLib\Service\DynamicServiceLoadingService::__construct
43
   */
44
  public function testLoadRankingSystemService()
45
  {
46
    $app = $this->getMockForAbstractClass(Container::class);
47
    $instance = $this->getMockForAbstractClass(RankingSystemInterface::class);
48
    $app->expects(self::exactly(4))->method('make')->with('Tfboe\FmLib\Service\RankingSystem\TestInterface')
49
      ->willReturn($instance);
50
    /** @var Container $app */
51
    $entity = new DynamicServiceLoadingService($app);
52
    self::assertTrue($instance === $entity->loadRankingSystemService("Test"));
53
    self::assertTrue($instance === $entity->loadRankingSystemService("TestInterface"));
54
    self::assertTrue($instance === $entity->loadRankingSystemService("Tfboe\FmLib\Service\RankingSystem\Test"));
55
    self::assertTrue($instance ===
56
      $entity->loadRankingSystemService("Tfboe\FmLib\Service\RankingSystem\TestInterface"));
57
  }
58
//</editor-fold desc="Public Methods">
59
}