1
+ Feature : Rename Property
2
+ To keep my code base clean
3
+ As a developer
4
+ I want to rename properties
5
+
6
+ Scenario : Rename Property using its declaration
7
+ Given a PHP File named "src/Foo.php" with:
8
+ """
9
+ <?php
10
+ class Foo
11
+ {
12
+ private $number = 2;
13
+
14
+ public function operation()
15
+ {
16
+ $var = 2;
17
+
18
+ for ($i = 0; $i < 3; $i++) {
19
+ $var = pow($var, 2);
20
+ }
21
+
22
+ return $var * $this->number;
23
+ }
24
+ }
25
+ """
26
+ When I use refactoring "rename-property" with:
27
+ | arg | value |
28
+ | file | src /Foo .php |
29
+ | line | 4 |
30
+ | name | number |
31
+ | new -name | magic |
32
+ Then the PHP File "src/Foo.php" should be refactored:
33
+ """
34
+ --- a/vfs://project/src/Foo.php
35
+ +++ b/vfs://project/src/Foo.php
36
+ @@ -1,7 +1,7 @@
37
+ <?php
38
+ class Foo
39
+ {
40
+ - private $number = 2;
41
+ + private $magic = 2;
42
+
43
+ public function operation()
44
+ {
45
+ @@ -11,6 +11,6 @@
46
+ $var = pow($var, 2);
47
+ }
48
+
49
+ - return $var * $this->number;
50
+ + return $var * $this->magic;
51
+ }
52
+ }
53
+ """
54
+
55
+ Scenario : Rename Property using a line where it's used.
56
+ Given a PHP File named "src/Foo.php" with:
57
+ """
58
+ <?php
59
+ class Foo
60
+ {
61
+ private $number = 2;
62
+
63
+ public function operation()
64
+ {
65
+ $var = 2;
66
+
67
+ for ($i = 0; $i < 3; $i++) {
68
+ $var = pow($var, 2);
69
+ }
70
+
71
+ return $var * $this->number;
72
+ }
73
+ }
74
+ """
75
+ When I use refactoring "rename-property" with:
76
+ | arg | value |
77
+ | file | src /Foo .php |
78
+ | line | 14 |
79
+ | name | number |
80
+ | new -name | magic |
81
+ Then the PHP File "src/Foo.php" should be refactored:
82
+ """
83
+ --- a/vfs://project/src/Foo.php
84
+ +++ b/vfs://project/src/Foo.php
85
+ @@ -1,7 +1,7 @@
86
+ <?php
87
+ class Foo
88
+ {
89
+ - private $number = 2;
90
+ + private $magic = 2;
91
+
92
+ public function operation()
93
+ {
94
+ @@ -11,6 +11,6 @@
95
+ $var = pow($var, 2);
96
+ }
97
+
98
+ - return $var * $this->number;
99
+ + return $var * $this->magic;
100
+ }
101
+ }
102
+ """
103
+
104
+ Scenario : Rename Property using any line inside the class.
105
+ Given a PHP File named "src/Foo.php" with:
106
+ """
107
+ <?php
108
+ class Foo
109
+ {
110
+ private $number = 2;
111
+
112
+ public function operation()
113
+ {
114
+ $var = 2;
115
+
116
+ for ($i = 0; $i < 3; $i++) {
117
+ $var = pow($var, 2);
118
+ }
119
+
120
+ return $var * $this->number;
121
+ }
122
+ }
123
+ """
124
+ When I use refactoring "rename-property" with:
125
+ | arg | value |
126
+ | file | src /Foo .php |
127
+ | line | 7 |
128
+ | name | number |
129
+ | new -name | magic |
130
+ Then the PHP File "src/Foo.php" should be refactored:
131
+ """
132
+ --- a/vfs://project/src/Foo.php
133
+ +++ b/vfs://project/src/Foo.php
134
+ @@ -1,7 +1,7 @@
135
+ <?php
136
+ class Foo
137
+ {
138
+ - private $number = 2;
139
+ + private $magic = 2;
140
+
141
+ public function operation()
142
+ {
143
+ @@ -11,6 +11,6 @@
144
+ $var = pow($var, 2);
145
+ }
146
+
147
+ - return $var * $this->number;
148
+ + return $var * $this->magic;
149
+ }
150
+ }
151
+ """
0 commit comments