Skip to content

Commit 49a3780

Browse files
committed
Merge pull request #47 from juvenn/v0.2
修复关联文件的对象保存时的语法错误
2 parents 91283c0 + df9daea commit 49a3780

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
0.2.2 发布日期:2016-01-06
3+
----
4+
5+
* 修复保存关联文件的对象时的语法错误 close #46
6+
27
0.2.1 发布日期:2015-12-31
38
----
49

src/LeanCloud/LeanClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LeanClient {
2222
/**
2323
* Client version
2424
*/
25-
const VERSION = '0.2.1';
25+
const VERSION = '0.2.2';
2626

2727
/**
2828
* API Endpoints for Regions

src/LeanCloud/LeanObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public static function saveAll($objects) {
583583
$children = array(); // Array of unsaved objects excluding files
584584
forEach($unsavedChildren as $obj) {
585585
if ($obj instanceof LeanFile) {
586-
$obj.save();
586+
$obj->save();
587587
} else if ($obj instanceof LeanObject) {
588588
if (!in_array($obj, $children)) {
589589
$children[] = $obj;

tests/LeanFileTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use LeanCloud\LeanObject;
34
use LeanCloud\LeanClient;
45
use LeanCloud\LeanFile;
56

@@ -90,5 +91,24 @@ public function testMetaData() {
9091

9192
$file->destroy();
9293
}
94+
95+
/*
96+
* leancloud/php-sdk#46
97+
*/
98+
public function testSaveObjectWithFile() {
99+
$obj = new LeanObject("TestObject");
100+
$obj->set("name", "alice");
101+
102+
$file = LeanFile::createWithData("test.txt", "你好,中国!");
103+
$obj->addIn("files", $file);
104+
$obj->save();
105+
106+
$this->assertNotEmpty($obj->getObjectId());
107+
$this->assertNotEmpty($file->getObjectId());
108+
$this->assertNotEmpty($file->getUrl());
109+
110+
$file->destroy();
111+
$obj->destroy();
112+
}
93113
}
94114

0 commit comments

Comments
 (0)