Completed
Push — master ( f1bd54...a11f6e )
by Tobias
02:37
created

ConfigTest::testGeneric()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 0
dl 0
loc 46
rs 8.9411
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Ekino New Relic bundle.
5
 *
6
 * (c) Ekino - Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ekino\Bundle\NewRelicBundle\Tests\NewRelic;
13
14
use Ekino\Bundle\NewRelicBundle\NewRelic\Config;
15
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class ConfigTest extends TestCase
18
{
19
    public function testGeneric()
20
    {
21
        $newRelic = new Config('Ekino', 'XXX');
22
23
        $this->assertSame('Ekino', $newRelic->getName());
24
        $this->assertSame('XXX', $newRelic->getApiKey());
25
26
        $this->assertEmpty($newRelic->getCustomEvents());
27
        $this->assertEmpty($newRelic->getCustomMetrics());
28
        $this->assertEmpty($newRelic->getCustomParameters());
29
30
        $newRelic->addCustomEvent('WidgetSale', ['color' => 'red', 'weight' => 12.5]);
31
        $newRelic->addCustomEvent('WidgetSale', ['color' => 'blue', 'weight' => 12.5]);
32
33
        $expected = [
34
            'WidgetSale' => [
35
                [
36
                    'color' => 'red',
37
                    'weight' => 12.5,
38
                ],
39
                [
40
                    'color' => 'blue',
41
                    'weight' => 12.5,
42
                ],
43
            ],
44
        ];
45
46
        $this->assertSame($expected, $newRelic->getCustomEvents());
47
48
        $newRelic->addCustomMetric('foo', 4.2);
49
        $newRelic->addCustomMetric('asd', 1);
50
51
        $expected = [
52
            'foo' => 4.2,
53
            'asd' => 1.0,
54
        ];
55
56
        $this->assertSame($expected, $newRelic->getCustomMetrics());
57
58
        $newRelic->addCustomParameter('param1', 1);
59
60
        $expected = [
61
            'param1' => 1,
62
        ];
63
64
        $this->assertSame($expected, $newRelic->getCustomParameters());
65
    }
66
67
    public function testDefaults()
68
    {
69
        $newRelic = new Config('', '');
70
71
        $this->assertNotNull($newRelic->getName());
72
        $this->assertSame(ini_get('newrelic.appname') ?: '', $newRelic->getName());
73
74
        $this->assertNotNull($newRelic->getLicenseKey());
75
        $this->assertSame(ini_get('newrelic.license') ?: '', $newRelic->getLicenseKey());
76
    }
77
}
78