testBundleLoadThrowsExceptionUnlessApiKeyIsSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Sverraest\RevolutPHPBundle\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use RevolutPHP\Client;
7
use Sverraest\RevolutPHPBundle\DependencyInjection\SverraestRevolutPHPExtension;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\Yaml\Parser;
10
11
class SverraestRevolutPHPExtensionTest extends TestCase
12
{
13
    /**
14
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
15
     */
16
    public function testBundleLoadThrowsExceptionUnlessApiKeyIsSet()
17
    {
18
        $loader = new SverraestRevolutPHPExtension();
19
        $config = $this->getEmptyConfig();
20
        unset($config['api_key']);
21
        $loader->load([$config], new ContainerBuilder());
22
    }
23
24
    /**
25
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
26
     */
27
    public function testBundleLoadThrowsExceptionUnlessModeIsSet()
28
    {
29
        $loader = new SverraestRevolutPHPExtension();
30
        $config = $this->getEmptyConfig();
31
        unset($config['mode']);
32
        $loader->load([$config], new ContainerBuilder());
33
    }
34
35
    public function testServiceIsInstanceOfRevolutPHP()
36
    {
37
        $loader = new SverraestRevolutPHPExtension();
38
        $config = $this->getEmptyConfig();
39
        $loader->load([$config], new ContainerBuilder());
40
        $this->assertInstanceOf(Client::class, new Client($config['api_key'], $config['mode']));
41
    }
42
43
    /**
44
     * @return mixed
45
     */
46
    protected function getEmptyConfig()
47
    {
48
        $yaml = <<<EOF
49
api_key: foo
50
mode: sandbox
51
EOF;
52
        $parser = new Parser();
53
        return $parser->parse($yaml);
54
    }
55
}
56