Completed
Push — master ( 72fe8d...342859 )
by Dmitry
30:38
created

TariffPlansCrudCest::ensureThatICanSeeTariffPlan()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
nc 1
cc 1
nop 1
1
<?php
2
3
namespace advancedhosters\hipanel\tests\acceptance\module\finance\manager;
4
5
use hipanel\modules\finance\tests\_support\Page\plan\Create;
6
use hipanel\modules\finance\tests\_support\Page\plan\View;
7
use hipanel\modules\finance\tests\_support\Page\plan\Update;
8
use hipanel\modules\finance\tests\_support\Page\plan\Delete;
9
use hipanel\modules\finance\tests\_support\Page\plan\Index;
10
use hipanel\tests\_support\Step\Acceptance\Manager;
11
12
class TariffPlansCrudCest
13
{
14
    /**
15
     * @var string
16
     */
17
    private $id;
18
19
    /**
20
     * @var array
21
     */
22
    private $fields;
23
24 View Code Duplication
    public function ensureThatICanCreateTariffPlan(Manager $I)
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...
25
    {
26
        $this->fields = [
27
            'name' => uniqid(),
28
            'type' => 'Template',
29
            'client' => 'hipanel_test_manager',
30
            'currency' => 'USD',
31
            'note' => 'test note',
32
        ];
33
        $plan = new Create($I, $this->fields);
34
        $plan->seeFields();
35
        $this->id = $plan->createPlan();
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type string, but $plan->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...
36
        $this->ensureThatICanSeeTariffPlan($I);
37
    }
38
39
    private function ensureThatICanSeeTariffPlan(Manager $I)
40
    {
41
        $plan = new View($I, $this->fields, $this->id);
42
        $plan->visitPlan();
43
        $plan->seePlan();
44
        $search = new Index($I);
45
        $search->ensurePageWorks();
46
        $search->ensurePlanCanBeFound($this->fields['name']);
47
    }
48
49 View Code Duplication
    public function ensureThatICanUpdateTariffPlan(Manager $I)
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...
50
    {
51
        $this->fields = [
52
            'name' => uniqid(),
53
            'type' => 'Server',
54
            'client' => 'hipanel_test_manager',
55
            'currency' => 'EUR',
56
            'note' => 'new_test_note',
57
        ];
58
        $plan = new Update($I, $this->fields);
59
        $this->id = $plan->updatePlan($this->id);
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type string, but $plan->updatePlan($this->id) 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...
60
        $this->ensureThatICanSeeTariffPlan($I);
61
    }
62
63
    public function ensureThatICanDeleteTariffPlan(Manager $I)
64
    {
65
        (new Delete($I, null, $this->id))->deletePlan();
66
        $this->ensureThatIDontSeeTariffPlan($I);
67
    }
68
69
    private function ensureThatIDontSeeTariffPlan(Manager $I)
70
    {
71
        $search = new Index($I);
72
        $search->ensurePageWorks();
73
        $search->ensurePlanNotFound($this->fields['name']);
74
    }
75
}
76