Skip to content

Commit

Permalink
Issue #11039: mc_issue_attachment_get() returns garbage
Browse files Browse the repository at this point in the history
This commits adds a test which verifies that the contents of an
attachment is properly encoded and decoded.
  • Loading branch information
rombert committed Oct 29, 2009
1 parent 42b7a5d commit d880d59
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/soap/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require_once 'IssueNoteTest.php';
require_once 'IssueUpdateTest.php';
require_once 'FilterTest.php';
require_once 'AttachmentTest.php';

/**
* @package Tests
Expand Down Expand Up @@ -59,6 +60,7 @@ public static function suite()
$suite->addTestSuite('IssueNoteTest');
$suite->addTestSuite('IssueUpdateTest');
$suite->addTestSuite('FilterTest');
$suite->addTestSuite('AttachmentTest');

return $suite;
}
Expand Down
73 changes: 73 additions & 0 deletions tests/soap/AttachmentTest.php
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' );
}
}

0 comments on commit d880d59

Please sign in to comment.