Skip to content
Snippets Groups Projects
Commit f7c1ab43 authored by Kevin Saliou's avatar Kevin Saliou
Browse files

add basic class instanciation tests

parent b4ca8d5c
Branches
Tags v1.1.1
No related merge requests found
vendor
phpunit.xml
composer.lock
composer.phar
vendor
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="test/bootstrap.php"
>
<testsuites>
<testsuite name="php-redmine-api Test Suite">
<directory>./test/Redmine/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<filter>
<whitelist>
<directory suffix=".php">./lib/Redmine/</directory>
</whitelist>
</filter>
</phpunit>
<?php
namespace Redmine\Tests;
use Redmine\Client;
use Redmine\Exception\InvalidArgumentException;
class ClientTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldPassApiKeyToContructor()
{
$client = new Client('http://test.local', 'asdf');
$this->assertInstanceOf('Redmine\Client', $client);
}
/**
* @test
*/
public function shouldPassUsernameAndPasswordToContructor()
{
$client = new Client('http://test.local', 'username', 'pwd');
$this->assertInstanceOf('Redmine\Client', $client);
}
/**
* @test
* @expectedException InvalidArgumentException
*/
public function shouldNotGetApiInstance()
{
$client = new Client('http://test.local', 'asdf');
$client->api('do_not_exist');
}
/**
* @test
* @dataProvider getApiClassesProvider
*/
public function shouldGetApiInstance($apiName, $class)
{
$client = new Client('http://test.local', 'asdf');
$this->assertInstanceOf($class, $client->api($apiName));
}
public function getApiClassesProvider()
{
return array(
array('attachment', 'Redmine\Api\Attachment'),
array('group', 'Redmine\Api\Group'),
array('custom_fields', 'Redmine\Api\CustomField'),
array('issue', 'Redmine\Api\Issue'),
array('issue_category', 'Redmine\Api\IssueCategory'),
array('issue_priority', 'Redmine\Api\IssuePriority'),
array('issue_relation', 'Redmine\Api\IssueRelation'),
array('issue_status', 'Redmine\Api\IssueStatus'),
array('membership', 'Redmine\Api\Membership'),
array('news', 'Redmine\Api\News'),
array('project', 'Redmine\Api\Project'),
array('query', 'Redmine\Api\Query'),
array('role', 'Redmine\Api\Role'),
array('time_entry', 'Redmine\Api\TimeEntry'),
array('time_entry_activity', 'Redmine\Api\TimeEntryActivity'),
array('tracker', 'Redmine\Api\Tracker'),
array('user', 'Redmine\Api\User'),
array('version', 'Redmine\Api\Version'),
array('wiki', 'Redmine\Api\Wiki'),
);
}
}
<?php
function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../.composer/autoload.php'))) {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
}
$loader->add('Redmine\Tests', __DIR__);
return $loader;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment