Author: Jonathan.Wage
Date: 2010-01-15 22:58:50 +0100 (Fri, 15 Jan 2010)
New Revision: 26697

Added:
   plugins/sfSympalPlugin/trunk/test/fixtures/project/config/fresh_app.yml
Modified:
   plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
   plugins/sfSympalPlugin/trunk/lib/helper/SympalContentSlotHelper.php
   
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
   
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotContentPropertyRenderer.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotMarkdownRenderer.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotRenderer.class.php
   plugins/sfSympalPlugin/trunk/test/bootstrap/cleanup.php
   plugins/sfSympalPlugin/trunk/test/fixtures/project/data/fresh_test_db.sqlite
   plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
   plugins/sfSympalPlugin/trunk/test/unit/ContentTest.php
Log:
[1.4][sfSympalPlugin][1.0] Fixes for tests


Modified: plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php        
2010-01-15 21:11:40 UTC (rev 26696)
+++ plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php        
2010-01-15 21:58:50 UTC (rev 26697)
@@ -89,6 +89,11 @@
 
   public function hasRecaptcha()
   {
+    // No recaptcha in test environment
+    if (sfConfig::get('sf_environment') === 'test')
+    {
+      return false;
+    }
     $forms = sfSympalConfig::get('recaptcha_forms', null, array());
     $class = get_class($this->getSubject());
 

Modified: plugins/sfSympalPlugin/trunk/lib/helper/SympalContentSlotHelper.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/helper/SympalContentSlotHelper.php 
2010-01-15 21:11:40 UTC (rev 26696)
+++ plugins/sfSympalPlugin/trunk/lib/helper/SympalContentSlotHelper.php 
2010-01-15 21:58:50 UTC (rev 26697)
@@ -29,7 +29,7 @@
  * @param Content $content  The Content instance
  * @param string $name The name of the slot
  * @param string $type The type of slot
- * @param string $renderFunction The function to use to render the value
+ * @param string $renderFunction The function/callable used to render the 
value of slots which are columns
  * @return void
  */
 function get_sympal_content_slot($content, $name, $type = 'Text', 
$renderFunction = null)
@@ -39,31 +39,14 @@
   {
     $slot = $name;
     $name = $name->getName();
+  } else {
+    $slot = $content->getOrCreateSlot($name, $type, $renderFunction);
   }
 
-  $isColumn = false;
-  if ($content->hasField($name))
-  {
-    $isColumn = true;
-  }
-
-  if (!$slot)
-  {
-    $slot = $content->getOrCreateSlot($name, $type, $isColumn, 
$renderFunction);
-  }
-
   $slot->setContentRenderedFor($content);
 
-  if ($isColumn && is_null($renderFunction))
+  if (sfContext::getInstance()->getUser()->isEditMode())
   {
-    $renderFunction = 'get_sympal_content_property';
-  }
-
-  $slots = $content->getSlots();
-
-  $user = sfContext::getInstance()->getUser();
-  if ($user->isEditMode())
-  {
     use_helper('SympalContentSlotEditor');
 
     return get_sympal_content_slot_editor($slot);

Modified: 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php 
    2010-01-15 21:11:40 UTC (rev 26696)
+++ 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContent.class.php 
    2010-01-15 21:58:50 UTC (rev 26697)
@@ -118,30 +118,27 @@
     return $contentSlotRef;
   }
 
-  public function getOrCreateSlot($name, $type = 'Text', $isColumn = false, 
$renderFunction = null)
+  public function getOrCreateSlot($name, $type = null, $renderFunction = null)
   {
     if (!$hasSlot = $this->hasSlot($name))
     {
+      $isColumn = $this->hasField($name) ? true : false;
+      $type = $type ? $type : 'Text';
+
       $slot = new sfSympalContentSlot();
-      $slot->render_function = $renderFunction;
-      if ($isColumn)
+      $slot->is_column = $isColumn;
+      
+      if ($slot->is_column && is_null($renderFunction))
       {
-        $slot->is_column = true;
+        $renderFunction = 'get_sympal_content_property';
       }
 
-      if (!$slot->exists())
-      {
-        if ($isColumn)
-        {
-          $type = 'ContentProperty';
-        }
+      $slot->render_function = $renderFunction;
+      $slot->name = $name;
+      $slot->type = $type;
+      $slot->save();
 
-        $slot->setName($name);
-        $slot->setType($type);
-        $slot->save();
-
-        $this->addSlot($slot);
-      }
+      $this->addSlot($slot);
     } else {
       $slot = $this->getSlot($name);
     }
@@ -156,7 +153,7 @@
     $result = $this->_table->hasField($name);
     if (!$result)
     {
-      $className = $this->getContentTypeClassName();
+      $className = $this->getType()->getName();
       $table = Doctrine_Core::getTable($className);
       if ($table->hasField($name))
       {

Modified: 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
 2010-01-15 21:11:40 UTC (rev 26696)
+++ 
plugins/sfSympalPlugin/trunk/lib/model/doctrine/PluginsfSympalContentSlot.class.php
 2010-01-15 21:58:50 UTC (rev 26697)
@@ -96,22 +96,11 @@
   {
     if (!$this->_rendered)
     {
-      if ($this->render_function)
-      {
-        $renderFunction = $this->render_function;
-        if (method_exists($this->_contentRenderedFor, $renderFunction))
-        {
-          $this->_rendered = 
$this->_contentRenderedFor->$renderFunction($this);
-        } else {
-          sfSympalToolkit::autoloadHelper($renderFunction);
-          $this->_rendered = $renderFunction($this->_contentRenderedFor, 
$this->name);
-        }
-      } else {
-        $className = 'sfSympalContentSlot'.$this->type.'Renderer';
-        $renderer = new $className($this);
-        $this->_rendered = (string) $renderer;
-      }
-      $this->_rendered = 
sfApplicationConfiguration::getActive()->getEventDispatcher()->filter(new 
sfEvent($this, 'sympal.content_renderer.filter_slot_content'), 
$this->_rendered)->getReturnValue();
+      $className = 'sfSympalContentSlot'.$this->type.'Renderer';
+      $renderer = new $className($this);
+      $rendered = (string) $renderer;
+  
+      $this->_rendered = 
sfApplicationConfiguration::getActive()->getEventDispatcher()->filter(new 
sfEvent($this, 'sympal.content_renderer.filter_slot_content'), 
$rendered)->getReturnValue();
     }
     return $this->_rendered;
   }

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotContentPropertyRenderer.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotContentPropertyRenderer.class.php
      2010-01-15 21:11:40 UTC (rev 26696)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotContentPropertyRenderer.class.php
      2010-01-15 21:58:50 UTC (rev 26697)
@@ -2,5 +2,4 @@
 
 class sfSympalContentSlotContentPropertyRenderer extends 
sfSympalContentSlotRenderer
 {
-  
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotMarkdownRenderer.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotMarkdownRenderer.class.php
     2010-01-15 21:11:40 UTC (rev 26696)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotMarkdownRenderer.class.php
     2010-01-15 21:58:50 UTC (rev 26697)
@@ -4,6 +4,6 @@
 {
   public function render()
   {
-    return sfSympalMarkdownRenderer::convertToHtml($this->getRawValue());
+    return sfSympalMarkdownRenderer::convertToHtml($this->getRenderedValue());
   }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotRenderer.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotRenderer.class.php
     2010-01-15 21:11:40 UTC (rev 26696)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/slot/sfSympalContentSlotRenderer.class.php
     2010-01-15 21:58:50 UTC (rev 26697)
@@ -8,11 +8,12 @@
   public function __construct(sfSympalContentSlot $contentSlot)
   {
     $this->_contentSlot = $contentSlot;
+    $this->_content = $contentSlot->getContentRenderedFor();
   }
 
   public function render()
   {
-    return $this->getRawValue();
+    return $this->getRenderedValue();
   }
 
   public function getRawValue()
@@ -20,6 +21,25 @@
     return $this->_contentSlot->getRawValue();
   }
 
+  public function getRenderedValue()
+  {
+    if ($this->_contentSlot->render_function)
+    {
+      $renderFunction = $this->_contentSlot->render_function;
+      if (method_exists($this->_content, $renderFunction))
+      {
+        return $this->_content->$renderFunction($this);
+      } else if (method_exists($this->_contentSlot, $renderFunction)) {
+        return $this->_contentSlot->$renderFunction($this);
+      } else {
+        sfSympalToolkit::autoloadHelper($renderFunction);
+        return $renderFunction($this->_content, $this->_contentSlot->name);
+      }
+    } else {
+      return $this->getRawValue();
+    }
+  }
+
   public function __toString()
   {
     try

Modified: plugins/sfSympalPlugin/trunk/test/bootstrap/cleanup.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/bootstrap/cleanup.php     2010-01-15 
21:11:40 UTC (rev 26696)
+++ plugins/sfSympalPlugin/trunk/test/bootstrap/cleanup.php     2010-01-15 
21:58:50 UTC (rev 26697)
@@ -6,7 +6,9 @@
   sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/log');
 
   @unlink(dirname(__FILE__) . '/../fixtures/project/data/test.sqlite');
+  @unlink(dirname(__FILE__) . '/../fixtures/project/config/app.yml');
 }
 
 copy(dirname(__FILE__).'/../fixtures/project/data/fresh_test_db.sqlite', 
dirname(__FILE__).'/../fixtures/project/data/test.sqlite');
+copy(dirname(__FILE__).'/../fixtures/project/config/fresh_app.yml', 
dirname(__FILE__).'/../fixtures/project/config/app.yml');
 register_shutdown_function('sympal_cleanup');
\ No newline at end of file

Added: plugins/sfSympalPlugin/trunk/test/fixtures/project/config/fresh_app.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/test/fixtures/project/config/fresh_app.yml     
                        (rev 0)
+++ plugins/sfSympalPlugin/trunk/test/fixtures/project/config/fresh_app.yml     
2010-01-15 21:58:50 UTC (rev 26697)
@@ -0,0 +1,12 @@
+all:
+  sympal_config:
+    sfSympalBlogPlugin:
+      installed: true
+    sfSympalCommentsPlugin:
+      installed: true
+    sfSympalThemeTestPlugin:
+      installed: true
+    installed: true
+    current_version: 1.0.0-ALPHA1
+    upgrade_version_history:
+      - 0.7.0__2

Modified: 
plugins/sfSympalPlugin/trunk/test/fixtures/project/data/fresh_test_db.sqlite
===================================================================
(Binary files differ)

Modified: plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php       
2010-01-15 21:11:40 UTC (rev 26696)
+++ plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php       
2010-01-15 21:58:50 UTC (rev 26697)
@@ -7,7 +7,7 @@
 $browser->
   signInAsAdmin()->
   get('/blog-post/sample_blogpost')->
-  click('Save', array('sf_sympal_comment' => array(
+  click('Save Comment', array('sf_sympal_comment' => array(
     'subject' => 'Test',
     'body' => 'Test',
   )), array('_with_csrf' => true))

Modified: plugins/sfSympalPlugin/trunk/test/unit/ContentTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/unit/ContentTest.php      2010-01-15 
21:11:40 UTC (rev 26696)
+++ plugins/sfSympalPlugin/trunk/test/unit/ContentTest.php      2010-01-15 
21:58:50 UTC (rev 26697)
@@ -3,7 +3,7 @@
 $app = 'sympal';
 require_once(dirname(__FILE__).'/../bootstrap/unit.php');
 
-$t = new lime_test(37, new lime_output_color());
+$t = new lime_test(38, new lime_output_color());
 
 $user = new sfGuardUser();
 $user->first_name = 'test';
@@ -110,7 +110,8 @@
 
 $t->is($content->title, 'Title value');
 $t->is($slots['title']['value'], 'Title value');
-$t->is($slots['title']['type'], 'ContentProperty');
+$t->is($slots['title']['type'], 'Text');
+$t->is($slots['title']['is_column'], true);
 $t->is($slots['body']['type'], 'Markdown');
 $t->is($slots['teaser']['type'], 'RawHtml');
 

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.


Reply via email to