Completed
Push — master ( cae295...8cff55 )
by
unknown
13:42
created

WorkflowTest::createAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace OroCRM\Bundle\SalesBundle\Tests\Selenium\Sales;
4
5
use Oro\Bundle\TestFrameworkBundle\Test\Selenium2TestCase;
6
use OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages\Opportunities;
7
use OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages\SalesFunnels;
8
use OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages\SalesHelperTrait;
9
10
/**
11
 * Class WorkflowTest
12
 *
13
 * @package OroCRM\Bundle\SalesBundle\Tests\Selenium\Sales
14
 */
15
class WorkflowTest extends Selenium2TestCase
16
{
17
    use SalesHelperTrait;
18
    protected $address = array(
19
        'label' => 'Address Label',
20
        'street' => 'Address Street',
21
        'city' => 'Address City',
22
        'zipCode' => '10001',
23
        'country' => 'United States',
24
        'region' => 'New York'
25
    );
26
27 View Code Duplication
    public function testLeadWorkflowAsWon()
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...
28
    {
29
        $login = $this->login();
30
31
        $leadName = $this->createLead($this->address);
32
        $accountName = $this->createAccount();
33
        $customer = $this->createB2BCustomer($accountName);
34
35
        /** @var SalesFunnels $login */
36
        $id = $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
37
            ->assertTitle('All - Sales Processes - Sales')
38
            ->startFromLead()
39
            ->assertTitle('New Sales Process - Sales Processes')
40
            ->selectEntity('Lead', $leadName)
41
            ->submit()
42
            ->openWorkflow('OroCRM\Bundle\SalesBundle')
43
            ->checkStep('New Lead')
44
            ->qualify()
45
            ->setB2BCustomer($customer)
46
            ->submit()
47
            ->checkStep('New Opportunity')
48
            ->develop()
49
            ->setBudget('100')
50
            ->setProbability('100')
51
            ->setCustomerNeed('Some customer need')
52
            ->setSolution('Some solution')
53
            ->submit()
54
            ->checkStep('Developed Opportunity')
55
            ->closeAsWon()
56
            ->setCloseRevenue('100')
57
            ->submit()
58
            ->checkStep('Won Opportunity')
59
            ->getId();
60
61
        /** @var Opportunities $login*/
62
        $login->openOpportunities('OroCRM\Bundle\SalesBundle')
0 ignored issues
show
Documentation Bug introduced by
The method openOpportunities does not exist on object<OroCRM\Bundle\Sal...ium\Pages\SalesFunnels>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
63
            ->filterBy('Opportunity name', $leadName)
64
            ->open(array($leadName))
65
            ->checkStatus('Won');
66
67
        return $id;
68
    }
69
70 View Code Duplication
    public function testLeadWorkflowAsLost()
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...
71
    {
72
        $login = $this->login();
73
74
        $leadName = $this->createLead($this->address);
75
        $accountName = $this->createAccount();
76
        $customer = $this->createB2BCustomer($accountName);
77
78
        /** @var SalesFunnels $login */
79
        $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
80
            ->assertTitle('All - Sales Processes - Sales')
81
            ->startFromLead()
82
            ->assertTitle('New Sales Process - Sales Processes')
83
            ->selectEntity('Lead', $leadName)
84
            ->submit()
85
            ->openWorkflow('OroCRM\Bundle\SalesBundle')
86
            ->checkStep('New Lead')
87
            ->qualify()
88
            ->setB2BCustomer($customer)
89
            ->submit()
90
            ->checkStep('New Opportunity')
91
            ->develop()
92
            ->setBudget('100')
93
            ->setProbability('100')
94
            ->setCustomerNeed('Some customer need')
95
            ->setSolution('Some solution')
96
            ->submit()
97
            ->checkStep('Developed Opportunity')
98
            ->closeAsLost()
99
            ->setCloseReason('Cancelled')
100
            ->submit()
101
            ->checkStep('Lost Opportunity');
102
        /** @var  Opportunities $login */
103
        $login->openOpportunities('OroCRM\Bundle\SalesBundle')
104
            ->filterBy('Opportunity name', $leadName)
105
            ->open(array($leadName))
106
            ->checkStatus('Lost');
107
    }
108
109
    /**
110
     * @param $funnelId
111
     * @depends testLeadWorkflowAsWon
112
     * @return string
113
     */
114 View Code Duplication
    public function testLeadWorkflowReopen($funnelId)
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...
115
    {
116
        /** @var SalesFunnels $login */
117
        $login = $this->login();
118
        $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
119
            ->filterBy('Sales', $funnelId, 'equals')
120
            ->open(array($funnelId))
121
            ->assertTitle('Sales Process #' . $funnelId . ' - Sales Processes - Sales')
122
            ->reopen()
123
            ->checkStep('New Opportunity');
124
    }
125
126
    public function testLeadWorkflowReactivate()
127
    {
128
        $login = $this->login();
129
130
        $leadName = $this->createLead($this->address);
131
132
        /** @var SalesFunnels $login */
133
        $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
134
            ->startFromLead()
135
            ->selectEntity('Lead', $leadName)
136
            ->submit()
137
            ->openWorkflow('OroCRM\Bundle\SalesBundle')
138
            ->checkStep('New Lead')
139
            ->disqualify()
140
            ->checkStep('Disqualified Lead')
141
            ->reactivate()
142
            ->checkStep('New Lead');
143
    }
144
145 View Code Duplication
    public function testOpportunityWorkflowAsWon()
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...
146
    {
147
        $login = $this->login();
148
149
        $opportunity = $this->createOpportunity();
150
151
        /** @var SalesFunnels $login */
152
        $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
0 ignored issues
show
Documentation Bug introduced by
The method setChannel does not exist on object<OroCRM\Bundle\Sal...nium\Pages\SalesFunnel>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
153
            ->assertTitle('All - Sales Processes - Sales')
154
            ->startFromOpportunity()
155
            ->assertTitle('New Sales Process - Sales Processes')
156
            ->setChannel($opportunity['channel'])
157
            ->selectEntity('Opportunity', $opportunity['opportunity'])
158
            ->submit()
159
            ->openWorkflow('OroCRM\Bundle\SalesBundle')
160
            ->checkStep('New Opportunity')
161
            ->develop()
162
            ->setBudget('100')
163
            ->setProbability('100')
164
            ->setCustomerNeed('Some customer need')
165
            ->setSolution('Some solution')
166
            ->submit()
167
            ->checkStep('Developed Opportunity')
168
            ->closeAsWon()
169
            ->setCloseRevenue('100')
170
            ->submit()
171
            ->checkStep('Won Opportunity');
172
        /** @var  Opportunities $login */
173
        $login->openOpportunities('OroCRM\Bundle\SalesBundle')
174
            ->filterBy('Opportunity name', $opportunity['opportunity'])
175
            ->open(array($opportunity['opportunity']))
176
            ->checkStatus('Won');
177
    }
178
179 View Code Duplication
    public function testOpportunityWorkflowAsLost()
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...
180
    {
181
        $login = $this->login();
182
183
        $opportunity = $this->createOpportunity();
184
185
        /** @var SalesFunnels $login */
186
        $id = $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
0 ignored issues
show
Documentation Bug introduced by
The method setChannel does not exist on object<OroCRM\Bundle\Sal...nium\Pages\SalesFunnel>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
187
            ->assertTitle('All - Sales Processes - Sales')
188
            ->startFromOpportunity()
189
            ->assertTitle('New Sales Process - Sales Processes')
190
            ->setChannel($opportunity['channel'])
191
            ->selectEntity('Opportunity', $opportunity['opportunity'])
192
            ->submit()
193
            ->openWorkflow('OroCRM\Bundle\SalesBundle')
194
            ->checkStep('New Opportunity')
195
            ->develop()
196
            ->setBudget('100')
197
            ->setProbability('100')
198
            ->setCustomerNeed('Some customer need')
199
            ->setSolution('Some solution')
200
            ->submit()
201
            ->checkStep('Developed Opportunity')
202
            ->closeAsLost()
203
            ->setCloseReason('Cancelled')
204
            ->submit()
205
            ->checkStep('Lost Opportunity')
206
            ->getId();
207
208
        /** @var Opportunities $login*/
209
        $login->openOpportunities('OroCRM\Bundle\SalesBundle')
0 ignored issues
show
Documentation Bug introduced by
The method openOpportunities does not exist on object<OroCRM\Bundle\Sal...ium\Pages\SalesFunnels>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
210
            ->filterBy('Opportunity name', $opportunity['opportunity'])
211
            ->open(array($opportunity['opportunity']))
212
            ->checkStatus('Lost');
213
214
        return $id;
215
    }
216
217
    /**
218
     * @param $funnelId
219
     * @depends testOpportunityWorkflowAsLost
220
     * @return string
221
     */
222 View Code Duplication
    public function testOpportunityWorkflowReopen($funnelId)
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...
223
    {
224
        $login = $this->login();
225
        /** @var SalesFunnels $login */
226
        $login->openSalesFunnels('OroCRM\Bundle\SalesBundle')
227
            ->filterBy('Sales', $funnelId, 'equals')
228
            ->open(array($funnelId))
229
            ->assertTitle('Sales Process #' . $funnelId . ' - Sales Processes - Sales')
230
            ->reopen()
231
            ->checkStep('New Opportunity');
232
    }
233
}
234