Author: FabianLange
Date: 2010-02-22 14:57:40 +0100 (Mon, 22 Feb 2010)
New Revision: 28184

Modified:
   components/yaml/trunk/lib/sfYamlParser.php
   components/yaml/trunk/test/fixtures/sfTests.yml
   components/yaml/trunk/test/sfYamlParserTest.php
Log:
[yaml] updated unit test to cover r28183

Modified: components/yaml/trunk/lib/sfYamlParser.php
===================================================================
--- components/yaml/trunk/lib/sfYamlParser.php  2010-02-22 13:33:56 UTC (rev 
28183)
+++ components/yaml/trunk/lib/sfYamlParser.php  2010-02-22 13:57:40 UTC (rev 
28184)
@@ -26,7 +26,6 @@
 class sfYamlParser
 {
   protected
-    $value         = '',
     $offset        = 0,
     $lines         = array(),
     $currentLineNb = -1,
@@ -54,10 +53,9 @@
    */
   public function parse($value)
   {
-    $this->value = $this->cleanup($value);
     $this->currentLineNb = -1;
     $this->currentLine = '';
-    $this->lines = explode("\n", $this->value);
+    $this->lines = explode("\n", $this->cleanup($value));
 
     $data = array();
     while ($this->moveToNextLine())
@@ -198,8 +196,8 @@
       }
       else
       {
-        // one liner?
-        if (1 == count(explode("\n", rtrim($this->value, "\n"))))
+        // 1-liner followed by newline
+        if (2 == count($this->lines) && empty($this->lines[1]))
         {
           $value = sfYamlInline::load($this->lines[0]);
           if (is_array($value))

Modified: components/yaml/trunk/test/fixtures/sfTests.yml
===================================================================
--- components/yaml/trunk/test/fixtures/sfTests.yml     2010-02-22 13:33:56 UTC 
(rev 28183)
+++ components/yaml/trunk/test/fixtures/sfTests.yml     2010-02-22 13:57:40 UTC 
(rev 28184)
@@ -13,6 +13,12 @@
 php: |
     array('foo' => array())
 ---
+test: Empty value
+yaml: |
+    foo:
+php: |
+    array('foo' => null)
+---
 test: Inline string parsing
 brief: >
     Inline string parsing

Modified: components/yaml/trunk/test/sfYamlParserTest.php
===================================================================
--- components/yaml/trunk/test/sfYamlParserTest.php     2010-02-22 13:33:56 UTC 
(rev 28183)
+++ components/yaml/trunk/test/sfYamlParserTest.php     2010-02-22 13:57:40 UTC 
(rev 28184)
@@ -14,7 +14,7 @@
 
 sfYaml::setSpecVersion('1.1');
 
-$t = new lime_test(148);
+$t = new lime_test(149);
 
 $parser = new sfYamlParser();
 

-- 
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