ComposerUpdateExtensionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAvailableVersionIsShown() 0 5 1
A testAvailableVersionIsNotShownWhenSameAsCurrent() 0 5 1
1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Tests\Extensions;
4
5
use BringYourOwnIdeas\Maintenance\Model\Package;
6
use BringYourOwnIdeas\UpdateChecker\Extensions\ComposerUpdateExtension;
7
use PHPUnit_Framework_TestCase;
8
use SilverStripe\Dev\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 static $required_extensions = [
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());
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());
35
    }
36
}
37