| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 28 | public function testEnablePluginsByArrayWithPaths() { |
||
| 29 | Config::inst()->update('Director', 'alternate_base_url', 'http://mysite.com/subdir'); |
||
| 30 | $c = new TinyMCEConfig(); |
||
| 31 | $c->setTheme('modern'); |
||
| 32 | $c->setOption('language', 'es'); |
||
| 33 | $c->disablePlugins('table', 'emoticons', 'paste', 'code', 'link', 'importcss'); |
||
| 34 | $c->enablePlugins(array( |
||
| 35 | 'plugin1' => 'mypath/plugin1.js', |
||
| 36 | 'plugin2' => '/anotherbase/mypath/plugin2.js', |
||
| 37 | 'plugin3' => 'https://www.google.com/plugin.js', |
||
| 38 | 'plugin4' => null, |
||
| 39 | 'plugin5' => null, |
||
| 40 | )); |
||
| 41 | $attributes = $c->getAttributes(); |
||
| 42 | $config = Convert::json2array($attributes['data-config']); |
||
| 43 | $plugins = $config['external_plugins']; |
||
| 44 | $this->assertNotEmpty($plugins); |
||
| 45 | |||
| 46 | // Plugin specified via relative url |
||
| 47 | $this->assertContains('plugin1', array_keys($plugins)); |
||
| 48 | $this->assertEquals( |
||
| 49 | 'http://mysite.com/subdir/mypath/plugin1.js', |
||
| 50 | $plugins['plugin1'] |
||
| 51 | ); |
||
| 52 | |||
| 53 | // Plugin specified via root-relative url |
||
| 54 | $this->assertContains('plugin2', array_keys($plugins)); |
||
| 55 | $this->assertEquals( |
||
| 56 | 'http://mysite.com/anotherbase/mypath/plugin2.js', |
||
| 57 | $plugins['plugin2'] |
||
| 58 | ); |
||
| 59 | |||
| 60 | // Plugin specified with absolute url |
||
| 61 | $this->assertContains('plugin3', array_keys($plugins)); |
||
| 62 | $this->assertEquals( |
||
| 63 | 'https://www.google.com/plugin.js', |
||
| 64 | $plugins['plugin3'] |
||
| 65 | ); |
||
| 66 | |||
| 67 | // Plugin specified with standard location |
||
| 68 | $this->assertContains('plugin4', array_keys($plugins)); |
||
| 69 | $this->assertEquals( |
||
| 70 | 'http://mysite.com/subdir/framework/thirdparty/tinymce/plugins/plugin4/plugin.min.js', |
||
| 71 | $plugins['plugin4'] |
||
| 72 | ); |
||
| 73 | |||
| 74 | // Check that internal plugins are extractable separately |
||
| 75 | $this->assertEquals(['plugin4', 'plugin5'], $c->getInternalPlugins()); |
||
| 76 | |||
| 77 | // Test plugins included via gzip compresser |
||
| 78 | Config::inst()->update('HTMLEditorField', 'use_gzip', true); |
||
| 79 | $this->assertEquals( |
||
| 80 | 'framework/thirdparty/tinymce/tiny_mce_gzip.php?js=1&plugins=plugin4,plugin5&themes=modern&languages=es&diskcache=true&src=true', |
||
| 81 | $c->getScriptURL() |
||
| 82 | ); |
||
| 83 | |||
| 84 | // If gzip is disabled only the core plugin is loaded |
||
| 85 | Config::inst()->remove('HTMLEditorField', 'use_gzip'); |
||
| 86 | $this->assertEquals( |
||
| 87 | 'framework/thirdparty/tinymce/tinymce.min.js', |
||
| 88 | $c->getScriptURL() |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | |||
| 135 |