Completed
Push — master ( 8f233e...cb7239 )
by Tobias
45:50 queued 28:37
created

HappyrGoogleAnalyticsExtensionTest::testTrackerDisabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Tests\Unit\DependencyInjection;
4
5
use Happyr\GoogleAnalyticsBundle\DependencyInjection\HappyrGoogleAnalyticsExtension;
6
use Happyr\GoogleAnalyticsBundle\Service\DataFetcher;
7
use Happyr\GoogleAnalyticsBundle\Service\Tracker;
8
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class HappyrGoogleAnalyticsExtensionTest extends AbstractExtensionTestCase
12
{
13
    protected function getMinimalConfiguration()
14
    {
15
        return ['tracking_id' => 'id'];
16
    }
17
18
    protected function getContainerExtensions()
19
    {
20
        return [
21
            new HappyrGoogleAnalyticsExtension(),
22
        ];
23
    }
24
25
    public function testTracker()
26
    {
27
        $this->load();
28
        $this->assertContainerBuilderHasService('happyr.google_analytics.tracker', Tracker::class);
29
        $this->assertContainerBuilderHasServiceDefinitionWithArgument('happyr.google_analytics.tracker', 0, new Reference('happyr.google_analytics.http.client'));
30
    }
31
32
    public function testTrackerDisabled()
33
    {
34
        $this->load(['enabled' => false]);
35
        $this->assertContainerBuilderHasService('happyr.google_analytics.tracker', Tracker::class);
36
        $this->assertContainerBuilderHasServiceDefinitionWithArgument('happyr.google_analytics.tracker', 0, new Reference('happyr.google_analytics.http.void'));
37
    }
38
39
    public function testFetcher()
40
    {
41
        $this->load(['fetching' => ['client_service' => 'foo']]);
42
        $this->assertContainerBuilderHasService('happyr.google_analytics.data_fetcher', DataFetcher::class);
43
        $this->assertContainerBuilderHasServiceDefinitionWithArgument('happyr.google_analytics.data_fetcher', 1, new Reference('foo'));
44
    }
45
46
    public function testFetcherDisabled()
47
    {
48
        $this->load();
49
        $this->assertContainerBuilderNotHasService('happyr.google_analytics.data_fetcher');
50
    }
51
}
52