aboutsummaryrefslogtreecommitdiff
path: root/php/tests
diff options
context:
space:
mode:
authorLeonard Hecker <leonard@hecker.io>2018-07-20 22:03:00 +0200
committerPaul Yang <TeBoring@users.noreply.github.com>2018-07-20 13:03:00 -0700
commite7746f487cb9cca685ffb1b3d7dccc5554b618a4 (patch)
tree851e32ef5032765a8ad61c30b212aefc5f12703a /php/tests
parent656f64ec0b5dff6816886d66a0124ab4f8d1fd4b (diff)
downloadprotobuf-e7746f487cb9cca685ffb1b3d7dccc5554b618a4.tar.gz
protobuf-e7746f487cb9cca685ffb1b3d7dccc5554b618a4.tar.bz2
protobuf-e7746f487cb9cca685ffb1b3d7dccc5554b618a4.zip
php: Added nanosecond support for Timestamp (#3972)
* php: Added nanosecond support for Timestamp * php: Fixed compatibility test
Diffstat (limited to 'php/tests')
-rwxr-xr-xphp/tests/compatibility_test.sh1
-rw-r--r--php/tests/memory_leak_test.php2
-rw-r--r--php/tests/well_known_test.php3
3 files changed, 4 insertions, 2 deletions
diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh
index b377d85c..c4d6325d 100755
--- a/php/tests/compatibility_test.sh
+++ b/php/tests/compatibility_test.sh
@@ -124,6 +124,7 @@ sed -i.bak '/php_implementation_test.php/d' phpunit.xml
sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml
sed -i.bak 's/generated_phpdoc_test.php//g' tests/test.sh
sed -i.bak '/memory_leak_test.php/d' tests/test.sh
+sed -i.bak '/^ public function testTimestamp()$/,/^ }$/d' tests/well_known_test.php
for t in "${tests[@]}"
do
remove_error_test tests/$t
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 4e3874b7..f3bcb963 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -152,7 +152,7 @@ date_default_timezone_set('UTC');
$from = new DateTime('2011-01-01T15:03:01.012345UTC');
$timestamp->fromDateTime($from);
assert($from->format('U') == $timestamp->getSeconds());
-assert(0 == $timestamp->getNanos());
+assert(1000 * $from->format('u') == $timestamp->getNanos());
$to = $timestamp->toDateTime();
assert(\DateTime::class == get_class($to));
diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php
index 1e8c4f42..9f2661fa 100644
--- a/php/tests/well_known_test.php
+++ b/php/tests/well_known_test.php
@@ -312,11 +312,12 @@ class WellKnownTest extends TestBase {
$from = new DateTime('2011-01-01T15:03:01.012345UTC');
$timestamp->fromDateTime($from);
$this->assertEquals($from->format('U'), $timestamp->getSeconds());
- $this->assertSame(0, $timestamp->getNanos());
+ $this->assertEquals(1000 * $from->format('u'), $timestamp->getNanos());
$to = $timestamp->toDateTime();
$this->assertSame(\DateTime::class, get_class($to));
$this->assertSame($from->format('U'), $to->format('U'));
+ $this->assertSame($from->format('u'), $to->format('u'));
}
public function testType()