[Pkg-owncloud-commits] [php-sabredav] 88/148: Tests for getlastmodified.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:20 UTC 2015


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

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

commit 5d45df37dbced3644a62920425da6ea9de8d095f
Author: Evert Pot <me at evertpot.com>
Date:   Tue Mar 24 11:55:48 2015 -0400

    Tests for getlastmodified.
---
 lib/DAV/Xml/Property/GetLastModified.php          | 12 ++-----
 tests/Sabre/DAV/Xml/Property/LastModifiedTest.php | 41 +++++++++++++++++++++++
 2 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/lib/DAV/Xml/Property/GetLastModified.php b/lib/DAV/Xml/Property/GetLastModified.php
index b7e04d9..6551cf1 100644
--- a/lib/DAV/Xml/Property/GetLastModified.php
+++ b/lib/DAV/Xml/Property/GetLastModified.php
@@ -14,12 +14,6 @@ use
  * Defined in:
  * http://tools.ietf.org/html/rfc4918#section-15.7
  *
- * Although this is normally a simple property, windows requires us to add
- * some new attributes.
- *
- * This class uses unix timestamps internally, and converts them to RFC 1123 times for
- * serialization
- *
  * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
  * @author Evert Pot (http://www.rooftopsolutions.nl/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
@@ -41,11 +35,9 @@ class GetLastModified implements Element {
     public function __construct($time) {
 
         if ($time instanceof \DateTime) {
-            $this->time = $time;
-        } elseif (is_int($time) || ctype_digit($time)) {
-            $this->time = new \DateTime('@' . $time);
+            $this->time = clone $time;
         } else {
-            $this->time = new \DateTime($time);
+            $this->time = new \DateTime('@' . $time);
         }
 
         // Setting timezone to UTC
diff --git a/tests/Sabre/DAV/Xml/Property/LastModifiedTest.php b/tests/Sabre/DAV/Xml/Property/LastModifiedTest.php
new file mode 100644
index 0000000..eb6c1c7
--- /dev/null
+++ b/tests/Sabre/DAV/Xml/Property/LastModifiedTest.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\DAV\Xml\XmlTest;
+use DateTime;
+use DateTimeZone;
+
+class GetLastModifiedTest extends XmlTest {
+
+    function testSerializeDateTime() {
+
+        $dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
+        $val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
+
+        $result = $this->write($val);
+        $expected = <<<XML
+<?xml version="1.0"?>
+<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
+XML;
+
+        $this->assertXmlStringEqualsXmlString($expected, $result);
+
+    }
+
+    function testSerializeTimeStamp() {
+
+        $dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
+        $dt = $dt->getTimeStamp();
+        $val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
+
+        $result = $this->write($val);
+        $expected = <<<XML
+<?xml version="1.0"?>
+<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
+XML;
+
+        $this->assertXmlStringEqualsXmlString($expected, $result);
+
+    }
+}

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



More information about the Pkg-owncloud-commits mailing list