| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 25 |
| 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 |
||
| 85 | function testCreateCompositeType() |
||
| 86 | {
|
||
| 87 | global $webUrl; |
||
| 88 | global $lang, $SERVER, $DATABASE; |
||
| 89 | |||
| 90 | // Turn to "Types" page. |
||
| 91 | $this->assertTrue($this->get("$webUrl/types.php", array(
|
||
| 92 | 'server' => $SERVER, |
||
| 93 | 'database' => $DATABASE, |
||
| 94 | 'schema' => 'public', |
||
| 95 | 'subject' => 'schema')) |
||
| 96 | ); |
||
| 97 | $this->assertTrue($this->clickLink($lang['strcreatecomptype'])); |
||
| 98 | |||
| 99 | // Create without composite type name. |
||
| 100 | //$this->assertTrue($this->clickSubmit($lang['strnext'])); |
||
| 101 | // If we do not hardcoded it here, it will cause fail. Encoding issue. |
||
| 102 | $this->assertTrue($this->clickSubmit('Next >'));
|
||
| 103 | $this->assertTrue($this->assertWantedText($lang['strtypeneedsname'])); |
||
| 104 | |||
| 105 | // Enter the name of the new composite type. |
||
| 106 | $this->assertTrue($this->setField('name', 'compositetype'));
|
||
| 107 | |||
| 108 | // Create without composite type field. |
||
| 109 | //$this->assertTrue($this->clickSubmit($lang['strnext'])); |
||
| 110 | // If we do not hardcoded it here, it will cause fail. Encoding issue. |
||
| 111 | $this->assertTrue($this->clickSubmit('Next >'));
|
||
| 112 | $this->assertTrue($this->assertWantedText($lang['strtypeneedscols'])); |
||
| 113 | |||
| 114 | $this->assertTrue($this->setField('fields', '2'));
|
||
| 115 | $this->assertTrue($this->setField('typcomment', 'Create in testcase'));
|
||
| 116 | $this->assertTrue($this->clickSubmit('Next >'));
|
||
| 117 | // If we do not hardcoded it here, it will cause fail. Encoding issue. |
||
| 118 | //$this->assertTrue($this->clickSubmit('Next >'));
|
||
| 119 | |||
| 120 | // Create the composite type without the definition of fields. |
||
| 121 | $this->assertTrue($this->clickSubmit($lang['strcreate'])); |
||
| 122 | $this->assertTrue($this->assertWantedText($lang['strtypeneedsfield'])); |
||
| 123 | |||
| 124 | // Enter the fields information. |
||
| 125 | $this->assertTrue($this->setField('field[0]', 'firstfield'));
|
||
| 126 | $this->assertTrue($this->setField('type[0]', 'bigint'));
|
||
| 127 | $this->assertTrue($this->setField('field[1]', 'secondfield'));
|
||
| 128 | $this->assertTrue($this->setField('type[1]', 'bigint'));
|
||
| 129 | |||
| 130 | // Click the "Create" button to create the composite type. |
||
| 131 | $this->assertTrue($this->clickSubmit($lang['strcreate'])); |
||
| 132 | // Verify if the type create correctly. |
||
| 133 | $this->assertTrue($this->assertWantedText($lang['strtypecreated'])); |
||
| 134 | |||
| 135 | return TRUE; |
||
| 136 | } |
||
| 208 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.