Completed
Push — master ( edfd40...5c1088 )
by Dmitry
02:40 queued 18s
created

CertificateCrudCest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 40
loc 40
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ensureThatICanCreateTariffPlan() 12 12 1
A ensureThatICanAddPrices() 8 8 1
A ensureICanUpdatePrices() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace ahnames\hipanel\tests\acceptance\module\finance\manager;
4
5
use hipanel\helpers\Url;
6
use hipanel\modules\finance\tests\_support\Page\plan\Create as PlanCreatePage;
7
use hipanel\modules\finance\tests\_support\Page\price\certificate\Create as PriceCertificateCreate;
8
use hipanel\modules\finance\tests\_support\Page\price\certificate\Update as PriceCertificateUpdate;
9
use hipanel\tests\_support\Step\Acceptance\Manager;
10
11 View Code Duplication
class CertificateCrudCest
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    /**
14
     * @var string
15
     */
16
    private $id;
17
18
    /**
19
     * @var array
20
     */
21
    private $fields;
22
23
    public function ensureThatICanCreateTariffPlan(Manager $I): void
24
    {
25
        $this->fields = [
26
            'name' => uniqid(),
27
            'type' => 'Certificate tariff',
28
            'client' => '[email protected]',
29
            'currency' => 'USD',
30
            'note' => 'test note',
31
        ];
32
        $page = new PlanCreatePage($I, $this->fields);
33
        $this->id = $page->createPlan();
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type string, but $page->createPlan() is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
34
    }
35
36
    public function ensureThatICanAddPrices(Manager $I): void
37
    {
38
        $I->needPage(Url::to(['@plan/view', 'id' => $this->id]));
39
        $I->see('No prices found');
40
        $price = new PriceCertificateCreate($I, $this->id);
41
        $price->addPrices('Certificate tariff');
42
        $price->ensureThereNoSuggestions('Certificate tariff');
43
    }
44
45
    public function ensureICanUpdatePrices(Manager $I): void
46
    {
47
        $price = new PriceCertificateUpdate($I, $this->id);
48
        $price->updatePrices();
49
    }
50
}
51