From 38bc21285f4925c358489bfbc76abe577e4cebd2 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 24 Jun 2021 15:51:39 +0100 Subject: [PATCH] PHP8: support --- .github/workflows/ci.yaml | 41 +++++++++++++++++++ .gitignore | 1 + composer.json | 7 ++-- lib/Bitbucket/API/Groups.php | 2 +- lib/Bitbucket/API/Repositories/Commits.php | 2 +- lib/Bitbucket/API/Repositories/Issues.php | 2 +- lib/Bitbucket/API/Repositories/Pipelines.php | 2 +- .../API/Repositories/PullRequests.php | 2 +- lib/Bitbucket/API/Teams.php | 4 +- lib/Bitbucket/API/User.php | 2 +- lib/Bitbucket/API/Users.php | 4 +- lib/Bitbucket/API/Workspaces/Workspace.php | 2 +- test/Bitbucket/Tests/API/ApiTest.php | 8 ++-- .../Tests/API/GroupPrivilegesTest.php | 7 ++-- .../Tests/API/Groups/MembersTest.php | 2 +- test/Bitbucket/Tests/API/GroupsTest.php | 2 +- test/Bitbucket/Tests/API/Http/ClientTest.php | 10 ++--- .../API/Http/Plugin/OAuth2PluginTest.php | 24 +++++------ .../Tests/API/Http/Plugin/OAuthPluginTest.php | 4 +- .../Tests/API/Http/Response/PagerTest.php | 5 +-- test/Bitbucket/Tests/API/InvitationsTest.php | 2 +- .../Repositories/BranchRestrictionsTest.php | 23 +++++------ .../Commits/BuildStatusesTest.php | 2 +- .../API/Repositories/Commits/CommentsTest.php | 2 +- .../Tests/API/Repositories/CommitsTest.php | 2 +- .../Tests/API/Repositories/DeploykeysTest.php | 2 +- .../Tests/API/Repositories/HooksTest.php | 8 ++-- .../API/Repositories/Issues/CommentsTest.php | 2 +- .../Tests/API/Repositories/IssuesTest.php | 12 +++--- .../Tests/API/Repositories/MilestonesTest.php | 2 +- .../API/Repositories/Pipelines/StepsTest.php | 2 +- .../Tests/API/Repositories/PipelinesTest.php | 2 +- .../PullRequests/CommentsTest.php | 2 +- .../API/Repositories/PullRequestsTest.php | 8 ++-- .../API/Repositories/Refs/BranchesTest.php | 2 +- .../Tests/API/Repositories/Refs/TagsTest.php | 2 +- .../Tests/API/Repositories/RefsTest.php | 2 +- .../Tests/API/Repositories/RepositoryTest.php | 5 ++- .../Tests/API/Repositories/SrcTest.php | 5 ++- test/Bitbucket/Tests/API/RepositoriesTest.php | 2 +- test/Bitbucket/Tests/API/Teams/HooksTest.php | 8 ++-- .../Tests/API/Teams/PermissionsTest.php | 2 +- test/Bitbucket/Tests/API/TeamsTest.php | 5 ++- .../Tests/API/User/PermissionsTest.php | 2 +- test/Bitbucket/Tests/API/UserTest.php | 2 +- .../Tests/API/Users/InvitationsTest.php | 2 +- .../Bitbucket/Tests/API/Users/SshKeysTest.php | 2 +- test/Bitbucket/Tests/API/UsersTest.php | 2 +- .../Tests/API/Workspaces/HooksTest.php | 5 ++- .../Tests/API/Workspaces/WorkspaceTest.php | 2 +- test/Bitbucket/Tests/API/WorkspacesTest.php | 2 +- 51 files changed, 152 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c82ce93 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,41 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + +jobs: + phpunit: + name: Test Suite + runs-on: ubuntu-latest + strategy: + matrix: + php: [7.1, 7.2, 7.3, 7.4, 8.0] + steps: + - uses: actions/checkout@v2 + - name: Install PHP ${{ matrix.php }} + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + ini-values: "memory_limit=-1, phar.readonly=0" + php-version: ${{ matrix.php }} + + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + key: "php-${{ matrix.php }}-ci" + restore-keys: "php-${{ matrix.php }}" + + - name: "Install dependencies" + run: composer update --no-progress -o --prefer-dist + + - name: "Run PHPUnit" + run: ./vendor/bin/phpunit + + - name: "Run PHPStan" + run: ./vendor/bin/phpstan analyze lib test --level=4 diff --git a/.gitignore b/.gitignore index ac593c2..c168e85 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor/ report/ build/ composer.lock +.phpunit.result.cache diff --git a/composer.json b/composer.json index 691984f..c88bdd3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^7.1", + "php": "^7.1|^8.0", "ext-json": "*", "jacobkiers/oauth":"~1.0", "psr/http-message": "^1.0", @@ -23,10 +23,11 @@ "php-http/client-common": "^2.0" }, "require-dev": { - "phpunit/phpunit":"^7.5", + "phpunit/phpunit":"^7.5|^8", "php-http/mock-client": " ^1.2", "squizlabs/php_codesniffer": "^3.5", - "php-http/guzzle6-adapter": "^2.0" + "php-http/guzzle6-adapter": "^2.0", + "phpstan/phpstan": "^0.12.90" }, "conflict": { "eabay/bitbucket-repo-sync": "*", diff --git a/lib/Bitbucket/API/Groups.php b/lib/Bitbucket/API/Groups.php index 3aefac4..94b480c 100644 --- a/lib/Bitbucket/API/Groups.php +++ b/lib/Bitbucket/API/Groups.php @@ -114,6 +114,6 @@ public function delete($account, $name) */ public function members() { - return $this->api(Members::class); + return new Members([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Repositories/Commits.php b/lib/Bitbucket/API/Repositories/Commits.php index 742459e..3aeb11f 100644 --- a/lib/Bitbucket/API/Repositories/Commits.php +++ b/lib/Bitbucket/API/Repositories/Commits.php @@ -105,6 +105,6 @@ public function deleteApproval($account, $repo, $revision) */ public function comments() { - return $this->api(Comments::class); + return new Comments([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Repositories/Issues.php b/lib/Bitbucket/API/Repositories/Issues.php index e452524..e913cfd 100644 --- a/lib/Bitbucket/API/Repositories/Issues.php +++ b/lib/Bitbucket/API/Repositories/Issues.php @@ -133,6 +133,6 @@ public function delete($account, $repo, $issueID) */ public function comments() { - return $this->api(Issues\Comments::class); + return new Issues\Comments([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Repositories/Pipelines.php b/lib/Bitbucket/API/Repositories/Pipelines.php index ff2ae92..d813227 100644 --- a/lib/Bitbucket/API/Repositories/Pipelines.php +++ b/lib/Bitbucket/API/Repositories/Pipelines.php @@ -107,6 +107,6 @@ public function stopPipeline($account, $repo, $uuid) */ public function steps() { - return $this->api(Steps::class); + return new Steps([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Repositories/PullRequests.php b/lib/Bitbucket/API/Repositories/PullRequests.php index 19746b0..2d3828b 100644 --- a/lib/Bitbucket/API/Repositories/PullRequests.php +++ b/lib/Bitbucket/API/Repositories/PullRequests.php @@ -32,7 +32,7 @@ class PullRequests extends API\Api */ public function comments() { - return $this->api('Repositories\\PullRequests\\Comments'); + return new PullRequests\Comments([], $this->getClient()); } /** diff --git a/lib/Bitbucket/API/Teams.php b/lib/Bitbucket/API/Teams.php index 43005c2..fc9f020 100644 --- a/lib/Bitbucket/API/Teams.php +++ b/lib/Bitbucket/API/Teams.php @@ -115,7 +115,7 @@ public function repositories($name) */ public function hooks() { - return $this->api(Teams\Hooks::class); + return new Teams\Hooks([], $this->getClient()); } /** @@ -124,6 +124,6 @@ public function hooks() */ public function permissions() { - return $this->api(Teams\Permissions::class); + return new Teams\Permissions([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/User.php b/lib/Bitbucket/API/User.php index bcb17a4..6ab20da 100644 --- a/lib/Bitbucket/API/User.php +++ b/lib/Bitbucket/API/User.php @@ -52,6 +52,6 @@ public function emails() */ public function permissions() { - return $this->api(User\Permissions::class); + return new User\Permissions([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Users.php b/lib/Bitbucket/API/Users.php index 089897f..ec53e5b 100644 --- a/lib/Bitbucket/API/Users.php +++ b/lib/Bitbucket/API/Users.php @@ -59,7 +59,7 @@ public function repositories($username) */ public function invitations() { - return $this->api(Users\Invitations::class); + return new Users\Invitations([], $this->getClient()); } /** @@ -72,6 +72,6 @@ public function invitations() */ public function sshKeys() { - return $this->api(Users\SshKeys::class); + return new Users\SshKeys([], $this->getClient()); } } diff --git a/lib/Bitbucket/API/Workspaces/Workspace.php b/lib/Bitbucket/API/Workspaces/Workspace.php index 891876e..992b997 100644 --- a/lib/Bitbucket/API/Workspaces/Workspace.php +++ b/lib/Bitbucket/API/Workspaces/Workspace.php @@ -67,6 +67,6 @@ public function projects($workspace) */ public function hooks() { - return $this->api(Hooks::class); + return new Hooks([], $this->getClient()); } } diff --git a/test/Bitbucket/Tests/API/ApiTest.php b/test/Bitbucket/Tests/API/ApiTest.php index 2907f82..2e34421 100644 --- a/test/Bitbucket/Tests/API/ApiTest.php +++ b/test/Bitbucket/Tests/API/ApiTest.php @@ -76,11 +76,10 @@ public function testShouldDoDeleteRequest() $this->assertSame('DELETE', $request->getMethod()); } - /** - * @expectedException \InvalidArgumentException - */ public function testFormat() { + $this->expectException(\InvalidArgumentException::class); + $api = new Api; // default format @@ -96,10 +95,11 @@ public function testFormat() /** * @dataProvider invalidChildNameProvider - * @expectedException \InvalidArgumentException */ public function testSPFShouldFailWithInvalidClassName($name) { + $this->expectException(\InvalidArgumentException::class); + $bitbucket = new Api(); $bitbucket->api($name); } diff --git a/test/Bitbucket/Tests/API/GroupPrivilegesTest.php b/test/Bitbucket/Tests/API/GroupPrivilegesTest.php index 70ea164..1f07e3a 100644 --- a/test/Bitbucket/Tests/API/GroupPrivilegesTest.php +++ b/test/Bitbucket/Tests/API/GroupPrivilegesTest.php @@ -9,7 +9,7 @@ class GroupPrivilegesTest extends TestCase /** @var GroupPrivileges */ private $groupPrivileges; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->groupPrivileges = $this->getApiMock(GroupPrivileges::class); @@ -51,11 +51,10 @@ public function testGetRepositoriesPrivilegeGroupSuccess() $this->assertRequest('GET', $endpoint, '', 'format=json'); } - /** - * @expectedException \InvalidArgumentException - */ public function testGrantGroupPrivilegesInvalidPrivilege() { + $this->expectException(\InvalidArgumentException::class); + $this->groupPrivileges->grant('gentle', 'repo', 'owner', 'sys-admins', 'invalid'); } diff --git a/test/Bitbucket/Tests/API/Groups/MembersTest.php b/test/Bitbucket/Tests/API/Groups/MembersTest.php index 8d82352..29e08b6 100644 --- a/test/Bitbucket/Tests/API/Groups/MembersTest.php +++ b/test/Bitbucket/Tests/API/Groups/MembersTest.php @@ -10,7 +10,7 @@ class MembersTest extends TestCase /** @var Members */ private $members; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->members = $this->getApiMock(Members::class); diff --git a/test/Bitbucket/Tests/API/GroupsTest.php b/test/Bitbucket/Tests/API/GroupsTest.php index 671e99c..0b60a52 100644 --- a/test/Bitbucket/Tests/API/GroupsTest.php +++ b/test/Bitbucket/Tests/API/GroupsTest.php @@ -10,7 +10,7 @@ class GroupsTest extends TestCase /** @var Groups */ private $groups; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->groups = $this->getApiMock(Groups::class); diff --git a/test/Bitbucket/Tests/API/Http/ClientTest.php b/test/Bitbucket/Tests/API/Http/ClientTest.php index 13cb019..cbe43d6 100644 --- a/test/Bitbucket/Tests/API/Http/ClientTest.php +++ b/test/Bitbucket/Tests/API/Http/ClientTest.php @@ -15,7 +15,7 @@ class ClientTest extends Tests\TestCase /** @var Client */ private $client; - public function setUp() + public function setUp(): void { $this->client = new Client(array(), $this->getHttpPluginClientBuilder()); } @@ -25,11 +25,10 @@ public function testGetSelfInstance() $this->assertInstanceOf(HttpMethodsClient::class, $this->client->getClient()); } - /** - * @expectedException \InvalidArgumentException - */ public function testSetResponseFormatInvalid() { + $this->expectException(\InvalidArgumentException::class); + $this->client->setResponseFormat('invalid'); } @@ -41,11 +40,12 @@ public function testResponseFormatSuccess() /** * @dataProvider invalidApiVersionsProvider - * @expectedException \InvalidArgumentException * @ticket 57 */ public function testSetApiVersionInvalid($version) { + $this->expectException(\InvalidArgumentException::class); + $this->client->setApiVersion($version); } diff --git a/test/Bitbucket/Tests/API/Http/Plugin/OAuth2PluginTest.php b/test/Bitbucket/Tests/API/Http/Plugin/OAuth2PluginTest.php index 7ef62c3..3e007db 100644 --- a/test/Bitbucket/Tests/API/Http/Plugin/OAuth2PluginTest.php +++ b/test/Bitbucket/Tests/API/Http/Plugin/OAuth2PluginTest.php @@ -2,12 +2,14 @@ namespace Bitbucket\Tests\API\Http\Plugin; +use Bitbucket\API\Exceptions\ForbiddenAccessException; use Bitbucket\API\Http\ClientInterface; use Bitbucket\Tests\API as Tests; use Bitbucket\API\Http\Plugin\OAuth2Plugin; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Http\Client\Promise\HttpFulfilledPromise; +use PHPUnit\Framework\MockObject\MockObject; use Psr\Http\Message\RequestInterface; /** @@ -15,21 +17,20 @@ */ class OAuth2PluginTest extends Tests\TestCase { - /** @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ClientInterface|MockObject */ private $httpClient; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->httpClient = $this->getMockBuilder(ClientInterface::class)->getMock(); } - /** - * @expectedException \Bitbucket\API\Exceptions\ForbiddenAccessException - */ public function testGetAccessTokenShouldFailWithInvalidJson() { + $this->expectException(ForbiddenAccessException::class); + $oauth_params = [ 'client_id' => 'aaa', 'client_secret' => 'bbb' @@ -61,11 +62,10 @@ public function testGetAccessTokenShouldFailWithInvalidJson() }); } - /** - * @expectedException \Bitbucket\API\Exceptions\ForbiddenAccessException - */ public function testGetAccessTokenFail() { + $this->expectException(ForbiddenAccessException::class); + $responseBody = '{"error_description": "Invalid OAuth client credentials", "error": "unauthorized_client"}'; $response = new Response(200, [], $responseBody); @@ -111,8 +111,8 @@ public function testOauth2ListenerDoesNotReplaceExistingBearer() $plugin->handleRequest($request, function (RequestInterface $request) { $authHeader = $request->getHeader('Authorization')[0]; - $this->assertContains('Bearer', $authHeader); - $this->assertContains('secret', $authHeader); + $this->assertStringContainsString('Bearer', $authHeader); + $this->assertStringContainsString('secret', $authHeader); return new HttpFulfilledPromise(new Response()); }, function () { @@ -148,8 +148,8 @@ public function testMakeSureRequestIncludesBearer() $plugin->handleRequest($request, function (RequestInterface $request) { $authHeader = $request->getHeader('Authorization')[0]; - $this->assertContains('Bearer', $authHeader); - $this->assertContains('secret', $authHeader); + $this->assertStringContainsString('Bearer', $authHeader); + $this->assertStringContainsString('secret', $authHeader); return new HttpFulfilledPromise(new Response()); }, function () { diff --git a/test/Bitbucket/Tests/API/Http/Plugin/OAuthPluginTest.php b/test/Bitbucket/Tests/API/Http/Plugin/OAuthPluginTest.php index dc53911..d13b181 100644 --- a/test/Bitbucket/Tests/API/Http/Plugin/OAuthPluginTest.php +++ b/test/Bitbucket/Tests/API/Http/Plugin/OAuthPluginTest.php @@ -84,8 +84,8 @@ public function testMakeSureRequestIncludesOAuthHeader() $listener = new OAuthPlugin($oauth_params); $listener->handleRequest($request, function (RequestInterface $request) use ($oauth_params) { $authHeader = $request->getHeader('Authorization')[0]; - $this->assertContains('OAuth', $authHeader); - $this->assertContains( + $this->assertStringContainsString('OAuth', $authHeader); + $this->assertStringContainsString( sprintf('oauth_consumer_key="%s"', $oauth_params['oauth_consumer_key']), $authHeader ); diff --git a/test/Bitbucket/Tests/API/Http/Response/PagerTest.php b/test/Bitbucket/Tests/API/Http/Response/PagerTest.php index 4688765..6fcdcef 100644 --- a/test/Bitbucket/Tests/API/Http/Response/PagerTest.php +++ b/test/Bitbucket/Tests/API/Http/Response/PagerTest.php @@ -113,11 +113,10 @@ public function testFetchAllWithInvalidJsonShouldReturnEmptyValuesArray() $this->assertEquals($expected, json_decode($response->getBody()->getContents(), true)); } - /** - * @expectedException \UnexpectedValueException - */ public function testFetchAllWithUnauthorizedHeaderShouldFail() { + $this->expectException(\UnexpectedValueException::class); + $response = $this->fakeResponse([], 401); new Pager($this->getHttpPluginClientBuilder(), $response); diff --git a/test/Bitbucket/Tests/API/InvitationsTest.php b/test/Bitbucket/Tests/API/InvitationsTest.php index e74309f..24272e4 100644 --- a/test/Bitbucket/Tests/API/InvitationsTest.php +++ b/test/Bitbucket/Tests/API/InvitationsTest.php @@ -9,7 +9,7 @@ class InvitationsTest extends TestCase /** @var Invitations */ private $invitations; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->invitations = $this->getApiMock(Invitations::class); diff --git a/test/Bitbucket/Tests/API/Repositories/BranchRestrictionsTest.php b/test/Bitbucket/Tests/API/Repositories/BranchRestrictionsTest.php index 02f9c2d..910ddc6 100644 --- a/test/Bitbucket/Tests/API/Repositories/BranchRestrictionsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/BranchRestrictionsTest.php @@ -10,7 +10,7 @@ class BranchRestrictionsTest extends TestCase /** @var BranchRestrictions */ private $branchRestrictions; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->branchRestrictions = $this->getApiMock(BranchRestrictions::class); @@ -65,11 +65,12 @@ public function testCreateRestrictionFromJSON() } /** - * @expectedException \InvalidArgumentException * @dataProvider restrictionsInvalidParamsProvider */ public function testCreateRestrictionWithInvalidParams($params) { + $this->expectException(\InvalidArgumentException::class); + $this->branchRestrictions->create('gentle', 'eof', $params); } @@ -82,11 +83,10 @@ public function restrictionsInvalidParamsProvider() ]; } - /** - * @expectedException \InvalidArgumentException - */ public function testCreateRestrictionFromArrayShouldFailWithInvalidRestrictionKind() { + $this->expectException(\InvalidArgumentException::class); + $params = [ 'kind' => 'invalid' ]; @@ -94,11 +94,10 @@ public function testCreateRestrictionFromArrayShouldFailWithInvalidRestrictionKi $this->branchRestrictions->create('gentle', 'eof', $params); } - /** - * @expectedException \InvalidArgumentException - */ public function testCreateRestrictionFromJSONShouldFailWithInvalidRestrictionKind() { + $this->expectException(\InvalidArgumentException::class); + $params = json_encode([ 'kind' => 'invalid' ]); @@ -148,19 +147,19 @@ public function testUpdateRestrictionFromJSON() } /** - * @expectedException \InvalidArgumentException * @dataProvider restrictionsInvalidParamsProvider */ public function testUpdateRestrictionWithInvalidParams($params) { + $this->expectException(\InvalidArgumentException::class); + $this->branchRestrictions->update('gentle', 'eof', 1, $params); } - /** - * @expectedException \InvalidArgumentException - */ public function testCreateRestrictionShouldFailIfKindIsSpecified() { + $this->expectException(\InvalidArgumentException::class); + $params = [ 'kind' => 'invalid' ]; diff --git a/test/Bitbucket/Tests/API/Repositories/Commits/BuildStatusesTest.php b/test/Bitbucket/Tests/API/Repositories/Commits/BuildStatusesTest.php index bca850b..ddc16cb 100644 --- a/test/Bitbucket/Tests/API/Repositories/Commits/BuildStatusesTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Commits/BuildStatusesTest.php @@ -10,7 +10,7 @@ class BuildStatusesTest extends TestCase /** @var BuildStatuses */ private $buildStatuses; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->buildStatuses = $this->getApiMock(BuildStatuses::class); diff --git a/test/Bitbucket/Tests/API/Repositories/Commits/CommentsTest.php b/test/Bitbucket/Tests/API/Repositories/Commits/CommentsTest.php index ca9a506..2d93131 100644 --- a/test/Bitbucket/Tests/API/Repositories/Commits/CommentsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Commits/CommentsTest.php @@ -10,7 +10,7 @@ class CommentsTest extends TestCase /** @var Comments */ private $comments; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->comments = $this->getApiMock(Comments::class); diff --git a/test/Bitbucket/Tests/API/Repositories/CommitsTest.php b/test/Bitbucket/Tests/API/Repositories/CommitsTest.php index 9bfb32a..e1c460e 100644 --- a/test/Bitbucket/Tests/API/Repositories/CommitsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/CommitsTest.php @@ -10,7 +10,7 @@ class CommitsTest extends TestCase /** @var Commits */ private $commits; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->commits = $this->getApiMock(Commits::class); diff --git a/test/Bitbucket/Tests/API/Repositories/DeploykeysTest.php b/test/Bitbucket/Tests/API/Repositories/DeploykeysTest.php index 2104e9a..1b50443 100644 --- a/test/Bitbucket/Tests/API/Repositories/DeploykeysTest.php +++ b/test/Bitbucket/Tests/API/Repositories/DeploykeysTest.php @@ -10,7 +10,7 @@ class DeploykeysTest extends TestCase /** @var Deploykeys */ private $deploykeys; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->deploykeys = $this->getApiMock(Deploykeys::class); diff --git a/test/Bitbucket/Tests/API/Repositories/HooksTest.php b/test/Bitbucket/Tests/API/Repositories/HooksTest.php index 1ca37da..6557d77 100644 --- a/test/Bitbucket/Tests/API/Repositories/HooksTest.php +++ b/test/Bitbucket/Tests/API/Repositories/HooksTest.php @@ -20,7 +20,7 @@ class HooksTest extends TestCase /** @var Hooks */ private $hooks; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->hooks = $this->getApiMock(Hooks::class); @@ -64,11 +64,12 @@ public function invalidCreateProvider() } /** - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider */ public function testInvalidCreate(array $check) { + $this->expectException(\InvalidArgumentException::class); + $this->hooks->create('gentle', 'my-repo', $check); } @@ -150,11 +151,12 @@ public function testUpdateSuccess() } /** - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider */ public function testInvalidUpdate(array $check) { + $this->expectException(\InvalidArgumentException::class); + $this->hooks->update('gentle', 'eof', '30b60aee-9cdf-407d-901c-2de106ee0c9d', $check); } diff --git a/test/Bitbucket/Tests/API/Repositories/Issues/CommentsTest.php b/test/Bitbucket/Tests/API/Repositories/Issues/CommentsTest.php index 6b84ff3..f64a3e5 100644 --- a/test/Bitbucket/Tests/API/Repositories/Issues/CommentsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Issues/CommentsTest.php @@ -10,7 +10,7 @@ class CommentsTest extends TestCase /** @var Comments */ private $comments; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->comments = $this->getApiMock(Comments::class); diff --git a/test/Bitbucket/Tests/API/Repositories/IssuesTest.php b/test/Bitbucket/Tests/API/Repositories/IssuesTest.php index 3189cbf..465abdd 100644 --- a/test/Bitbucket/Tests/API/Repositories/IssuesTest.php +++ b/test/Bitbucket/Tests/API/Repositories/IssuesTest.php @@ -10,7 +10,7 @@ class IssuesTest extends TestCase /** @var Issues */ private $issues; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->issues = $this->getApiMock(Issues::class); @@ -56,11 +56,10 @@ public function testCreateIssue() $this->assertRequest('POST', $endpoint, json_encode($params)); } - /** - * @expectedException \InvalidArgumentException - */ public function testShouldNotCreateIssueWithoutTitle() { + $this->expectException(\InvalidArgumentException::class); + $params = [ 'content' => ['raw' => 'dummy content'], ]; @@ -68,11 +67,10 @@ public function testShouldNotCreateIssueWithoutTitle() $this->issues->create('gentle', 'eof', $params); } - /** - * @expectedException \InvalidArgumentException - */ public function testShouldNotCreateIssueWithoutContent() { + $this->expectException(\InvalidArgumentException::class); + $params = [ 'title' => 'dummy title' ]; diff --git a/test/Bitbucket/Tests/API/Repositories/MilestonesTest.php b/test/Bitbucket/Tests/API/Repositories/MilestonesTest.php index d26db48..72d5a33 100644 --- a/test/Bitbucket/Tests/API/Repositories/MilestonesTest.php +++ b/test/Bitbucket/Tests/API/Repositories/MilestonesTest.php @@ -10,7 +10,7 @@ class MilestonesTest extends TestCase /** @var Milestones */ private $milestones; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->milestones = $this->getApiMock(Milestones::class); diff --git a/test/Bitbucket/Tests/API/Repositories/Pipelines/StepsTest.php b/test/Bitbucket/Tests/API/Repositories/Pipelines/StepsTest.php index 804490d..714fd18 100644 --- a/test/Bitbucket/Tests/API/Repositories/Pipelines/StepsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Pipelines/StepsTest.php @@ -10,7 +10,7 @@ class StepsTest extends TestCase /** @var Steps */ private $steps; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->steps = $this->getApiMock(Steps::class); diff --git a/test/Bitbucket/Tests/API/Repositories/PipelinesTest.php b/test/Bitbucket/Tests/API/Repositories/PipelinesTest.php index 06d2e2e..dbc455a 100644 --- a/test/Bitbucket/Tests/API/Repositories/PipelinesTest.php +++ b/test/Bitbucket/Tests/API/Repositories/PipelinesTest.php @@ -10,7 +10,7 @@ class PipelinesTest extends TestCase /** @var Pipelines */ private $pipelines; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->pipelines = $this->getApiMock(Pipelines::class); diff --git a/test/Bitbucket/Tests/API/Repositories/PullRequests/CommentsTest.php b/test/Bitbucket/Tests/API/Repositories/PullRequests/CommentsTest.php index c7b8b47..7dc91b9 100644 --- a/test/Bitbucket/Tests/API/Repositories/PullRequests/CommentsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/PullRequests/CommentsTest.php @@ -10,7 +10,7 @@ class CommentsTest extends TestCase /** @var Comments */ private $comments; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->comments = $this->getApiMock(Comments::class); diff --git a/test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php b/test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php index 61965b1..b3ff5cb 100644 --- a/test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php @@ -10,7 +10,7 @@ class PullRequestsTest extends TestCase /** @var PullRequests */ private $pullRequests; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->pullRequests = $this->getApiMock(PullRequests::class); @@ -78,11 +78,12 @@ public function testCreateNewPullRequestFromArray() } /** - * @expectedException \InvalidArgumentException * @dataProvider pullRequestWrongParamsTypeProvider */ public function testCreateNewPullRequestWithWrongParamsType($params) { + $this->expectException(\InvalidArgumentException::class); + $this->pullRequests->create('gentle', 'eof', $params); } @@ -130,11 +131,12 @@ public function testUpdatePullRequestFromArray() } /** - * @expectedException \InvalidArgumentException * @dataProvider pullRequestWrongParamsTypeProvider */ public function testUpdatePullRequestWithWrongParamsType($params) { + $this->expectException(\InvalidArgumentException::class); + $this->pullRequests->update('gentle', 'eof', 1, $params); } diff --git a/test/Bitbucket/Tests/API/Repositories/Refs/BranchesTest.php b/test/Bitbucket/Tests/API/Repositories/Refs/BranchesTest.php index d4a9b67..557398c 100644 --- a/test/Bitbucket/Tests/API/Repositories/Refs/BranchesTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Refs/BranchesTest.php @@ -10,7 +10,7 @@ class BranchesTest extends TestCase /** @var Branches */ private $branches; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->branches = $this->getApiMock(Branches::class); diff --git a/test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php b/test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php index d71d52f..cbd055f 100644 --- a/test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php @@ -10,7 +10,7 @@ class TagsTest extends TestCase /** @var Tags */ private $tags; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->tags = $this->getApiMock(Tags::class); diff --git a/test/Bitbucket/Tests/API/Repositories/RefsTest.php b/test/Bitbucket/Tests/API/Repositories/RefsTest.php index ef924e3..1cdc801 100644 --- a/test/Bitbucket/Tests/API/Repositories/RefsTest.php +++ b/test/Bitbucket/Tests/API/Repositories/RefsTest.php @@ -10,7 +10,7 @@ class RefsTest extends TestCase /** @var Refs */ private $refs; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->refs = $this->getApiMock(Refs::class); diff --git a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php index 0c2947d..484db2f 100644 --- a/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php +++ b/test/Bitbucket/Tests/API/Repositories/RepositoryTest.php @@ -10,7 +10,7 @@ class RepositoryTest extends TestCase /** @var Repository */ private $repository; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->repository = $this->getApiMock(Repository::class); @@ -50,12 +50,13 @@ public function invalidCreateProvider() /** * @param mixed $check - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider * @ticket 27, 26 */ public function testInvalidCreate($check) { + $this->expectException(\InvalidArgumentException::class); + $this->repository->create('gentle', 'new-repo', $check); } diff --git a/test/Bitbucket/Tests/API/Repositories/SrcTest.php b/test/Bitbucket/Tests/API/Repositories/SrcTest.php index 2cb22ab..3bfa1f4 100644 --- a/test/Bitbucket/Tests/API/Repositories/SrcTest.php +++ b/test/Bitbucket/Tests/API/Repositories/SrcTest.php @@ -10,7 +10,7 @@ class SrcTest extends TestCase /** @var Src */ private $src; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->src = $this->getApiMock(Src::class); @@ -39,11 +39,12 @@ public function testSrcGetRawContent() } /** - * @expectedException \InvalidArgumentException * @dataProvider srcInvalidParamsProvider */ public function testSrcCreateWithInvalidParams($params) { + $this->expectException(\InvalidArgumentException::class); + $this->src->create('gentle', 'eof', $params); } diff --git a/test/Bitbucket/Tests/API/RepositoriesTest.php b/test/Bitbucket/Tests/API/RepositoriesTest.php index d5dd45a..e9371b5 100644 --- a/test/Bitbucket/Tests/API/RepositoriesTest.php +++ b/test/Bitbucket/Tests/API/RepositoriesTest.php @@ -9,7 +9,7 @@ class RepositoriesTest extends TestCase /** @var Repositories */ private $repositories; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->repositories = $this->getApiMock(Repositories::class); diff --git a/test/Bitbucket/Tests/API/Teams/HooksTest.php b/test/Bitbucket/Tests/API/Teams/HooksTest.php index c89bb3d..86ebbf0 100644 --- a/test/Bitbucket/Tests/API/Teams/HooksTest.php +++ b/test/Bitbucket/Tests/API/Teams/HooksTest.php @@ -10,7 +10,7 @@ class HooksTest extends TestCase /** @var Hooks */ private $hooks; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->hooks = $this->getApiMock(Hooks::class); @@ -49,11 +49,12 @@ public function invalidCreateProvider() } /** - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider */ public function testInvalidCreate(array $check) { + $this->expectException(\InvalidArgumentException::class); + $this->hooks->create('gentle', $check); } @@ -92,11 +93,12 @@ public function testUpdateSuccess() } /** - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider */ public function testInvalidUpdate(array $check) { + $this->expectException(\InvalidArgumentException::class); + $this->hooks->update('gentle', '30b60aee-9cdf-407d-901c-2de106ee0c9d', $check); } diff --git a/test/Bitbucket/Tests/API/Teams/PermissionsTest.php b/test/Bitbucket/Tests/API/Teams/PermissionsTest.php index 046c084..d88ad6a 100644 --- a/test/Bitbucket/Tests/API/Teams/PermissionsTest.php +++ b/test/Bitbucket/Tests/API/Teams/PermissionsTest.php @@ -10,7 +10,7 @@ class PermissionsTest extends TestCase /** @var Permissions */ private $permissions; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->permissions = $this->getApiMock(Permissions::class); diff --git a/test/Bitbucket/Tests/API/TeamsTest.php b/test/Bitbucket/Tests/API/TeamsTest.php index 8048bce..8725b65 100644 --- a/test/Bitbucket/Tests/API/TeamsTest.php +++ b/test/Bitbucket/Tests/API/TeamsTest.php @@ -9,7 +9,7 @@ class TeamsTest extends TestCase /** @var Teams */ private $teams; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->teams = $this->getApiMock(Teams::class); @@ -30,10 +30,11 @@ public function invalidRoleProvider() /** * @dataProvider invalidRoleProvider - * @expectedException \InvalidArgumentException */ public function testGetTeamsListWithInvalidRole($role) { + $this->expectException(\InvalidArgumentException::class); + $this->teams->all($role); } diff --git a/test/Bitbucket/Tests/API/User/PermissionsTest.php b/test/Bitbucket/Tests/API/User/PermissionsTest.php index 900b952..0523a71 100644 --- a/test/Bitbucket/Tests/API/User/PermissionsTest.php +++ b/test/Bitbucket/Tests/API/User/PermissionsTest.php @@ -10,7 +10,7 @@ class PermissionsTest extends TestCase /** @var Permissions */ private $permissions; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->permissions = $this->getApiMock(Permissions::class); diff --git a/test/Bitbucket/Tests/API/UserTest.php b/test/Bitbucket/Tests/API/UserTest.php index 42eff9b..2dc7a11 100644 --- a/test/Bitbucket/Tests/API/UserTest.php +++ b/test/Bitbucket/Tests/API/UserTest.php @@ -9,7 +9,7 @@ class UserTest extends TestCase /** @var User */ private $user; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->user = $this->getApiMock(User::class); diff --git a/test/Bitbucket/Tests/API/Users/InvitationsTest.php b/test/Bitbucket/Tests/API/Users/InvitationsTest.php index 58782b8..4ccd4ab 100644 --- a/test/Bitbucket/Tests/API/Users/InvitationsTest.php +++ b/test/Bitbucket/Tests/API/Users/InvitationsTest.php @@ -10,7 +10,7 @@ class InvitationsTest extends Tests\TestCase /** @var Invitations */ private $invitations; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->invitations = $this->getApiMock(Invitations::class); diff --git a/test/Bitbucket/Tests/API/Users/SshKeysTest.php b/test/Bitbucket/Tests/API/Users/SshKeysTest.php index 9d518bc..93d0c6a 100644 --- a/test/Bitbucket/Tests/API/Users/SshKeysTest.php +++ b/test/Bitbucket/Tests/API/Users/SshKeysTest.php @@ -10,7 +10,7 @@ class SshKeysTest extends Tests\TestCase /** @var SshKeys */ private $sshKeys; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->sshKeys = $this->getApiMock(SshKeys::class); diff --git a/test/Bitbucket/Tests/API/UsersTest.php b/test/Bitbucket/Tests/API/UsersTest.php index 9266aad..da5614b 100644 --- a/test/Bitbucket/Tests/API/UsersTest.php +++ b/test/Bitbucket/Tests/API/UsersTest.php @@ -9,7 +9,7 @@ class UsersTest extends TestCase /** @var Users */ private $users; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->users = $this->getApiMock(Users::class); diff --git a/test/Bitbucket/Tests/API/Workspaces/HooksTest.php b/test/Bitbucket/Tests/API/Workspaces/HooksTest.php index 4836c70..22f9be1 100644 --- a/test/Bitbucket/Tests/API/Workspaces/HooksTest.php +++ b/test/Bitbucket/Tests/API/Workspaces/HooksTest.php @@ -10,7 +10,7 @@ class HooksTest extends TestCase /** @var Hooks */ private $hooks; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->hooks = $this->getApiMock(Hooks::class); @@ -49,11 +49,12 @@ public function invalidCreateProvider() } /** - * @expectedException \InvalidArgumentException * @dataProvider invalidCreateProvider */ public function testInvalidCreate(array $check) { + $this->expectException(\InvalidArgumentException::class); + $this->hooks->create('gentle', $check); } } diff --git a/test/Bitbucket/Tests/API/Workspaces/WorkspaceTest.php b/test/Bitbucket/Tests/API/Workspaces/WorkspaceTest.php index fb0ab4b..5e5b537 100644 --- a/test/Bitbucket/Tests/API/Workspaces/WorkspaceTest.php +++ b/test/Bitbucket/Tests/API/Workspaces/WorkspaceTest.php @@ -11,7 +11,7 @@ class WorkspaceTest extends TestCase /** @var Workspace */ private $workspace; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->workspace = $this->getApiMock(Workspace::class); diff --git a/test/Bitbucket/Tests/API/WorkspacesTest.php b/test/Bitbucket/Tests/API/WorkspacesTest.php index 93467a6..3a7e92d 100644 --- a/test/Bitbucket/Tests/API/WorkspacesTest.php +++ b/test/Bitbucket/Tests/API/WorkspacesTest.php @@ -9,7 +9,7 @@ class WorkspacesTest extends TestCase /** @var Workspaces */ private $workspaces; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->workspaces = $this->getApiMock(Workspaces::class);