Skip to content

Commit

Permalink
Add test for expected exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Jan 18, 2024
1 parent f3d299a commit 54edbf0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/Unit/Api/Project/CloseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Redmine\Tests\Unit\Api\Project;

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Redmine\Api\Project;
use Redmine\Client\Client;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Http\HttpClient;
use Redmine\Http\Response;
Expand Down Expand Up @@ -38,4 +38,17 @@ public function testCloseReturnsResponse()

$this->assertSame('', $api->close(5));
}

public function testCloseWithoutIntOrStringThrowsInvalidArgumentException()
{
$client = $this->createMock(HttpClient::class);

$api = new Project($client);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Redmine\Api\Project::close(): Argument #1 ($projectIdentifier) must be of type int or string');

// Perform the tests
$api->close(true);
}
}

0 comments on commit 54edbf0

Please sign in to comment.