From 2e8d373ec228f912f99f2e4d695621d40266f68f Mon Sep 17 00:00:00 2001 From: Trent Steel Date: Fri, 7 Feb 2014 08:26:13 +1000 Subject: [PATCH] improve test coverage and reshuffle tests so properties are grouped --- Tests/Form/CkeditorTypeTest.php | 408 ++++++++++++++++++++++++++------ 1 file changed, 336 insertions(+), 72 deletions(-) diff --git a/Tests/Form/CkeditorTypeTest.php b/Tests/Form/CkeditorTypeTest.php index 95be3ff8..17818fd4 100755 --- a/Tests/Form/CkeditorTypeTest.php +++ b/Tests/Form/CkeditorTypeTest.php @@ -330,103 +330,100 @@ public function testLanguage() } /** - * Checks filebrowserBrowseUrl property + * Check the default filebrowserBrowseUrl property */ - public function testFilebrowserBrowseUrl() + public function testDefaultFileBrowserBrowseUrl() { - $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_browse_url' => '/myfilebrowser/browser.html' - )); - + $form = $this->factory->create('ckeditor'); $view = $form->createView(); $filebrowserBrowseUrl = $view->vars['filebrowser_browse_url']; - $this->assertEquals($filebrowserBrowseUrl, '/myfilebrowser/browser.html'); - } - - /** - * Checks filebrowserUploadUrl property - */ - public function testFilebrowserUploadUrl() - { - $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_upload_url' => '/myfilebrowser/uploads' + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), )); - - $view = $form->createView(); - $filebrowserUploadUrl = $view->vars['filebrowser_upload_url']; - - $this->assertEquals($filebrowserUploadUrl, '/myfilebrowser/uploads'); } /** - * Checks filebrowserImageBrowseUrl property + * Checks filebrowserBrowseUrl property */ - public function testFilebrowserImageBrowseUrl() + public function testFileBrowserBrowseUrl() { $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_image_browse_url' => '/myfilebrowser/browser.html' + 'filebrowser_browse_url' => '/myfilebrowser/browser.html' )); $view = $form->createView(); - $filebrowserImageBrowseUrl = $view->vars['filebrowser_image_browse_url']; + $filebrowserBrowseUrl = $view->vars['filebrowser_browse_url']; - $this->assertEquals($filebrowserImageBrowseUrl, '/myfilebrowser/browser.html'); + $this->assertEquals($filebrowserBrowseUrl, '/myfilebrowser/browser.html'); } /** - * Checks filebrowserImageUploadUrl property + * Checks filebrowserBrowseUrl property */ - public function testFilebrowserImageUploadUrl() + public function testFileBrowserBrowseUrlRoute() { $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_image_upload_url' => '/myfilebrowser/uploads' + 'filebrowser_browse_url' => array( + 'route' => 'file_browser', + 'route_parameters' => array( + 'type' => 'file', + ), + ) )); $view = $form->createView(); - $filebrowserImageUploadUrl = $view->vars['filebrowser_image_upload_url']; + $filebrowserBrowseUrl = $view->vars['filebrowser_browse_url']; - $this->assertEquals($filebrowserImageUploadUrl, '/myfilebrowser/uploads'); + $this->assertEquals($filebrowserBrowseUrl, array( + 'route' => 'file_browser', + 'route_parameters' => array( + 'type' => 'file', + ), + )); } /** - * Checks filebrowserFlashBrowseUrl property + * Check the default filebrowserUploadUrl property */ - public function testFilebrowserFlashBrowseUrl() + public function testDefaultFileBrowserUploadUrl() { - $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_flash_browse_url' => '/myfilebrowser/browser.html' - )); - + $form = $this->factory->create('ckeditor'); $view = $form->createView(); - $filebrowserFlashBrowseUrl = $view->vars['filebrowser_flash_browse_url']; + $filebrowserBrowseUrl = $view->vars['filebrowser_upload_url']; - $this->assertEquals($filebrowserFlashBrowseUrl, '/myfilebrowser/browser.html'); + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), + )); } /** - * Checks filebrowserFlashUploadUrl property + * Checks filebrowserUploadUrl property */ - public function testFilebrowserFlashUploadUrl() + public function testFileBrowserUploadUrl() { $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_flash_upload_url' => '/myfilebrowser/uploads', + 'filebrowser_upload_url' => '/myfilebrowser/uploads' )); $view = $form->createView(); - $filebrowserFlashUploadUrl = $view->vars['filebrowser_flash_upload_url']; + $filebrowserUploadUrl = $view->vars['filebrowser_upload_url']; - $this->assertEquals($filebrowserFlashUploadUrl, '/myfilebrowser/uploads'); + $this->assertEquals($filebrowserUploadUrl, '/myfilebrowser/uploads'); } /** - * Checks filebrowserBrowseUrl property + * Checks filebrowserUploadUrl property */ - public function testFilebrowserBrowseUrlRoute() + public function testFileBrowserUploadUrlRoute() { $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_browse_url' => array( - 'route' => 'file_browser', + 'filebrowser_upload_url' => array( + 'route' => 'file_browser_upload', 'route_parameters' => array( 'type' => 'file', ), @@ -434,10 +431,10 @@ public function testFilebrowserBrowseUrlRoute() )); $view = $form->createView(); - $filebrowserBrowseUrl = $view->vars['filebrowser_browse_url']; + $filebrowserUploadUrl = $view->vars['filebrowser_upload_url']; - $this->assertEquals($filebrowserBrowseUrl, array( - 'route' => 'file_browser', + $this->assertEquals($filebrowserUploadUrl, array( + 'route' => 'file_browser_upload', 'route_parameters' => array( 'type' => 'file', ), @@ -445,34 +442,40 @@ public function testFilebrowserBrowseUrlRoute() } /** - * Checks filebrowserUploadUrl property + * Check the default filebrowserImageBrowseUrl property */ - public function testFilebrowserUploadUrlRoute() + public function testDefaultFileBrowserImageBrowseUrl() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $filebrowserBrowseUrl = $view->vars['filebrowser_image_browse_url']; + + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), + )); + } + + /** + * Checks filebrowserImageBrowseUrl property + */ + public function testFileBrowserImageBrowseUrl() { $form = $this->factory->create('ckeditor', null, array( - 'filebrowser_upload_url' => array( - 'route' => 'file_browser_upload', - 'route_parameters' => array( - 'type' => 'file', - ), - ) + 'filebrowser_image_browse_url' => '/myfilebrowser/browser.html' )); $view = $form->createView(); - $filebrowserUploadUrl = $view->vars['filebrowser_upload_url']; + $filebrowserImageBrowseUrl = $view->vars['filebrowser_image_browse_url']; - $this->assertEquals($filebrowserUploadUrl, array( - 'route' => 'file_browser_upload', - 'route_parameters' => array( - 'type' => 'file', - ), - )); + $this->assertEquals($filebrowserImageBrowseUrl, '/myfilebrowser/browser.html'); } /** * Checks filebrowserImageBrowseUrl property */ - public function testFilebrowserImageBrowseUrlRoute() + public function testFileBrowserImageBrowseUrlRoute() { $form = $this->factory->create('ckeditor', null, array( 'filebrowser_image_browse_url' => array( @@ -494,10 +497,41 @@ public function testFilebrowserImageBrowseUrlRoute() )); } + /** + * Check the default filebrowserImageUploadUrl property + */ + public function testDefaultFileBrowserImageUploadUrl() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $filebrowserBrowseUrl = $view->vars['filebrowser_image_upload_url']; + + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), + )); + } + /** * Checks filebrowserImageUploadUrl property */ - public function testFilebrowserImageUploadUrlRoute() + public function testFileBrowserImageUploadUrl() + { + $form = $this->factory->create('ckeditor', null, array( + 'filebrowser_image_upload_url' => '/myfilebrowser/uploads' + )); + + $view = $form->createView(); + $filebrowserImageUploadUrl = $view->vars['filebrowser_image_upload_url']; + + $this->assertEquals($filebrowserImageUploadUrl, '/myfilebrowser/uploads'); + } + + /** + * Checks filebrowserImageUploadUrl property + */ + public function testFileBrowserImageUploadUrlRoute() { $form = $this->factory->create('ckeditor', null, array( 'filebrowser_image_upload_url' => array( @@ -519,10 +553,41 @@ public function testFilebrowserImageUploadUrlRoute() )); } + /** + * Check the default filebrowserFlashBrowseUrl property + */ + public function testDefaultFileBrowserFlashBrowseUrl() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $filebrowserBrowseUrl = $view->vars['filebrowser_flash_browse_url']; + + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), + )); + } + + /** + * Checks filebrowserFlashBrowseUrl property + */ + public function testFileBrowserFlashBrowseUrl() + { + $form = $this->factory->create('ckeditor', null, array( + 'filebrowser_flash_browse_url' => '/myfilebrowser/browser.html' + )); + + $view = $form->createView(); + $filebrowserFlashBrowseUrl = $view->vars['filebrowser_flash_browse_url']; + + $this->assertEquals($filebrowserFlashBrowseUrl, '/myfilebrowser/browser.html'); + } + /** * Checks filebrowserFlashBrowseUrl property */ - public function testFilebrowserFlashBrowseUrlRoute() + public function testFileBrowserFlashBrowseUrlRoute() { $form = $this->factory->create('ckeditor', null, array( 'filebrowser_flash_browse_url' => array( @@ -544,10 +609,41 @@ public function testFilebrowserFlashBrowseUrlRoute() )); } + /** + * Check the default filebrowserFlashUploadUrl property + */ + public function testDefaultFileBrowserFlashUploadUrl() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $filebrowserBrowseUrl = $view->vars['filebrowser_flash_upload_url']; + + $this->assertEquals($filebrowserBrowseUrl, array( + 'url' => null, + 'route' => null, + 'route_parameters' => array(), + )); + } + + /** + * Checks filebrowserFlashUploadUrl property + */ + public function testFileBrowserFlashUploadUrl() + { + $form = $this->factory->create('ckeditor', null, array( + 'filebrowser_flash_upload_url' => '/myfilebrowser/uploads', + )); + + $view = $form->createView(); + $filebrowserFlashUploadUrl = $view->vars['filebrowser_flash_upload_url']; + + $this->assertEquals($filebrowserFlashUploadUrl, '/myfilebrowser/uploads'); + } + /** * Checks filebrowserFlashUploadUrl property */ - public function testFilebrowserFlashUploadUrlRoute() + public function testFileBrowserFlashUploadUrlRoute() { $form = $this->factory->create('ckeditor', null, array( 'filebrowser_flash_upload_url' => array( @@ -569,6 +665,18 @@ public function testFilebrowserFlashUploadUrlRoute() )); } + /** + * Check default skin property + */ + public function testDefaultSkin() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $skin = $view->vars['skin']; + + $this->assertNull($skin); + } + /** * Checks skin property */ @@ -584,6 +692,18 @@ public function testSkin() $this->assertEquals($skin, 'myskin,/skins/myskin/'); } + /** + * Check default format_tags property + */ + public function testDefaultFormatTags() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $formatTags = $view->vars['format_tags']; + + $this->assertEquals($formatTags, array()); + } + /** * Checks format_tags property */ @@ -599,6 +719,18 @@ public function testFormatTags() $this->assertEquals($formatTags, array('p','h2','h3','pre')); } + /** + * Check default base_path property + */ + public function testDefaultBasePath() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $basePath = $view->vars['base_path']; + + $this->assertEquals($basePath, 'bundles/trsteelckeditor/'); + } + /** * Checks base_path property */ @@ -614,6 +746,18 @@ public function testBasePath() $this->assertEquals($basePath, '/lib/ckeditor/'); } + /** + * Check default base_href property + */ + public function testDefaultBaseHref() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $baseHref = $view->vars['base_href']; + + $this->assertNull($baseHref); + } + /** * Checks base_href property */ @@ -629,6 +773,18 @@ public function testBaseHref() $this->assertEquals($baseHref, 'http://domain.com/'); } + /** + * Check default body_class property + */ + public function testDefaultBodyClass() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $bodyClass = $view->vars['body_class']; + + $this->assertNull($bodyClass); + } + /** * Checks body_class property */ @@ -644,6 +800,18 @@ public function testBodyClass() $this->assertEquals($bodyClass, 'special_class'); } + /** + * Check default contents_css property + */ + public function testDefaultContentsCss() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $contentsCss = $view->vars['contents_css']; + + $this->assertEquals($contentsCss, array()); + } + /** * Checks contents_css property */ @@ -680,6 +848,18 @@ public function testContentsCssAsString() $this->assertEquals($contentsCss, '/css/ckeditor/contents.css'); } + /** + * Check default basic_entities property + */ + public function testDefaultBasicEntities() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $basicEntities = $view->vars['basic_entities']; + + $this->assertNull($basicEntities); + } + /** * Checks basic_entities property */ @@ -695,6 +875,18 @@ public function testBasicEntities() $this->assertEquals($basicEntities, false); } + /** + * Check default entities property + */ + public function testDefaultEntities() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $entities = $view->vars['entities']; + + $this->assertNull($entities); + } + /** * Checks entities property */ @@ -710,6 +902,18 @@ public function testEntities() $this->assertEquals($entities, false); } + /** + * Check default entities_latin property + */ + public function testDefaultEntitiesLatin() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $entitiesLatin = $view->vars['entities_latin']; + + $this->assertNull($entitiesLatin); + } + /** * Checks entities_latin property */ @@ -725,6 +929,18 @@ public function testEntitiesLatin() $this->assertEquals($entitiesLatin, false); } + /** + * Check default startup_mode property + */ + public function testDefaultStartupMode() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $startupMode = $view->vars['startup_mode']; + + $this->assertNull($startupMode); + } + /** * Checks startup_mode property */ @@ -740,6 +956,18 @@ public function testStartupMode() $this->assertEquals($startupMode, 'source'); } + /** + * Check default enter_mode property + */ + public function testDefaultEnterMode() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $enterMode = $view->vars['enter_mode']; + + $this->assertNull($enterMode); + } + /** * Checks enter_mode property */ @@ -750,9 +978,21 @@ public function testEnterMode() )); $view = $form->createView(); - $startupMode = $view->vars['enter_mode']; + $enterMode = $view->vars['enter_mode']; + + $this->assertEquals($enterMode, 'ENTER_BR'); + } + + /** + * Check default external_plugins property + */ + public function testDefaultExternalPlugins() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $externalPlugins = $view->vars['external_plugins']; - $this->assertEquals($startupMode, 'ENTER_BR'); + $this->assertEquals($externalPlugins, array()); } /** @@ -806,6 +1046,18 @@ public function testCustomConfig() $this->assertEquals($customConfig, 'someconfig.js'); } + /** + * Check default templates_files property + */ + public function testDefaultTemplateFiles() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $templateFiles = $view->vars['templates_files']; + + $this->assertEquals($templateFiles, array()); + } + /** * Checks templateFiles property */ @@ -827,6 +1079,18 @@ public function testTemplateFiles() )); } + /** + * Check default extra_allowed_content property + */ + public function testDefaultExtraAllowedContent() + { + $form = $this->factory->create('ckeditor'); + $view = $form->createView(); + $extraAllowedContent = $view->vars['extra_allowed_content']; + + $this->assertNull($extraAllowedContent); + } + /** * Checks extraAllowedContent property */