Completed
Push — 1.10 ( 3f8f95...f007bc )
by
unknown
09:16
created

OpportunityByStatusTest::getConfigureDialog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
namespace OroCRM\Bundle\SalesBundle\Tests\Functional\Dashboard;
3
4
use Oro\Bundle\DashboardBundle\Entity\Widget;
5
use Oro\Bundle\DashboardBundle\Tests\Functional\AbstractWidgetTestCase;
6
use Oro\Bundle\FilterBundle\Form\Type\Filter\AbstractDateFilterType;
7
8
/**
9
 * @dbIsolationPerTest
10
 */
11
class OpportunityByStatusTest extends AbstractWidgetTestCase
12
{
13
    /** @var  Widget */
14
    protected $widget;
15
16 View Code Duplication
    public function setUp()
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...
17
    {
18
        $this->initClient(
19
            ['debug' => false],
20
            array_merge($this->generateBasicAuthHeader(), array('HTTP_X-CSRF-Header' => 1))
21
        );
22
        $this->loadFixtures([
23
            'OroCRM\Bundle\SalesBundle\Tests\Functional\Fixture\LoadOpportunityByStatusWidgetFixture'
24
        ]);
25
        $this->widget = $this->getReference('widget_opportunity_by_status');
26
    }
27
28
    public function testGetWidgetConfigureDialog()
29
    {
30
        $this->getConfigureDialog();
31
    }
32
33
    /**
34
     * @depends      testGetWidgetConfigureDialog
35
     * @dataProvider widgetProvider
36
     * @param $requestData
37
     */
38 View Code Duplication
    public function testDateRangeBetweenFilter($requestData)
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...
39
    {
40
        $this->configureWidget($this->widget, $requestData['widgetConfig']);
41
        $crawler = $this->client->request(
42
            'GET',
43
            $this->getUrl(
44
                'orocrm_sales_dashboard_opportunity_by_state_chart',
45
                [
46
                    'widget' => 'opportunities_by_state',
47
                    '_widgetId' => $this->widget->getId()
48
                ]
49
            )
50
        );
51
        $response = $this->client->getResponse();
52
        $this->assertEquals($response->getStatusCode(), 200, "Failed in getting widget view !");
53
        $this->assertNotEmpty($crawler->html());
54
        $data = $this->getChartData($crawler);
55
        $this->assertEquals('Open', $data[0]->label);
56
        $this->assertEquals($requestData['expectedResultCount'], $data[0]->value);
57
    }
58
59 View Code Duplication
    protected function getConfigureDialog()
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...
60
    {
61
        $this->client->request(
62
            'GET',
63
            $this->getUrl(
64
                'oro_dashboard_configure',
65
                ['id' => $this->widget->getId(), '_widgetContainer' => 'dialog']
66
            )
67
        );
68
        $response = $this->client->getResponse();
69
        $this->assertEquals($response->getStatusCode(), 200, 'Failed in getting configure widget dialog window !');
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function widgetProvider()
76
    {
77
        return [
78
            'Opportunity by status with between date range filter' => [
79
                [
80
                    'widgetConfig' => [
81
                        'opportunities_by_state[dateRange][part]'   => 'value',
82
                        'opportunities_by_state[dateRange][type]'   => AbstractDateFilterType::TYPE_BETWEEN,
83
                        'opportunities_by_state[dateRange][value][start]'  => '2016-12-28',
84
                        'opportunities_by_state[dateRange][value][end]'    => '2016-12-29',
85
                        'opportunities_by_state[useQuantityAsData]' => 1
86
                    ],
87
                    'expectedResultCount' => 2
88
                ],
89
            ],
90
            'Opportunity by status with this month date range filter'  => [
91
                [
92
                    'widgetConfig' => [
93
                        'opportunities_by_state[dateRange][part]'   => 'value',
94
                        'opportunities_by_state[dateRange][type]'   => AbstractDateFilterType::TYPE_THIS_MONTH,
95
                        'opportunities_by_state[useQuantityAsData]' => 1
96
                    ],
97
                    'expectedResultCount' => 1
98
                ],
99
            ],
100
            'Opportunity by status with this all time date range filter' => [
101
                [
102
                    'widgetConfig' => [
103
                        'opportunities_by_state[dateRange][part]'   => 'value',
104
                        'opportunities_by_state[dateRange][type]'   => AbstractDateFilterType::TYPE_ALL_TIME,
105
                        'opportunities_by_state[useQuantityAsData]' => 1
106
                    ],
107
                    'expectedResultCount' => 5
108
                ],
109
            ],
110
        ];
111
    }
112
}
113