소스 검색

Merged: ZF-12324
Updated Zend_Mobile_Push_Message_Gcm to enforce the toJson method to return collapse key as a string

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25022 44c647ce-9c0f-0410-b52a-842ac1e357ba

digitalstruct 13 년 전
부모
커밋
401084dbf0
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      library/Zend/Mobile/Push/Message/Gcm.php
  2. 7 0
      tests/Zend/Mobile/Push/Message/GcmTest.php

+ 1 - 1
library/Zend/Mobile/Push/Message/Gcm.php

@@ -257,7 +257,7 @@ class Zend_Mobile_Push_Message_Gcm extends Zend_Mobile_Push_Message_Abstract
             $json['registration_ids'] = $this->_token;
         }
         if ($this->_id) {
-            $json['collapse_key'] = $this->_id;
+            $json['collapse_key'] = (string) $this->_id;
         }
         if ($this->_data) {
             $json['data'] = $this->_data;

+ 7 - 0
tests/Zend/Mobile/Push/Message/GcmTest.php

@@ -137,4 +137,11 @@ class Zend_Mobile_Push_Message_GcmTest extends PHPUnit_Framework_TestCase
         $msg->setTtl(10);
         $this->assertFalse($msg->validate());
     }
+
+    public function testToJsonIntCollapseKeyEncodedAsString()
+    {
+        $msg = new Zend_Mobile_Push_Message_Gcm();
+        $msg->setId(10);
+        $this->assertEquals('{"collapse_key":"10"}', $msg->toJson());
+    }
 }