ResultEntityTest::testResultB()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 10/1/17
7
 * Time: 12:52 PM
8
 */
9
10
namespace Tfboe\FmLib\Tests\Unit\Entity\Helpers;
11
12
use PHPUnit\Framework\MockObject\MockObject;
13
use Tfboe\FmLib\Entity\Helpers\Result;
14
use Tfboe\FmLib\Entity\Helpers\ResultEntity;
15
use Tfboe\FmLib\Exceptions\ValueNotValid;
16
use Tfboe\FmLib\Tests\Helpers\UnitTestCase;
17
18
/**
19
 * Class BaseEntityTest
20
 * @package Tfboe\FmLib\Tests\Unit\Entity\Helpers
21
 */
22
class ResultEntityTest extends UnitTestCase
23
{
24
//<editor-fold desc="Public Methods">
25
  /**
26
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::setPlayed
27
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::isPlayed
28
   */
29
  public function testPlayed()
30
  {
31
    $entity = $this->mock();
32
    $played = true;
33
    $entity->setPlayed($played);
0 ignored issues
show
Bug introduced by
The method setPlayed does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
34
    self::assertEquals($played, $entity->isPlayed());
0 ignored issues
show
Bug introduced by
The method isPlayed does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
35
  }
36
37
  /**
38
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::setResult
39
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::getResult
40
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
41
   */
42
  public function testResult()
43
  {
44
    $mock = $this->mock();
45
    /** @noinspection PhpUnhandledExceptionInspection */
46
    $mock->setResult(Result::DRAW);
0 ignored issues
show
Bug introduced by
The method setResult does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
47
    self::assertEquals(Result::DRAW, $mock->getResult());
0 ignored issues
show
Bug introduced by
The method getResult does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
48
  }
49
50
  /**
51
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::setResultA
52
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::getResultA
53
   */
54
  public function testResultA()
55
  {
56
    $entity = $this->mock();
57
    $res = 1;
58
    $entity->setResultA($res);
0 ignored issues
show
Bug introduced by
The method setResultA does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
59
    self::assertEquals($res, $entity->getResultA());
0 ignored issues
show
Bug introduced by
The method getResultA does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
60
  }
61
62
  /**
63
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::setResultB
64
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::getResultB
65
   */
66
  public function testResultB()
67
  {
68
    $entity = $this->mock();
69
    $res = 1;
70
    $entity->setResultB($res);
0 ignored issues
show
Bug introduced by
The method setResultB does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
71
    self::assertEquals($res, $entity->getResultB());
0 ignored issues
show
Bug introduced by
The method getResultB does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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...
72
  }
73
74
  /**
75
   * @covers \Tfboe\FmLib\Entity\Helpers\ResultEntity::setResult
76
   * @uses   \Tfboe\FmLib\Exceptions\ValueNotValid::__construct
77
   * @uses   \Tfboe\FmLib\Helpers\BasicEnum
78
   */
79
  public function testResultNotValidException()
80
  {
81
    $mock = $this->mock();
82
    $this->expectException(ValueNotValid::class);
83
    $this->expectExceptionMessage(
84
      'The following value is not valid: 100 in Tfboe\FmLib\Entity\Helpers\Result. Possible values: 0, 1, 2, 3, 4.');
85
    /** @noinspection PhpUnhandledExceptionInspection */
86
    $mock->setResult(100);
0 ignored issues
show
Bug introduced by
The method setResult does only exist in Tfboe\FmLib\Entity\Helpers\ResultEntity, 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
  }
88
//</editor-fold desc="Public Methods">
89
90
//<editor-fold desc="Private Methods">
91
  /**
92
   * @return MockObject|ResultEntity
93
   */
94
  private function mock(): MockObject
95
  {
96
    return $this->getMockForTrait(ResultEntity::class);
97
  }
98
//</editor-fold desc="Private Methods">
99
}