コード例 #1
0
ファイル: FileTest.php プロジェクト: juvenn/php-sdk
 public function testSaveObjectWithFile()
 {
     $obj = new Object("TestObject");
     $obj->set("name", "alice");
     $file = File::createWithData("test.txt", "你好,中国!");
     $obj->addIn("files", $file);
     $obj->save();
     $this->assertNotEmpty($obj->getObjectId());
     $this->assertNotEmpty($file->getObjectId());
     $this->assertNotEmpty($file->getUrl());
     $file->destroy();
     $obj->destroy();
 }
コード例 #2
0
ファイル: ObjectTest.php プロジェクト: juvenn/php-sdk
 public function testDeleteField()
 {
     $obj = new Object("TestObject");
     $obj->delete("tags");
     $this->assertNull($obj->get("tags"));
     $obj->set("tags", array("frontend", "javascript"));
     $this->assertEquals(array("frontend", "javascript"), $obj->get("tags"));
     $obj->delete("tags");
     $this->assertNull($obj->get("tags"));
     $obj->addIn("tags", "frontend");
     $this->assertEquals(array("frontend"), $obj->get("tags"));
 }
コード例 #3
0
ファイル: ClientTest.php プロジェクト: juvenn/php-sdk
 public function testEncodeCircularObjectAsPointer()
 {
     $a = new Object("TestObject", "id001");
     $b = new Object("TestObject", "id002");
     $c = new Object("TestObject", "id003");
     $a->set("name", "A");
     $b->set("name", "B");
     $c->set("name", "C");
     $a->addIn("likes", $b);
     $b->addIn("likes", $c);
     $c->addIn("likes", $a);
     $jsonA = Client::encode($a, "toFullJSON");
     $jsonB = $jsonA["likes"][0];
     $jsonC = $jsonB["likes"][0];
     $this->assertEquals("Object", $jsonA["__type"]);
     $this->assertEquals("Object", $jsonB["__type"]);
     $this->assertEquals("Object", $jsonC["__type"]);
     $this->assertEquals("Pointer", $jsonC["likes"][0]["__type"]);
 }