| <?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', 'genie@eclipse.org', 'blahblah'); |
| } |
| |
| function tearDown() { |
| $this->client->logout(); |
| } |
| |
| function testSuccessfulLogin() { |
| $this->client->login(); |
| $this->assertTrue($this->client->isLoggedIn()); |
| } |
| |
| function testInvalidPasswordLogin() { |
| $client = new BugzillaClient('http://localhost/bugzilla', 'genie@eclipse.org', 'wrongpassword'); |
| try { |
| $client->login(); |
| $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', 'genie@eclipse.org', 'wrongpassword'); |
| try { |
| $client->login(); |
| $this->fail("An exception should have been thrown!"); |
| } catch (Exception $e) { |
| $this->assertTrue(preg_match('/HTTP\/1\.1 404 Not Found/', $e->getMessage())); |
| } |
| } |
| |
| function testCreateABug() { |
| $this->client->login(); |
| $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(); |
| echo $bug->getId(); |
| $this->assertNotNull($bug->getId()); |
| } |
| |
| function testCreateABugWithAttachment() { |
| $this->fail("Not implemented!"); |
| return; |
| |
| $bug = $this->client |
| ->startBug('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(); |
| |
| $attachment = $bug->startAttachment() |
| ->setFileName('test.txt') |
| ->setContent('The quick brown fox jumped over the lazy dog') |
| ->create(); |
| |
| $this->assertNotNull($attachment->getId()); |
| } |
| } |
| |
| $runner = new TextTestRunner('BugzillaClientTests'); |
| $runner->run_tests(); |
| ?> |