Completed
Push — master ( 715718...c4fc6e )
by Benedikt
02:30
created

QualificationSystemTest::testPreviousPhase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
dl 20
loc 20
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
rs 9.4285
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 10/1/17
7
 * Time: 1:11 PM
8
 */
9
10
namespace Tfboe\FmLib\Tests\Unit\Entity\Traits;
11
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Tfboe\FmLib\Entity\PhaseInterface;
14
use Tfboe\FmLib\Entity\QualificationSystemInterface;
15
use Tfboe\FmLib\Tests\Entity\QualificationSystem;
16
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
17
18
/**
19
 * Class TournamentTest
20
 * @package Tfboe\FmLib\Tests\Unit\Entity
21
 */
22
class QualificationSystemTest extends UnitTestCase
23
{
24
//<editor-fold desc="Public Methods">
25
  /**
26
   * @covers \Tfboe\FmLib\Entity\Traits\QualificationSystem::setNextPhase
27
   * @covers \Tfboe\FmLib\Entity\Traits\QualificationSystem::getNextPhase
28
   * @uses   \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct
29
   */
30 View Code Duplication
  public function testNextPhase()
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...
31
  {
32
    $system = $this->system();
33
    $phase = $this->createStub(PhaseInterface::class, ['getPreQualifications' => new ArrayCollection()]);
34
35
    /** @var PhaseInterface $phase */
36
    $system->setNextPhase($phase);
37
    self::assertEquals($phase, $system->getNextPhase());
38
    self::assertEquals(1, $system->getNextPhase()->getPreQualifications()->count());
39
    self::assertEquals($system, $system->getNextPhase()->getPreQualifications()[0]);
40
41
    $phase2 = $this->createStub(PhaseInterface::class, ['getPreQualifications' => new ArrayCollection()]);
42
43
    /** @var PhaseInterface $phase2 */
44
    $system->setNextPhase($phase2);
45
    self::assertEquals($phase2, $system->getNextPhase());
46
    self::assertEquals(1, $system->getNextPhase()->getPreQualifications()->count());
47
    self::assertEquals(0, $phase->getPreQualifications()->count());
48
    self::assertEquals($system, $system->getNextPhase()->getPreQualifications()[0]);
49
  }
50
51
  /**
52
   * @covers \Tfboe\FmLib\Entity\Traits\QualificationSystem::setPreviousPhase
53
   * @covers \Tfboe\FmLib\Entity\Traits\QualificationSystem::getPreviousPhase
54
   * @uses   \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct
55
   */
56 View Code Duplication
  public function testPreviousPhase()
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...
57
  {
58
    $system = $this->system();
59
    $phase = $this->createStub(PhaseInterface::class, ['getPostQualifications' => new ArrayCollection()]);
60
61
    /** @var PhaseInterface $phase */
62
    $system->setPreviousPhase($phase);
63
    self::assertEquals($phase, $system->getPreviousPhase());
64
    self::assertEquals(1, $system->getPreviousPhase()->getPostQualifications()->count());
65
    self::assertEquals($system, $system->getPreviousPhase()->getPostQualifications()[0]);
66
67
    $phase2 = $this->createStub(PhaseInterface::class, ['getPostQualifications' => new ArrayCollection()]);
68
69
    /** @var PhaseInterface $phase2 */
70
    $system->setPreviousPhase($phase2);
71
    self::assertEquals($phase2, $system->getPreviousPhase());
72
    self::assertEquals(1, $system->getPreviousPhase()->getPostQualifications()->count());
73
    self::assertEquals(0, $phase->getPostQualifications()->count());
74
    self::assertEquals($system, $system->getPreviousPhase()->getPostQualifications()[0]);
75
  }
76
//</editor-fold desc="Public Methods">
77
78
//<editor-fold desc="Private Methods">
79
  /**
80
   * @return QualificationSystemInterface a new qualification system
81
   */
82
  private function system(): QualificationSystemInterface
83
  {
84
    return new QualificationSystem();
85
  }
86
//</editor-fold desc="Private Methods">
87
}