This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

unit tests for creating label

  • Loading branch information...
nprasath002 committed Oct 13, 2012
1 parent 5d85471 commit 04b9d65eca4dc7211045818d0ebc33748ca0080d
Showing with 51 additions and 0 deletions.
  1. +51 −0 tests/suites/unit/joomla/github/JGithubIssuesTest.php
@@ -173,6 +173,57 @@ public function testCreateCommentFailure()
$this->object->createComment('joomla', 'joomla-platform', 523, 'My Insightful Comment');
}
+ /**
+ * Tests the createLabel method
+ *
+ * @return void
+ */
+ public function testCreateLabel()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 201;
+ $returnData->body = $this->sampleString;
+
+ $issue = new stdClass;
+ $issue->name = 'Label';
+ $issue->color = 'blue';
+
+ $this->client->expects($this->once())
+ ->method('post')
+ ->with('/repos/joomla/joomla-platform/labels', json_encode($issue))
+ ->will($this->returnValue($returnData));
+
+ $this->assertThat(
+ $this->object->createLabel('joomla', 'joomla-platform', 'Label', 'blue'),
+ $this->equalTo(json_decode($this->sampleString))
+ );
+ }
+
+ /**
+ * Tests the createLabel method - failure
+ *
+ * @expectedException DomainException
+ *
+ * @return void
+ */
+ public function testCreateLabelFailure()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 501;
+ $returnData->body = $this->errorString;
+
+ $issue = new stdClass;
+ $issue->name = 'Label';
+ $issue->color = 'green';
+
+ $this->client->expects($this->once())
+ ->method('post')
+ ->with('/repos/joomla/joomla-platform/labels', json_encode($issue))
+ ->will($this->returnValue($returnData));
+
+ $this->object->createLabel('joomla', 'joomla-platform', 'Label', 'blue');
+ }
+
/**
* Tests the deleteComment method
*

0 comments on commit 04b9d65

Please sign in to comment.