UpdateManagerSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
rs 9.4285
1
<?php
2
3
namespace spec\SWP\UpdaterBundle\Manager;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
8
class UpdateManagerSpec extends ObjectBehavior
9
{
10
    function it_is_initializable()
11
    {
12
        $this->shouldHaveType('SWP\UpdaterBundle\Manager\UpdateManager');
13
        $this->shouldBeAnInstanceOf('SWP\UpdaterBundle\Manager\AbstractManager');
14
    }
15
16
    function let($client, $version)
17
    {
18
        $options = array(
19
            'temp_dir' => 'some/temp/dir',
20
            'target_dir' => 'some/target/dir'
21
        );
22
23
        $client->beADoubleOf('SWP\UpdaterBundle\Client\ClientInterface');
24
        $version->beADoubleOf('SWP\UpdaterBundle\Version\VersionInterface');
25
        $this->beConstructedWith($client, $version, $options);
26
    }
27
28
    function it_should_throw_NotFoundHttpException_when_no_updates_found($client)
29
    {
30
        $client->call(Argument::Any(), Argument::Type('array'))->willReturn('{}');
31
32
        $this->shouldThrow('\Symfony\Component\HttpKernel\Exception\NotFoundHttpException')
33
            ->duringGetAvailableUpdates();
34
    }
35
36
    function it_gets_available_updates($client)
37
    {
38
        $fakeResponse = '{"_items":{"core":[{"version":"0.2.1","changelog":["commit1"]},{"version":"0.2.0"}]}}';
39
        $client->call(Argument::Any(), Argument::Type('array'))->willReturn($fakeResponse);
40
41
        $result = $this->getAvailableUpdates();
42
        $result->shouldHaveCount(1);
43
        $result->shouldBeArray();
44
        foreach ($result['core'] as $package) {
45
            $package->shouldHaveType('SWP\UpdaterBundle\Model\UpdatePackage');
46
        }
47
    }
48
}
49