|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Redmine\Tests; |
| 4 | + |
| 5 | +use Redmine\Client; |
| 6 | +use Redmine\Exception\InvalidArgumentException; |
| 7 | + |
| 8 | +class ClientTest extends \PHPUnit_Framework_TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @test |
| 12 | + */ |
| 13 | + public function shouldPassApiKeyToContructor() |
| 14 | + { |
| 15 | + $client = new Client('http://test.local', 'asdf'); |
| 16 | + |
| 17 | + $this->assertInstanceOf('Redmine\Client', $client); |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * @test |
| 22 | + */ |
| 23 | + public function shouldPassUsernameAndPasswordToContructor() |
| 24 | + { |
| 25 | + $client = new Client('http://test.local', 'username', 'pwd'); |
| 26 | + |
| 27 | + $this->assertInstanceOf('Redmine\Client', $client); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @test |
| 32 | + * @expectedException InvalidArgumentException |
| 33 | + */ |
| 34 | + public function shouldNotGetApiInstance() |
| 35 | + { |
| 36 | + $client = new Client('http://test.local', 'asdf'); |
| 37 | + $client->api('do_not_exist'); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @test |
| 42 | + * @dataProvider getApiClassesProvider |
| 43 | + */ |
| 44 | + public function shouldGetApiInstance($apiName, $class) |
| 45 | + { |
| 46 | + $client = new Client('http://test.local', 'asdf'); |
| 47 | + $this->assertInstanceOf($class, $client->api($apiName)); |
| 48 | + } |
| 49 | + |
| 50 | + public function getApiClassesProvider() |
| 51 | + { |
| 52 | + return array( |
| 53 | + array('attachment', 'Redmine\Api\Attachment'), |
| 54 | + array('group', 'Redmine\Api\Group'), |
| 55 | + array('custom_fields', 'Redmine\Api\CustomField'), |
| 56 | + array('issue', 'Redmine\Api\Issue'), |
| 57 | + array('issue_category', 'Redmine\Api\IssueCategory'), |
| 58 | + array('issue_priority', 'Redmine\Api\IssuePriority'), |
| 59 | + array('issue_relation', 'Redmine\Api\IssueRelation'), |
| 60 | + array('issue_status', 'Redmine\Api\IssueStatus'), |
| 61 | + array('membership', 'Redmine\Api\Membership'), |
| 62 | + array('news', 'Redmine\Api\News'), |
| 63 | + array('project', 'Redmine\Api\Project'), |
| 64 | + array('query', 'Redmine\Api\Query'), |
| 65 | + array('role', 'Redmine\Api\Role'), |
| 66 | + array('time_entry', 'Redmine\Api\TimeEntry'), |
| 67 | + array('time_entry_activity', 'Redmine\Api\TimeEntryActivity'), |
| 68 | + array('tracker', 'Redmine\Api\Tracker'), |
| 69 | + array('user', 'Redmine\Api\User'), |
| 70 | + array('version', 'Redmine\Api\Version'), |
| 71 | + array('wiki', 'Redmine\Api\Wiki'), |
| 72 | + ); |
| 73 | + } |
| 74 | +} |
0 commit comments