Completed
Push — master ( 580007...3ce141 )
by
unknown
9s
created

tests/Extensions/ComposerUpdateExtensionTest.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Tests\Extensions;
4
5
use BringYourOwnIdeas\UpdateChecker\Extensions\ComposerUpdateExtension;
6
use Package;
7
use PHPUnit_Framework_TestCase;
8
use SapphireTest;
9
10
/**
11
 * @mixin PHPUnit_Framework_TestCase
12
 */
13
class ComposerUpdateExtensionTest extends SapphireTest
14
{
15
    protected static $fixture_file = 'ComposerUpdateExtensionTest.yml';
16
17
    protected $requiredExtensions = [
18
        Package::class => [
19
            ComposerUpdateExtension::class,
20
        ],
21
    ];
22
23
    public function testAvailableVersionIsNotShownWhenSameAsCurrent()
24
    {
25
        /** @var Package|ComposerUpdateExtension $package */
26
        $package = $this->objFromFixture(Package::class, 'up_to_date');
27
        $this->assertEmpty($package->getAvailableVersion());
0 ignored issues
show
The method getAvailableVersion does only exist in BringYourOwnIdeas\Update...ComposerUpdateExtension, but not in Package.

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...
The method assertEmpty() does not seem to exist on object<BringYourOwnIdeas...serUpdateExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
    }
29
30
    public function testAvailableVersionIsShown()
31
    {
32
        /** @var Package|ComposerUpdateExtension $package */
33
        $package = $this->objFromFixture(Package::class, 'has_available_update');
34
        $this->assertSame('1.2.1', $package->getAvailableVersion());
0 ignored issues
show
The method getAvailableVersion does only exist in BringYourOwnIdeas\Update...ComposerUpdateExtension, but not in Package.

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...
The method assertSame() does not seem to exist on object<BringYourOwnIdeas...serUpdateExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
    }
36
}
37