Completed
Push — 1.10 ( 93e51c...7f32fb )
by
unknown
11:06
created

getTimezone()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Tests\Functional\Provider;
4
5
use OroCRM\Bundle\MagentoBundle\Tests\Functional\DataFixtures\LoadTrackingWebsiteToMagentoChannel;
6
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;
7
use Oro\Bundle\TrackingBundle\Tests\Functional\DataFixtures\LoadTrackingVisits;
8
use OroCRM\Bundle\MagentoBundle\Provider\MagentoBigNumberProvider;
9
use OroCRM\Bundle\MagentoBundle\Provider\PrecalculatedMagentoBigNumberProvider;
10
11
/**
12
 * @dbIsolation
13
 */
14
class PrecalculatedMagentoBigNumberProviderTest extends WebTestCase
15
{
16
    /**
17
     * @var PrecalculatedMagentoBigNumberProvider
18
     */
19
    private $provider;
20
21
    /**
22
     * @var MagentoBigNumberProvider
23
     */
24
    private $originalProvider;
25
26
    protected function setUp()
27
    {
28
        $this->initClient([], $this->generateBasicAuthHeader());
29
        $this->loadFixtures([
30
            LoadTrackingVisits::class,
31
            LoadTrackingWebsiteToMagentoChannel::class
32
        ]);
33
        $this->provider = $this->getContainer()->get('orocrm_magento.provider.big_number');
34
        $this->originalProvider = new MagentoBigNumberProvider(
35
            $this->getContainer()->get('doctrine'),
36
            $this->getContainer()->get('oro_security.acl_helper'),
37
            $this->getContainer()->get('oro_dashboard.provider.big_number.date_helper'),
38
            $this->getContainer()->get('oro_channel.entity.repository.channel')
39
        );
40
    }
41
42
    public function testDecoration()
43
    {
44
        $this->assertInstanceOf(PrecalculatedMagentoBigNumberProvider::class, $this->provider);
45
    }
46
47
    public function testGetVisitedCount()
48
    {
49
        $timezone = $this->getTimezone();
50
        $from = new \DateTime('2012-01-11', $timezone);
51
        $to = new \DateTime('2013-01-13', $timezone);
52
        $dateRange = ['start' => $from, 'end' => $to];
53
54
        $original = $this->originalProvider->getSiteVisitsValues($dateRange);
55
        $precalculated = $this->provider->getSiteVisitsValues($dateRange);
56
57
        $this->assertEquals($original, $precalculated);
58
    }
59
60
    /**
61
     * @return \DateTimeZone
62
     */
63 View Code Duplication
    private function getTimezone()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $configManager = $this->getContainer()->get('oro_config.global');
66
67
        $timezoneName = $configManager->get('oro_locale.timezone');
68
        if (!$timezoneName) {
69
            $timezoneName = 'UTC';
70
        }
71
        return new \DateTimeZone($timezoneName);
72
    }
73
}
74