Conditions | 1 |
Paths | 1 |
Total Lines | 105 |
Code Lines | 77 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
121 | public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() |
||
122 | { |
||
123 | $primaryTableName = '"Primary_Table"'; |
||
124 | $offlinePrimaryTable = new Schema\Table($primaryTableName); |
||
125 | $offlinePrimaryTable->addColumn( |
||
126 | '"Id"', |
||
127 | 'integer', |
||
128 | ['autoincrement' => true, 'comment' => 'Explicit casing.'] |
||
129 | ); |
||
130 | $offlinePrimaryTable->addColumn('select', 'integer', ['comment' => 'Reserved keyword.']); |
||
131 | $offlinePrimaryTable->addColumn('foo', 'integer', ['comment' => 'Implicit uppercasing.']); |
||
132 | $offlinePrimaryTable->addColumn('BAR', 'integer'); |
||
133 | $offlinePrimaryTable->addColumn('"BAZ"', 'integer'); |
||
134 | $offlinePrimaryTable->addIndex(['select'], 'from'); |
||
135 | $offlinePrimaryTable->addIndex(['foo'], 'foo_index'); |
||
136 | $offlinePrimaryTable->addIndex(['BAR'], 'BAR_INDEX'); |
||
137 | $offlinePrimaryTable->addIndex(['"BAZ"'], 'BAZ_INDEX'); |
||
138 | $offlinePrimaryTable->setPrimaryKey(['"Id"']); |
||
139 | |||
140 | $foreignTableName = 'foreign'; |
||
141 | $offlineForeignTable = new Schema\Table($foreignTableName); |
||
142 | $offlineForeignTable->addColumn('id', 'integer', ['autoincrement' => true]); |
||
143 | $offlineForeignTable->addColumn('"Fk"', 'integer'); |
||
144 | $offlineForeignTable->addIndex(['"Fk"'], '"Fk_index"'); |
||
145 | $offlineForeignTable->addForeignKeyConstraint( |
||
146 | $primaryTableName, |
||
147 | ['"Fk"'], |
||
148 | ['"Id"'], |
||
149 | [], |
||
150 | '"Primary_Table_Fk"' |
||
151 | ); |
||
152 | $offlineForeignTable->setPrimaryKey(['id']); |
||
153 | |||
154 | $this->schemaManager->tryMethod('dropTable', $foreignTableName); |
||
155 | $this->schemaManager->tryMethod('dropTable', $primaryTableName); |
||
156 | |||
157 | $this->schemaManager->createTable($offlinePrimaryTable); |
||
158 | $this->schemaManager->createTable($offlineForeignTable); |
||
159 | |||
160 | $onlinePrimaryTable = $this->schemaManager->listTableDetails($primaryTableName); |
||
161 | $onlineForeignTable = $this->schemaManager->listTableDetails($foreignTableName); |
||
162 | |||
163 | $platform = $this->schemaManager->getDatabasePlatform(); |
||
164 | |||
165 | // Primary table assertions |
||
166 | self::assertSame($primaryTableName, $onlinePrimaryTable->getQuotedName($platform)); |
||
167 | |||
168 | self::assertTrue($onlinePrimaryTable->hasColumn('"Id"')); |
||
169 | self::assertSame('"Id"', $onlinePrimaryTable->getColumn('"Id"')->getQuotedName($platform)); |
||
170 | self::assertTrue($onlinePrimaryTable->hasPrimaryKey()); |
||
171 | self::assertSame(['"Id"'], $onlinePrimaryTable->getPrimaryKey()->getQuotedColumns($platform)); |
||
172 | |||
173 | self::assertTrue($onlinePrimaryTable->hasColumn('select')); |
||
174 | self::assertSame('"select"', $onlinePrimaryTable->getColumn('select')->getQuotedName($platform)); |
||
175 | |||
176 | self::assertTrue($onlinePrimaryTable->hasColumn('foo')); |
||
177 | self::assertSame('FOO', $onlinePrimaryTable->getColumn('foo')->getQuotedName($platform)); |
||
178 | |||
179 | self::assertTrue($onlinePrimaryTable->hasColumn('BAR')); |
||
180 | self::assertSame('BAR', $onlinePrimaryTable->getColumn('BAR')->getQuotedName($platform)); |
||
181 | |||
182 | self::assertTrue($onlinePrimaryTable->hasColumn('"BAZ"')); |
||
183 | self::assertSame('BAZ', $onlinePrimaryTable->getColumn('"BAZ"')->getQuotedName($platform)); |
||
184 | |||
185 | self::assertTrue($onlinePrimaryTable->hasIndex('from')); |
||
186 | self::assertTrue($onlinePrimaryTable->getIndex('from')->hasColumnAtPosition('"select"')); |
||
187 | self::assertSame(['"select"'], $onlinePrimaryTable->getIndex('from')->getQuotedColumns($platform)); |
||
188 | |||
189 | self::assertTrue($onlinePrimaryTable->hasIndex('foo_index')); |
||
190 | self::assertTrue($onlinePrimaryTable->getIndex('foo_index')->hasColumnAtPosition('foo')); |
||
191 | self::assertSame(['FOO'], $onlinePrimaryTable->getIndex('foo_index')->getQuotedColumns($platform)); |
||
192 | |||
193 | self::assertTrue($onlinePrimaryTable->hasIndex('BAR_INDEX')); |
||
194 | self::assertTrue($onlinePrimaryTable->getIndex('BAR_INDEX')->hasColumnAtPosition('BAR')); |
||
195 | self::assertSame(['BAR'], $onlinePrimaryTable->getIndex('BAR_INDEX')->getQuotedColumns($platform)); |
||
196 | |||
197 | self::assertTrue($onlinePrimaryTable->hasIndex('BAZ_INDEX')); |
||
198 | self::assertTrue($onlinePrimaryTable->getIndex('BAZ_INDEX')->hasColumnAtPosition('"BAZ"')); |
||
199 | self::assertSame(['BAZ'], $onlinePrimaryTable->getIndex('BAZ_INDEX')->getQuotedColumns($platform)); |
||
200 | |||
201 | // Foreign table assertions |
||
202 | self::assertTrue($onlineForeignTable->hasColumn('id')); |
||
203 | self::assertSame('ID', $onlineForeignTable->getColumn('id')->getQuotedName($platform)); |
||
204 | self::assertTrue($onlineForeignTable->hasPrimaryKey()); |
||
205 | self::assertSame(['ID'], $onlineForeignTable->getPrimaryKey()->getQuotedColumns($platform)); |
||
206 | |||
207 | self::assertTrue($onlineForeignTable->hasColumn('"Fk"')); |
||
208 | self::assertSame('"Fk"', $onlineForeignTable->getColumn('"Fk"')->getQuotedName($platform)); |
||
209 | |||
210 | self::assertTrue($onlineForeignTable->hasIndex('"Fk_index"')); |
||
211 | self::assertTrue($onlineForeignTable->getIndex('"Fk_index"')->hasColumnAtPosition('"Fk"')); |
||
212 | self::assertSame(['"Fk"'], $onlineForeignTable->getIndex('"Fk_index"')->getQuotedColumns($platform)); |
||
213 | |||
214 | self::assertTrue($onlineForeignTable->hasForeignKey('"Primary_Table_Fk"')); |
||
215 | self::assertSame( |
||
216 | $primaryTableName, |
||
217 | $onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignTableName($platform) |
||
218 | ); |
||
219 | self::assertSame( |
||
220 | ['"Fk"'], |
||
221 | $onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedLocalColumns($platform) |
||
222 | ); |
||
223 | self::assertSame( |
||
224 | ['"Id"'], |
||
225 | $onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignColumns($platform) |
||
226 | ); |
||
294 |