function test_get_attachment() { RemoteSyncPlugin::instance()->install(); $api = new RemoteSyncApi(); $id = wp_insert_post(array("post_title" => "hello", "post_type" => "attachment", "post_content" => "something", "post_name" => "test-attachment")); update_post_meta($id, "_wp_attached_file", "helloworld"); $upload_dir_info = wp_upload_dir(); file_put_contents($upload_dir_info["basedir"] . "/helloworld", "content"); $syncer = RemoteSyncPlugin::instance()->getSyncerByType("attachment"); $attachments = $syncer->getResourceAttachments("test-attachment"); $this->assertEquals($attachments, array("helloworld")); $res = $api->ls(array("type" => "attachment")); $this->assertCount(1, $res); $this->assertEquals($res[0]["slug"], "test-attachment"); $resource = $api->get(array("slug" => "test-attachment", "type" => "attachment")); $this->assertEquals(sizeof($resource["attachments"]), 1); $this->assertEquals($resource["attachments"][0], array("fileName" => "helloworld", "fileSize" => 7)); }