-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #11039: mc_issue_attachment_get() returns garbage
This commits adds a test which verifies that the contents of an attachment is properly encoded and decoded.
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
# MantisBT - a php based bugtracking system | ||
|
||
# MantisBT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MantisBT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package Tests | ||
* @subpackage UnitTests | ||
* @copyright Copyright (C) 2002 - 2009 MantisBT Team - mantisbt-dev@lists.sourceforge.net | ||
* @link http://www.mantisbt.org | ||
*/ | ||
|
||
require_once 'SoapBase.php'; | ||
|
||
/** | ||
* Test fixture for attachment methods | ||
*/ | ||
class AttachmentTest extends SoapBase { | ||
/** | ||
* A test case that tests the following: | ||
* 1. Create an issue. | ||
* 2. Adds at attachemnt | ||
* 3. Get the issue. | ||
* 4. Verify that the attachment is present in the issue data | ||
* 5. Verify that the attachment contents is correct | ||
*/ | ||
public function testAttachmentIsAdded() { | ||
$issueToAdd = $this->getIssueToAdd( 'AttachmentTest.testAttachmentIsAdded' ); | ||
|
||
$attachmentContents = 'Attachment contents.'; | ||
|
||
$issueId = $this->client->mc_issue_add( | ||
$this->userName, | ||
$this->password, | ||
$issueToAdd); | ||
|
||
$this->deleteAfterRun( $issueId ); | ||
|
||
$attachmentId = $this->client->mc_issue_attachment_add( | ||
$this->userName, | ||
$this->password, | ||
$issueId, | ||
'sample.txt', | ||
'txt', | ||
base64_encode( $attachmentContents ) | ||
); | ||
|
||
$issue = $this->client->mc_issue_get( | ||
$this->userName, | ||
$this->password, | ||
$issueId | ||
); | ||
|
||
$attachment = $this->client->mc_issue_attachment_get( | ||
$this->userName, | ||
$this->password, | ||
$attachmentId); | ||
|
||
$this->assertEquals( 1, count( $issue->attachments ), 'count($issue->attachments)' ); | ||
$this->assertEquals( $attachmentContents, $attachment, '$attachmentContents' ); | ||
} | ||
} |