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

SalesHelperTrait::createAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 14
loc 14
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages;
4
5
use OroCRM\Bundle\AccountBundle\Tests\Selenium\Pages\Accounts;
6
use OroCRM\Bundle\ChannelBundle\Tests\Selenium\Pages\Channels;
7
8
trait SalesHelperTrait
9
{
10
    /**
11
     * @param array $address
12
     * @return string
13
     */
14
    protected function createLead($address)
15
    {
16
        $name = 'Lead_' . mt_rand();
17
        /** @var Leads $page */
18
        $page = new Leads($this, false);
19
        $page->openLeads('OroCRM\Bundle\SalesBundle')
20
            ->add()
21
            ->setName($name)
22
            ->setFirstName($name . '_first_name')
23
            ->setLastName($name . '_last_name')
24
            ->setJobTitle('Manager')
25
            ->setPhone('712-566-3002')
26
            ->setEmail($name . '@mail.com')
27
            ->setCompany('Some Company')
28
            ->setWebsite('http://www.orocrm.com')
29
            ->setEmployees('100')
30
            ->setOwner('admin')
31
            ->setAddress($address)
32
            ->save();
33
34
        return $name;
35
    }
36
37
    /**
38
     * @return string
39
     */
40 View Code Duplication
    public function createChannel()
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...
41
    {
42
        $name = 'Channel_' . mt_rand();
43
44
        /** @var Channels $page */
45
        $page = new Channels($this, false);
46
        $page->openChannels('OroCRM\Bundle\ChannelBundle')
47
            ->assertTitle('All - Channels - System')
48
            ->add()
49
            ->assertTitle('Create Channel - Channels - System')
50
            ->setType('Sales')
51
            ->setName($name)
52
            ->setStatus('Active')
53
            ->save()
54
            ->assertMessage('Channel saved');
55
56
        return $name;
57
    }
58
59
60
    /**
61
     * @return array
62
     */
63
    protected function createOpportunity()
64
    {
65
        $opportunityName = 'Opportunity_'.mt_rand();
66
        $channelName = $this->createChannel();
67
        $accountName = $this->createAccount();
68
        $customer = $this->createB2BCustomer($accountName, $channelName);
69
70
        /** @var Opportunities $page */
71
        $page = new Opportunities($this, false);
72
        $page->openOpportunities('OroCRM\Bundle\SalesBundle')
73
            ->add()
74
            ->setName($opportunityName)
75
            ->setChannel($channelName)
76
            ->setB2BCustomer($customer)
77
            ->setProbability('50')
78
            ->seBudget('100')
79
            ->setCustomerNeed('50')
80
            ->setProposedSolution('150')
81
            ->setCloseRevenue('200')
82
            ->setCloseDate('Sep 26, 2013')
83
            ->setOwner('admin')
84
            ->save()
85
            ->assertMessage('Opportunity saved')
86
            ->toGrid()
87
            ->assertTitle('All - Opportunities - Sales');
88
89
        return [
90
            'opportunity' => $opportunityName,
91
            'channel' => $channelName,
92
            'customer' => $customer,
93
            'account' => $accountName
94
        ];
95
    }
96
97
    /**
98
     * @return string
99
     */
100 View Code Duplication
    protected function createAccount()
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...
101
    {
102
        $accountName = 'Account_'.mt_rand();
103
104
        /** @var Accounts $page */
105
        $page = new Accounts($this, false);
106
        $page->openAccounts('OroCRM\Bundle\AccountBundle')
107
            ->add()
108
            ->setName($accountName)
109
            ->setOwner('admin')
110
            ->save();
111
112
        return $accountName;
113
    }
114
115
    /**
116
     * @param string $account
117
     * @param string $channel
118
     * @return string
119
     */
120 View Code Duplication
    protected function createB2BCustomer($account, $channel = '')
0 ignored issues
show
Unused Code introduced by
The parameter $channel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
121
    {
122
        $name = 'B2BCustomer_'.mt_rand();
123
        /** @var B2BCustomers $page */
124
        $page = new B2BCustomers($this, false);
125
        $page->openB2BCustomers('OroCRM\Bundle\SalesBundle')
126
            ->add()
127
            ->setName($name)
128
            ->setOwner('admin')
129
            ->setAccount($account)
130
            ->save();
131
132
        return $name;
133
    }
134
}
135