Completed
Push — master ( 685463...a3ac99 )
by Benedikt
13:47
created

PhaseTest::phase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
rs 10
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 Doctrine\Common\Collections\Collection;
14
use PHPUnit\Framework\MockObject\MockObject;
15
use Tfboe\FmLib\Entity\CompetitionInterface;
16
use Tfboe\FmLib\Entity\MatchInterface;
17
use Tfboe\FmLib\Entity\PhaseInterface;
18
use Tfboe\FmLib\Entity\QualificationSystem;
19
use Tfboe\FmLib\Entity\Ranking;
20
use Tfboe\FmLib\Helpers\Level;
21
use Tfboe\FmLib\TestHelpers\UnitTestCase;
22
23
24
/** @noinspection PhpMultipleClassesDeclarationsInOneFile */
25
abstract class Phase implements PhaseInterface
26
{
27
  use \Tfboe\FmLib\Entity\Traits\Phase;
28
}
29
30
/** @noinspection PhpMultipleClassesDeclarationsInOneFile */
31
32
/**
33
 * Class TournamentTest
34
 * @package Tfboe\FmLib\Tests\Unit\Entity
35
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
36
 */
37
class PhaseTest extends UnitTestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
38
{
39
//<editor-fold desc="Public Methods">
40
  /**
41
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::setCompetition
42
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getCompetition
43
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getParent
44
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::getPhaseNumber
45
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::setPhaseNumber
46
   */
47
  public function testCompetitionAndParent()
48
  {
49
    $phase = $this->phase();
50
    $competition = $this->createStub(CompetitionInterface::class, ['getPhases' => new ArrayCollection()]);
51
    $phase->setPhaseNumber(1);
0 ignored issues
show
Bug introduced by
The method setPhaseNumber does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
52
    /** @var CompetitionInterface $competition */
53
    $phase->setCompetition($competition);
0 ignored issues
show
Bug introduced by
The method setCompetition does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
54
    self::assertEquals($competition, $phase->getCompetition());
0 ignored issues
show
Bug introduced by
The method getCompetition does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
55
    self::assertEquals(1, $phase->getCompetition()->getPhases()->count());
56
    self::assertEquals($phase, $phase->getCompetition()->getPhases()[$phase->getPhaseNumber()]);
0 ignored issues
show
Bug introduced by
The method getPhaseNumber does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
57
    self::assertEquals($phase->getCompetition(), $phase->getParent());
0 ignored issues
show
Bug introduced by
The method getParent does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
58
59
    $competition2 = $this->createStub(CompetitionInterface::class, ['getPhases' => new ArrayCollection()]);
60
61
    /** @var CompetitionInterface $competition2 */
62
    $phase->setCompetition($competition2);
63
    self::assertEquals($competition2, $phase->getCompetition());
64
    self::assertEquals(1, $phase->getCompetition()->getPhases()->count());
65
    self::assertEquals(0, $competition->getPhases()->count());
66
    self::assertEquals($phase, $phase->getCompetition()->getPhases()[$phase->getPhaseNumber()]);
67
    self::assertEquals($phase->getCompetition(), $phase->getParent());
68
  }
69
70
  /**
71
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::init
72
   * @uses   \Tfboe\FmLib\Entity\Helpers\NameEntity::getName
73
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::getPostQualifications
74
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::getPreQualifications
75
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::getRankings
76
   */
77 View Code Duplication
  public function testInit()
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...
78
  {
79
    $phase = $this->phase();
80
    $phase->init();
0 ignored issues
show
Bug introduced by
The method init does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
81
    self::assertEquals('', $phase->getName());
0 ignored issues
show
Bug introduced by
The method getName does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
82
    self::assertInstanceOf(Collection::class, $phase->getPostQualifications());
0 ignored issues
show
Bug introduced by
The method getPostQualifications does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
83
    self::assertEquals(0, $phase->getPostQualifications()->count());
84
    self::assertInstanceOf(Collection::class, $phase->getPreQualifications());
0 ignored issues
show
Bug introduced by
The method getPreQualifications does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
85
    self::assertEquals(0, $phase->getPreQualifications()->count());
86
    self::assertInstanceOf(Collection::class, $phase->getRankings());
0 ignored issues
show
Bug introduced by
The method getRankings does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
87
    self::assertEquals(0, $phase->getRankings()->count());
88
  }
89
90
  /**
91
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getLevel
92
   */
93
  public function testLevel()
94
  {
95
    self::assertEquals(Level::PHASE, $this->phase()->getLevel());
0 ignored issues
show
Bug introduced by
The method getLevel does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
96
  }
97
98
  /**
99
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getMatches
100
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getChildren
101
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::init
102
   */
103 View Code Duplication
  public function testMatchesAndChildren()
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...
104
  {
105
    $phase = $this->phase();
106
    $phase->init();
0 ignored issues
show
Bug introduced by
The method init does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
107
    $match = $this->createStub(MatchInterface::class, ['getMatchNumber' => 1]);
108
    self::assertEquals($phase->getMatches(), $phase->getChildren());
0 ignored issues
show
Bug introduced by
The method getMatches does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
Bug introduced by
The method getChildren does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
109
    /** @var MatchInterface $match */
110
    $phase->getMatches()->set($match->getMatchNumber(), $match);
111
    self::assertEquals(1, $phase->getMatches()->count());
112
    self::assertEquals($match, $phase->getMatches()[1]);
113
    self::assertEquals($phase->getMatches(), $phase->getChildren());
114
  }
115
116
  /**
117
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getPostQualifications
118
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::init
119
   * @uses   \Tfboe\FmLib\Entity\QualificationSystem
120
   * @uses   \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct
121
   */
122 View Code Duplication
  public function testNextQualificationSystems()
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...
123
  {
124
    $phase = $this->phase();
125
    $phase->init();
0 ignored issues
show
Bug introduced by
The method init does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
126
    $qualificationSystem = new QualificationSystem();
127
    $qualificationSystem->setPreviousPhase($phase);
0 ignored issues
show
Bug introduced by
It seems like $phase defined by $this->phase() on line 124 can also be of type object<PHPUnit\Framework\MockObject\MockObject>; however, Tfboe\FmLib\Entity\Quali...tem::setPreviousPhase() does only seem to accept object<Tfboe\FmLib\Entity\PhaseInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
128
    self::assertEquals(1, $phase->getPostQualifications()->count());
0 ignored issues
show
Bug introduced by
The method getPostQualifications does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
129
    self::assertEquals($qualificationSystem, $phase->getPostQualifications()[0]);
130
  }
131
132
  /**
133
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::setPhaseNumber
134
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getPhaseNumber
135
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getLocalIdentifier
136
   */
137
  public function testPhaseNumberAndLocalIdentifier()
138
  {
139
    $phase = $this->phase();
140
    $phase->setPhaseNumber(5);
0 ignored issues
show
Bug introduced by
The method setPhaseNumber does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
141
    self::assertEquals(5, $phase->getPhaseNumber());
0 ignored issues
show
Bug introduced by
The method getPhaseNumber does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
142
    self::assertEquals($phase->getPhaseNumber(), $phase->getLocalIdentifier());
0 ignored issues
show
Bug introduced by
The method getLocalIdentifier does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
143
  }
144
145
  /**
146
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getPreQualifications
147
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::init
148
   * @uses   \Tfboe\FmLib\Entity\QualificationSystem
149
   */
150 View Code Duplication
  public function testPreviousQualificationSystems()
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...
151
  {
152
    $phase = $this->phase();
153
    $phase->init();
0 ignored issues
show
Bug introduced by
The method init does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
154
    $qualificationSystem = new QualificationSystem();
155
    $qualificationSystem->setNextPhase($phase);
0 ignored issues
show
Bug introduced by
It seems like $phase defined by $this->phase() on line 152 can also be of type object<PHPUnit\Framework\MockObject\MockObject>; however, Tfboe\FmLib\Entity\Quali...nSystem::setNextPhase() does only seem to accept object<Tfboe\FmLib\Entity\PhaseInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
156
    self::assertEquals(1, $phase->getPreQualifications()->count());
0 ignored issues
show
Bug introduced by
The method getPreQualifications does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
157
    self::assertEquals($qualificationSystem, $phase->getPreQualifications()[0]);
158
  }
159
160
  /**
161
   * @covers \Tfboe\FmLib\Entity\Traits\Phase::getRankings
162
   * @uses   \Tfboe\FmLib\Entity\Traits\Phase::init
163
   * @uses   \Tfboe\FmLib\Entity\Ranking
164
   * @uses   \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct
165
   */
166 View Code Duplication
  public function testRankings()
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...
167
  {
168
    $phase = $this->phase();
169
    $phase->init();
0 ignored issues
show
Bug introduced by
The method init does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
170
    $ranking = new Ranking();
171
    $ranking->setUniqueRank(1);
172
    $phase->getRankings()->set($ranking->getUniqueRank(), $ranking);
0 ignored issues
show
Bug introduced by
The method getRankings does only exist in Tfboe\FmLib\Tests\Unit\Entity\Traits\Phase, but not in PHPUnit\Framework\MockObject\MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
173
    self::assertEquals(1, $phase->getRankings()->count());
174
    self::assertEquals($ranking, $phase->getRankings()[1]);
175
  }
176
//</editor-fold desc="Public Methods">
177
178
//<editor-fold desc="Private Methods">
179
  /**
180
   * @return Phase|MockObject a new phase
181
   */
182
  private function phase(): MockObject
183
  {
184
    return $this->getMockForAbstractClass(Phase::class);
185
  }
186
//</editor-fold desc="Private Methods">
187
}