Skip to content

Commit

Permalink
Include 'path' property in new linked_file attachment template
Browse files Browse the repository at this point in the history
And add tests for other attachment templates
  • Loading branch information
dstillman authored and uniuuu committed May 7, 2023
1 parent e48359e commit 9cf2e10
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controllers/MappingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ public function newItem() {
$json['contentType'] = '';
$json['charset'] = '';

if ($linkModeName == 'linked_file') {
$json['path'] = '';
}

if (preg_match('/^imported_/', $linkModeName)) {
$json['filename'] = '';
$json['md5'] = null;
Expand Down
27 changes: 27 additions & 0 deletions tests/remote/tests/API/3/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,33 @@ public function testNewTopLevelImportedFileAttachment() {
}


public function testNewItemTemplateAttachmentFields() {
$response = API::get("items/new?itemType=attachment&linkMode=linked_url");
$json = json_decode($response->getBody());
$this->assertSame('', $json->url);
$this->assertObjectNotHasAttribute('filename', $json);
$this->assertObjectNotHasAttribute('path', $json);

$response = API::get("items/new?itemType=attachment&linkMode=linked_file");
$json = json_decode($response->getBody());
$this->assertSame('', $json->path);
$this->assertObjectNotHasAttribute('filename', $json);
$this->assertObjectNotHasAttribute('url', $json);

$response = API::get("items/new?itemType=attachment&linkMode=imported_url");
$json = json_decode($response->getBody());
$this->assertSame('', $json->filename);
$this->assertSame('', $json->url);
$this->assertObjectNotHasAttribute('path', $json);

$response = API::get("items/new?itemType=attachment&linkMode=imported_file");
$json = json_decode($response->getBody());
$this->assertSame('', $json->filename);
$this->assertObjectNotHasAttribute('path', $json);
$this->assertObjectNotHasAttribute('url', $json);
}


/*
Disabled -- see note at Zotero_Item::checkTopLevelAttachment()
Expand Down

0 comments on commit 9cf2e10

Please sign in to comment.