[Pkg-owncloud-commits] [php-sabre-vobject] 38/43: Additional changes to deal with empty parameters correctly.

David Prévot taffit at moszumanska.debian.org
Fri Oct 10 14:16:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 381866e248dd779211048b9dfec760d065b9e6e1
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Sat Oct 4 22:49:27 2014 +0100

    Additional changes to deal with empty parameters correctly.
    
    Issue #151
---
 lib/Parameter.php                         |  2 +-
 tests/VObject/EmptyParameterTest.php      | 69 +++++++++++++++++++++++++++++++
 tests/VObject/Issue154Test.php            | 29 -------------
 tests/VObject/IssueEmptyParameterTest.php | 32 --------------
 tests/VObject/ParameterTest.php           |  2 +-
 5 files changed, 71 insertions(+), 63 deletions(-)

diff --git a/lib/Parameter.php b/lib/Parameter.php
index c9de363..f13bcd0 100644
--- a/lib/Parameter.php
+++ b/lib/Parameter.php
@@ -281,7 +281,7 @@ class Parameter extends Node {
         $value = $this->getParts();
 
         if (count($value)===0) {
-            return $this->name;
+            return $this->name . '=';
         }
 
         if ($this->root->getDocumentType() === Document::VCARD21 && $this->noName) {
diff --git a/tests/VObject/EmptyParameterTest.php b/tests/VObject/EmptyParameterTest.php
new file mode 100644
index 0000000..0dc1d69
--- /dev/null
+++ b/tests/VObject/EmptyParameterTest.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Sabre\VObject;
+
+class IssueEmptyParameterTest extends \PHPUnit_Framework_TestCase {
+
+    function testRead() {
+
+        $input = <<<VCF
+BEGIN:VCARD
+VERSION:2.1
+N:Doe;Jon;;;
+FN:Jon Doe
+EMAIL;X-INTERN:foo at example.org
+UID:foo
+END:VCARD
+VCF;
+
+        $vcard = Reader::read($input);
+
+        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
+        $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
+        $vcard = $vcard->serialize();
+
+        $converted = Reader::read($vcard);
+        $converted->validate();
+
+        $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
+
+        $version = Version::VERSION;
+
+        $expected = <<<VCF
+BEGIN:VCARD
+VERSION:3.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+N:Doe;Jon;;;
+FN:Jon Doe
+EMAIL;X-INTERN=:foo at example.org
+UID:foo
+END:VCARD
+
+VCF;
+
+        $this->assertEquals($expected, str_replace("\r","", $vcard));
+
+    }
+
+    function testVCard21Parameter() {
+
+        $vcard = new Component\VCard(array(), false);
+        $vcard->VERSION = '2.1';
+        $vcard->PHOTO = 'random_stuff';
+        $vcard->PHOTO->add(null,'BASE64');
+        $vcard->UID = 'foo-bar';
+
+        $result = $vcard->serialize();
+        $expected = array(
+            "BEGIN:VCARD",
+            "VERSION:2.1",
+            "PHOTO;BASE64:" . base64_encode('random_stuff'),
+            "UID:foo-bar",
+            "END:VCARD",
+            "",
+        );
+
+        $this->assertEquals(implode("\r\n", $expected), $result);
+
+    }
+}
diff --git a/tests/VObject/Issue154Test.php b/tests/VObject/Issue154Test.php
deleted file mode 100644
index ae3a3e8..0000000
--- a/tests/VObject/Issue154Test.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Sabre\VObject;
-
-class Issue154Test extends \PHPUnit_Framework_TestCase {
-
-    function testStuff() {
-
-        $vcard = new Component\VCard(array(), false);
-        $vcard->VERSION = '3.0';
-        $vcard->PHOTO = 'random_stuff';
-        $vcard->PHOTO->add('BASE64',null);
-        $vcard->UID = 'foo-bar';
-
-        $result = $vcard->serialize();
-        $expected = array(
-            "BEGIN:VCARD",
-            "VERSION:3.0",
-            "PHOTO;BASE64:" . base64_encode('random_stuff'),
-            "UID:foo-bar",
-            "END:VCARD",
-            "",
-        );
-
-        $this->assertEquals(implode("\r\n", $expected), $result);
-
-    }
-
-}
diff --git a/tests/VObject/IssueEmptyParameterTest.php b/tests/VObject/IssueEmptyParameterTest.php
deleted file mode 100644
index 3f28597..0000000
--- a/tests/VObject/IssueEmptyParameterTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-namespace Sabre\VObject;
-
-class IssueEmptyParameterTest extends \PHPUnit_Framework_TestCase {
-
-    function testRead() {
-
-        $input = <<<VCF
-BEGIN:VCARD
-VERSION:2.1
-N:Doe;Jon;;;
-FN:Jon Doe
-EMAIL;X-INTERN:foo at example.org
-UID:foo
-END:VCARD
-VCF;
-
-        $vcard = Reader::read($input);
-
-        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
-        $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
-        $vcard = $vcard->serialize();
-
-        $converted = Reader::read($vcard);
-        $converted->validate();
-
-        $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
-
-    }
-
-}
diff --git a/tests/VObject/ParameterTest.php b/tests/VObject/ParameterTest.php
index 2aabd0e..96f016d 100644
--- a/tests/VObject/ParameterTest.php
+++ b/tests/VObject/ParameterTest.php
@@ -75,7 +75,7 @@ class ParameterTest extends \PHPUnit_Framework_TestCase {
 
         $cal = new Component\VCalendar();
         $param = new Parameter($cal, 'name', null);
-        $this->assertEquals('NAME',$param->serialize());
+        $this->assertEquals('NAME=',$param->serialize());
 
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list