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

unit test for getting labels

  • Loading branch information...
nprasath002 committed Oct 13, 2012
1 parent 7dba0df commit 534b55b207e0e8480b7e32c918784d8713c1ceef
Showing with 86 additions and 0 deletions.
  1. +86 −0 tests/suites/unit/joomla/github/JGithubIssuesTest.php
@@ -591,6 +591,92 @@ public function testGetCommentsFailure()
$this->object->getComments('joomla', 'joomla-platform', 523);
}
+ /**
+ * Tests the getLabel method
+ *
+ * @return void
+ */
+ public function testGetLabel()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 200;
+ $returnData->body = $this->sampleString;
+
+ $this->client->expects($this->once())
+ ->method('get')
+ ->with('/repos/joomla/joomla-platform/labels/My Insightful Label')
+ ->will($this->returnValue($returnData));
+
+ $this->assertThat(
+ $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label'),
+ $this->equalTo(json_decode($this->sampleString))
+ );
+ }
+
+ /**
+ * Tests the getLabel method - failure
+ *
+ * @expectedException DomainException
+ *
+ * @return void
+ */
+ public function testGetLabelFailure()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 500;
+ $returnData->body = $this->errorString;
+
+ $this->client->expects($this->once())
+ ->method('get')
+ ->with('/repos/joomla/joomla-platform/issues/comments/523')
+ ->will($this->returnValue($returnData));
+
+ $this->object->getLabel('joomla', 'joomla-platform', 'My Insightful Label');
+ }
+
+ /**
+ * Tests the getLabels method
+ *
+ * @return void
+ */
+ public function testGetLabels()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 200;
+ $returnData->body = $this->sampleString;
+
+ $this->client->expects($this->once())
+ ->method('get')
+ ->with('/repos/joomla/joomla-platform/labels')
+ ->will($this->returnValue($returnData));
+
+ $this->assertThat(
+ $this->object->getLabels('joomla', 'joomla-platform'),
+ $this->equalTo(json_decode($this->sampleString))
+ );
+ }
+
+ /**
+ * Tests the getLabels method - failure
+ *
+ * @expectedException DomainException
+ *
+ * @return void
+ */
+ public function testGetLabelsFailure()
+ {
+ $returnData = new stdClass;
+ $returnData->code = 500;
+ $returnData->body = $this->errorString;
+
+ $this->client->expects($this->once())
+ ->method('get')
+ ->with('/repos/joomla/joomla-platform/labels')
+ ->will($this->returnValue($returnData));
+
+ $this->object->getLabels('joomla', 'joomla-platform');
+ }
+
/**
* Tests the getList method
*

0 comments on commit 534b55b

Please sign in to comment.