コード例 #1
0
 public function testCanCatchError()
 {
     $fogbugz = new FogBugz($this->user, $this->pass, $this->url);
     // swap out or connection object
     $fogbugz->curl = $this->getMock('FogBugzCurl');
     // set the xml we would expect to see on a login
     $fogbugz->curl->expects($this->any())->method('fetch')->will($this->returnValue(file_get_contents(__DIR__ . '/data/error.xml')));
     try {
         $fogbugz->startWork(array("ixBug" => 213));
     } catch (FogBugzAPIError $expected) {
         $this->assertEquals(3, $expected->getCode(), "Error code was not processed correctly");
         $this->assertEquals("Not logged on", $expected->getMessage(), "Error message was not processed correctly");
         return;
     }
     $this->fail("An exception was not raised");
 }