| <?php |
| include dirname(__FILE__) . '/../classes/BugzillaClient.class.inc'; |
| include dirname(__FILE__) . '/../classes/TestRunner.class.php'; |
| |
| /* |
| * These tests require a Bugzilla instance as follows: |
| * - URL: http://localhost/bugzilla |
| * - username: wayne@eclipse.org |
| * - username: genie@eclipse.org password: blahblah |
| */ |
| |
| class BugzillaClientTests extends TestCase { |
| var $client; |
| |
| function setUp() { |
| $this->client = new BugzillaClient('http://localhost/bugzilla'); |
| } |
| |
| function tearDown() { |
| $this->client->logout(); |
| } |
| |
| function testSuccessfulLogin() { |
| $this->client->login('genie@eclipse.org', 'blahblah'); |
| $this->assertTrue($this->client->isLoggedIn()); |
| } |
| |
| function testInvalidPasswordLogin() { |
| try { |
| $this->client->login('genie@eclipse.org', 'blahblahblah'); |
| $this->fail("An exception should have been thrown!"); |
| } catch (BugzillaInvalidCredentialsException $e) { |
| $this->assertEquals("Invalid Username Or Password", $e->getMessage()); |
| } |
| } |
| |
| function testInvalidHost() { |
| $client = new BugzillaClient('http://localhost/bogus'); |
| try { |
| $client->login('genie@eclipse.org', 'blahblah'); |
| $this->fail("An exception should have been thrown!"); |
| } catch (Exception $e) { |
| $this->assertTrue(preg_match('/404/', $e->getMessage())); |
| } |
| } |
| |
| function testCreateABug() { |
| $this->client->login('genie@eclipse.org', 'blahblah'); |
| $bug = $this->client |
| ->startBug('TestProduct', 'TestComponent', 'A test bug') |
| ->addParagraph('Now is the time for all good folks to come to the aid of the party') |
| ->addCC('wayne@eclipse.org') |
| ->create(); |
| $this->assertNotNull($bug->getId()); |
| } |
| |
| function testCreateABugWithAttachment() { |
| $this->client->login('genie@eclipse.org', 'blahblah'); |
| $bug = $this->client |
| ->startBug('TestProduct', 'TestComponent', 'A test bug with an attachment') |
| ->addParagraph('Now is the time for all good folks to come to the aid of the party') |
| ->addCC('wayne@eclipse.org') |
| ->create(); |
| |
| echo "**** Bug created: $bug->id \n"; |
| |
| $attachment = $bug->startAttachment() |
| ->setFile('/home/wayne/Downloads/technology.sisu-0.2-iplog.html') |
| ->setDescription('The quick brown fox jumped over the lazy dog') |
| ->create(); |
| |
| echo "**** Attachment created: $attachment->id \n"; |
| |
| //$this->assertNotNull($attachment->getId()); |
| } |
| } |
| |
| $runner = new TextTestRunner('BugzillaClientTests'); |
| $runner->run_tests(); |
| ?> |