diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 105314e..691bfa9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,17 +9,17 @@ jobs: strategy: fail-fast: true matrix: - php: [7.3, 7.4, 8.0, 8.1, 8.2] - dependency-version: [prefer-lowest, prefer-stable] + php: [8.2,8.3,8.4] + dependency-version: [prefer-stable] name: P${{ matrix.php }} - ${{ matrix.dependency-version }} steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies--php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} @@ -29,11 +29,18 @@ jobs: with: php-version: ${{ matrix.php }} extensions: curl, mbstring, iconv - coverage: none + coverage: xdebug, pcov + tools: composer:v2 - name: Install dependencies run: | composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest - name: Execute tests - run: vendor/bin/phpunit + run: vendor/bin/phpunit --coverage-clover clover.xml + + - name: Coverage Check + uses: ericsizemore/phpunit-coverage-check-action@1.0.0 + with: + clover_file: 'clover.xml' + threshold: 75 diff --git a/.gitignore b/.gitignore index d6e8ffc..f95d204 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.php_cs.cache /.php-cs-fixer.cache /.phpunit.result.cache +/.phpunit.cache /build /phpunit.xml /phpunit.xml.dist.bak diff --git a/README.md b/README.md index 8aa249e..5410d60 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PHP Trello API v1 client ======================== -![tests](https://github.com/semaio/php-trello-api/workflows/run-tests/badge.svg?branch=master) +![tests](https://github.com/josrom/php-trello-api/workflows/run-tests/badge.svg?branch=master) This library is based on the great [php-trello-api](https://github.com/cdaguerre/php-trello-api/) but updated and modernized for usage with PHP 7.3+ and a modern version of Guzzle. @@ -12,7 +12,7 @@ This library is based on the great [php-trello-api](https://github.com/cdaguerre The recommended way is using [composer](http://getcomposer.org): ```bash -$ composer require semaio/php-trello-api +$ composer require josrom/php-trello-api ``` ## Usage @@ -40,7 +40,7 @@ $client->getCardApi()->create( $card ); ## Support -If you encounter any problems or bugs, please create an issue on [GitHub](https://github.com/semaio/php-trello-api/issues). +If you encounter any problems or bugs, please create an issue on [GitHub](https://github.com/josrom/php-trello-api/issues). ## Contribution diff --git a/composer.json b/composer.json index 14e131e..2c814b9 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "semaio/php-trello-api", + "name": "josrom/php-trello-api", "type": "library", "description": "PHP client for Trello API v1", "keywords": [ @@ -7,21 +7,21 @@ ], "license": "MIT", "require": { - "php": "^7.3|^8.0|^8.1|^8.2", - "php-http/discovery": "^1.6", - "psr/http-client": "^1.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "psr/http-message-implementation": "^1.0" + "php": "^8.2|^8.3|^8.4", + "php-http/discovery": "^1.6|^2.0", + "psr/http-client": "^1.0|^2.0", + "psr/http-factory": "^1.0|^2.0", + "psr/http-message": "^1.0|^2.0", + "psr/http-message-implementation": "^1.0|^2.0" }, "require-dev": { "http-interop/http-factory-guzzle": "^1.0", - "php-http/guzzle6-adapter": "^2.0", - "phpunit/phpunit": "^9.0|^10.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symplify/easy-coding-standard": "^8.0", - "symplify/config-transformer": "^10.0" + "php-http/guzzle7-adapter": "^1.1.0", + "phpunit/phpunit": "^10.0|^11.0|^12.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0|^7.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0|^7.0", + "symplify/easy-coding-standard": "^8.0|^9.0|^10.0|^11.0|^12.0", + "symplify/config-transformer": "^10.0|^11.0|^12.0" }, "suggest": { "symfony/event-dispatcher": "Symfony Event Dispatcher for the Trello webhook service.", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5830d42..396dccf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,39 @@ - - - ./src - - - - - - - - - - - - - - ./tests/ - - - - - + xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" + failOnPhpunitDeprecation="true" + failOnRisky="true" + failOnWarning="true" + beStrictAboutCoverageMetadata="true" + beStrictAboutOutputDuringTests="true" + displayDetailsOnPhpunitDeprecations="true"> + + + + + + + + + + + + + + ./tests + + + + + ./src + + + + + diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 4fa3078..06173ff 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -15,25 +15,17 @@ abstract class AbstractApi implements ApiInterface /** * @var array */ - public static $fields; - - /** - * The client. - * - * @var TrelloClientInterface - */ - protected $client; + public static array $fields; /** * API sub namespace. * * @var string */ - protected $path; + protected string $path; - public function __construct(TrelloClientInterface $client) + public function __construct(protected TrelloClientInterface $client) { - $this->client = $client; } /** diff --git a/src/Api/ActionApi.php b/src/Api/ActionApi.php index c4f360d..d2719aa 100644 --- a/src/Api/ActionApi.php +++ b/src/Api/ActionApi.php @@ -14,14 +14,14 @@ class ActionApi extends AbstractApi /** * @see https://trello.com/docs/api/action/#get-1-actions-idaction-field */ - public static $fields = [ + public static array $fields = [ 'idMemberCreator', 'data', 'type', 'date', ]; - protected $path = 'actions'; + protected string $path = 'actions'; /** * Find an action by id. diff --git a/src/Api/Board/BoardActionsApi.php b/src/Api/Board/BoardActionsApi.php index 6cfd0df..308c439 100644 --- a/src/Api/Board/BoardActionsApi.php +++ b/src/Api/Board/BoardActionsApi.php @@ -13,7 +13,7 @@ */ class BoardActionsApi extends AbstractApi { - protected $path = 'boards/#id#/actions'; + protected string $path = 'boards/#id#/actions'; /** * Get actions related to a given board. diff --git a/src/Api/Board/BoardCardListsApi.php b/src/Api/Board/BoardCardListsApi.php index 7eec15a..960c5b6 100644 --- a/src/Api/Board/BoardCardListsApi.php +++ b/src/Api/Board/BoardCardListsApi.php @@ -13,7 +13,7 @@ */ class BoardCardListsApi extends AbstractApi { - protected $path = 'boards/#id#/lists'; + protected string $path = 'boards/#id#/lists'; /** * Get a given board's lists. diff --git a/src/Api/Board/BoardCardsApi.php b/src/Api/Board/BoardCardsApi.php index 9cacef4..dc044ab 100644 --- a/src/Api/Board/BoardCardsApi.php +++ b/src/Api/Board/BoardCardsApi.php @@ -13,7 +13,7 @@ */ class BoardCardsApi extends AbstractApi { - protected $path = 'boards/#id#/cards'; + protected string $path = 'boards/#id#/cards'; /** * Get cards related to a given board. diff --git a/src/Api/Board/BoardChecklistsApi.php b/src/Api/Board/BoardChecklistsApi.php index 3f5316e..b90469e 100644 --- a/src/Api/Board/BoardChecklistsApi.php +++ b/src/Api/Board/BoardChecklistsApi.php @@ -13,7 +13,7 @@ */ class BoardChecklistsApi extends AbstractApi { - protected $path = 'boards/#id#/checklists'; + protected string $path = 'boards/#id#/checklists'; /** * Get cards related to a given board. diff --git a/src/Api/Board/BoardLabelsApi.php b/src/Api/Board/BoardLabelsApi.php index 1778845..78a5fed 100644 --- a/src/Api/Board/BoardLabelsApi.php +++ b/src/Api/Board/BoardLabelsApi.php @@ -14,7 +14,7 @@ */ class BoardLabelsApi extends AbstractApi { - protected $path = 'boards/#id#/labels'; + protected string $path = 'boards/#id#/labels'; /** * Get labels related to a given board. diff --git a/src/Api/Board/BoardMembersApi.php b/src/Api/Board/BoardMembersApi.php index 531d58d..5295486 100644 --- a/src/Api/Board/BoardMembersApi.php +++ b/src/Api/Board/BoardMembersApi.php @@ -20,7 +20,7 @@ class BoardMembersApi extends AbstractApi * * @var string */ - protected $path = 'boards/#id#/members'; + protected string $path = 'boards/#id#/members'; /** * Get a given board's members. diff --git a/src/Api/Board/BoardMembershipsApi.php b/src/Api/Board/BoardMembershipsApi.php index 7926169..c424c70 100644 --- a/src/Api/Board/BoardMembershipsApi.php +++ b/src/Api/Board/BoardMembershipsApi.php @@ -21,5 +21,5 @@ class BoardMembershipsApi extends AbstractApi * * @var string */ - protected $path = 'boards/#id#/memberships'; + protected string $path = 'boards/#id#/memberships'; } diff --git a/src/Api/Board/BoardMyPreferencesApi.php b/src/Api/Board/BoardMyPreferencesApi.php index 2350146..2b104c2 100644 --- a/src/Api/Board/BoardMyPreferencesApi.php +++ b/src/Api/Board/BoardMyPreferencesApi.php @@ -26,5 +26,5 @@ class BoardMyPreferencesApi extends AbstractApi * * @var string */ - protected $path = 'boards/#id#/myPrefs'; + protected string $path = 'boards/#id#/myPrefs'; } diff --git a/src/Api/Board/BoardPowerUpsApi.php b/src/Api/Board/BoardPowerUpsApi.php index 8f19ff0..65e3a75 100644 --- a/src/Api/Board/BoardPowerUpsApi.php +++ b/src/Api/Board/BoardPowerUpsApi.php @@ -20,5 +20,5 @@ class BoardPowerUpsApi extends AbstractApi * * @var string */ - protected $path = 'boards/#id#/powerUps'; + protected string $path = 'boards/#id#/powerUps'; } diff --git a/src/Api/Board/BoardPreferencesApi.php b/src/Api/Board/BoardPreferencesApi.php index ed6ab24..c76dbe7 100644 --- a/src/Api/Board/BoardPreferencesApi.php +++ b/src/Api/Board/BoardPreferencesApi.php @@ -27,5 +27,5 @@ class BoardPreferencesApi extends AbstractApi * * @var string */ - protected $path = 'boards/#id#/prefs'; + protected string $path = 'boards/#id#/prefs'; } diff --git a/src/Api/BoardApi.php b/src/Api/BoardApi.php index 3a7a92e..1949a31 100644 --- a/src/Api/BoardApi.php +++ b/src/Api/BoardApi.php @@ -31,7 +31,7 @@ class BoardApi extends AbstractApi /** * @see https://trello.com/docs/api/board/#get-1-boards-board-id-field */ - public static $fields = [ + public static array $fields = [ 'name', 'desc', 'descData', @@ -53,7 +53,7 @@ class BoardApi extends AbstractApi 'shortUrl', ]; - protected $path = 'boards'; + protected string $path = 'boards'; /** * Find a board by id. diff --git a/src/Api/Card/CardActionsApi.php b/src/Api/Card/CardActionsApi.php index 94e0736..6e86c33 100644 --- a/src/Api/Card/CardActionsApi.php +++ b/src/Api/Card/CardActionsApi.php @@ -13,7 +13,7 @@ */ class CardActionsApi extends AbstractApi { - protected $path = 'cards/#id#/actions'; + protected string $path = 'cards/#id#/actions'; /** * Get actions related to a given card. diff --git a/src/Api/Card/CardAttachmentsApi.php b/src/Api/Card/CardAttachmentsApi.php index ce31c13..04e6f52 100644 --- a/src/Api/Card/CardAttachmentsApi.php +++ b/src/Api/Card/CardAttachmentsApi.php @@ -13,7 +13,7 @@ */ class CardAttachmentsApi extends AbstractApi { - protected $path = 'cards/#id#/attachments'; + protected string $path = 'cards/#id#/attachments'; /** * Get attachments related to a given card. diff --git a/src/Api/Card/CardChecklistsApi.php b/src/Api/Card/CardChecklistsApi.php index 7268c20..a1b8e87 100644 --- a/src/Api/Card/CardChecklistsApi.php +++ b/src/Api/Card/CardChecklistsApi.php @@ -13,7 +13,7 @@ */ class CardChecklistsApi extends AbstractApi { - protected $path = 'cards/#id#/checklists'; + protected string $path = 'cards/#id#/checklists'; /** * Get checklists related to a given card. diff --git a/src/Api/Card/CardLabelsApi.php b/src/Api/Card/CardLabelsApi.php index 30102b2..b621fec 100644 --- a/src/Api/Card/CardLabelsApi.php +++ b/src/Api/Card/CardLabelsApi.php @@ -13,7 +13,7 @@ */ class CardLabelsApi extends AbstractApi { - protected $path = 'cards/#id#/labels'; + protected string $path = 'cards/#id#/labels'; /** * Set a given card's labels. diff --git a/src/Api/Card/CardMembersApi.php b/src/Api/Card/CardMembersApi.php index c8b49e4..ca28a02 100644 --- a/src/Api/Card/CardMembersApi.php +++ b/src/Api/Card/CardMembersApi.php @@ -14,7 +14,7 @@ */ class CardMembersApi extends AbstractApi { - protected $path = 'cards/#id#/members'; + protected string $path = 'cards/#id#/members'; /** * Get members related to a given card. diff --git a/src/Api/Card/CardStickersApi.php b/src/Api/Card/CardStickersApi.php index 44981ad..9490e21 100644 --- a/src/Api/Card/CardStickersApi.php +++ b/src/Api/Card/CardStickersApi.php @@ -13,7 +13,7 @@ */ class CardStickersApi extends AbstractApi { - protected $path = 'cards/#id#/stickers'; + protected string $path = 'cards/#id#/stickers'; /** * Get stickers related to a given card. diff --git a/src/Api/CardApi.php b/src/Api/CardApi.php index 80834be..502302b 100644 --- a/src/Api/CardApi.php +++ b/src/Api/CardApi.php @@ -28,7 +28,7 @@ class CardApi extends AbstractApi /** * @see https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-field */ - public static $fields = [ + public static array $fields = [ 'badges', 'checkItemStates', 'closed', @@ -54,7 +54,7 @@ class CardApi extends AbstractApi 'url', ]; - protected $path = 'cards'; + protected string $path = 'cards'; /** * Find a card by id. diff --git a/src/Api/CardList/CardListActionsApi.php b/src/Api/CardList/CardListActionsApi.php index 7a9d60c..1e8e8ff 100644 --- a/src/Api/CardList/CardListActionsApi.php +++ b/src/Api/CardList/CardListActionsApi.php @@ -13,7 +13,7 @@ */ class CardListActionsApi extends AbstractApi { - protected $path = 'lists/#id#/actions'; + protected string $path = 'lists/#id#/actions'; /** * Get actions related to a given list. diff --git a/src/Api/CardList/CardListCardsApi.php b/src/Api/CardList/CardListCardsApi.php index 9cc034d..8026950 100644 --- a/src/Api/CardList/CardListCardsApi.php +++ b/src/Api/CardList/CardListCardsApi.php @@ -13,7 +13,7 @@ */ class CardListCardsApi extends AbstractApi { - protected $path = 'lists/#id#/cards'; + protected string $path = 'lists/#id#/cards'; /** * Get cards related to a given list. diff --git a/src/Api/CardListApi.php b/src/Api/CardListApi.php index 7abf226..2e3a93c 100644 --- a/src/Api/CardListApi.php +++ b/src/Api/CardListApi.php @@ -17,7 +17,7 @@ class CardListApi extends AbstractApi /** * @see https://trello.com/docs/api/list/#get-1-lists-list-id-or-shortlink-field */ - public static $fields = [ + public static array $fields = [ 'name', 'closed', 'idBoard', @@ -25,7 +25,7 @@ class CardListApi extends AbstractApi 'subscribed', ]; - protected $path = 'lists'; + protected string $path = 'lists'; /** * Find a list by id. diff --git a/src/Api/Checklist/ChecklistCardsApi.php b/src/Api/Checklist/ChecklistCardsApi.php index 5f2bfb4..e122361 100644 --- a/src/Api/Checklist/ChecklistCardsApi.php +++ b/src/Api/Checklist/ChecklistCardsApi.php @@ -13,7 +13,7 @@ */ class ChecklistCardsApi extends AbstractApi { - protected $path = 'checklists/#id#/cards'; + protected string $path = 'checklists/#id#/cards'; /** * Get cards related to a given checklist. diff --git a/src/Api/Checklist/ChecklistItemsApi.php b/src/Api/Checklist/ChecklistItemsApi.php index d660ebf..c50dcf9 100644 --- a/src/Api/Checklist/ChecklistItemsApi.php +++ b/src/Api/Checklist/ChecklistItemsApi.php @@ -13,7 +13,7 @@ */ class ChecklistItemsApi extends AbstractApi { - public static $fields = [ + public static array $fields = [ 'name', 'nameData', 'type', @@ -21,7 +21,7 @@ class ChecklistItemsApi extends AbstractApi 'state', ]; - protected $path = 'checklists/#id#/checkItems'; + protected string $path = 'checklists/#id#/checkItems'; /** * Get items related to a given checklist. diff --git a/src/Api/ChecklistApi.php b/src/Api/ChecklistApi.php index 79085d4..2036ad6 100644 --- a/src/Api/ChecklistApi.php +++ b/src/Api/ChecklistApi.php @@ -17,14 +17,14 @@ class ChecklistApi extends AbstractApi /** * @see https://trello.com/docs/api/list/#get-1-lists-list-id-or-shortlink-field */ - public static $fields = [ + public static array $fields = [ 'name', 'idBoard', 'idCard', 'pos', ]; - protected $path = 'checklists'; + protected string $path = 'checklists'; /** * Find a list by id. diff --git a/src/Api/LabelApi.php b/src/Api/LabelApi.php index 2a241c5..6c5c581 100644 --- a/src/Api/LabelApi.php +++ b/src/Api/LabelApi.php @@ -16,13 +16,13 @@ class LabelApi extends AbstractApi /** * @see https://developer.atlassian.com/cloud/trello/rest/api-group-labels/#api-group-labels */ - public static $fields = [ + public static array $fields = [ 'idBoard', 'name', 'color', ]; - protected $path = 'labels'; + protected string $path = 'labels'; /** * Find a label by id. diff --git a/src/Api/Member/Board/MemberBoardBackgroundsApi.php b/src/Api/Member/Board/MemberBoardBackgroundsApi.php index d48efe1..1045dc3 100644 --- a/src/Api/Member/Board/MemberBoardBackgroundsApi.php +++ b/src/Api/Member/Board/MemberBoardBackgroundsApi.php @@ -18,5 +18,5 @@ */ class MemberBoardBackgroundsApi extends AbstractApi { - protected $path = 'member/#id#/boardBackgrounds'; + protected string $path = 'member/#id#/boardBackgrounds'; } diff --git a/src/Api/Member/Board/MemberBoardStarsApi.php b/src/Api/Member/Board/MemberBoardStarsApi.php index df82e1d..d8da10d 100644 --- a/src/Api/Member/Board/MemberBoardStarsApi.php +++ b/src/Api/Member/Board/MemberBoardStarsApi.php @@ -20,5 +20,5 @@ */ class MemberBoardStarsApi extends AbstractApi { - protected $path = 'member/#id#/boardStars'; + protected string $path = 'member/#id#/boardStars'; } diff --git a/src/Api/Member/MemberActionsApi.php b/src/Api/Member/MemberActionsApi.php index e28629a..063bc34 100644 --- a/src/Api/Member/MemberActionsApi.php +++ b/src/Api/Member/MemberActionsApi.php @@ -13,7 +13,7 @@ */ class MemberActionsApi extends AbstractApi { - protected $path = 'members/#id#/actions'; + protected string $path = 'members/#id#/actions'; /** * Get actions related to a given member. diff --git a/src/Api/Member/MemberBoardsApi.php b/src/Api/Member/MemberBoardsApi.php index 9ec1427..b70bb6f 100644 --- a/src/Api/Member/MemberBoardsApi.php +++ b/src/Api/Member/MemberBoardsApi.php @@ -16,7 +16,7 @@ */ class MemberBoardsApi extends AbstractApi { - protected $path = 'members/#id#/boards'; + protected string $path = 'members/#id#/boards'; /** * Get boads related to a given member. diff --git a/src/Api/Member/MemberCardsApi.php b/src/Api/Member/MemberCardsApi.php index 8b63122..51801c2 100644 --- a/src/Api/Member/MemberCardsApi.php +++ b/src/Api/Member/MemberCardsApi.php @@ -13,7 +13,7 @@ */ class MemberCardsApi extends AbstractApi { - protected $path = 'members/#id#/cards'; + protected string $path = 'members/#id#/cards'; /** * Get cards related to a given list. diff --git a/src/Api/Member/MemberCustomBackgroundsApi.php b/src/Api/Member/MemberCustomBackgroundsApi.php index 68b6d7d..e97485f 100644 --- a/src/Api/Member/MemberCustomBackgroundsApi.php +++ b/src/Api/Member/MemberCustomBackgroundsApi.php @@ -18,5 +18,5 @@ */ class MemberCustomBackgroundsApi extends AbstractApi { - protected $path = 'members/#id#/customBackgrounds'; + protected string $path = 'members/#id#/customBackgrounds'; } diff --git a/src/Api/Member/MemberCustomEmojiApi.php b/src/Api/Member/MemberCustomEmojiApi.php index 3190f4c..58ed2e0 100644 --- a/src/Api/Member/MemberCustomEmojiApi.php +++ b/src/Api/Member/MemberCustomEmojiApi.php @@ -16,5 +16,5 @@ */ class MemberCustomEmojiApi extends AbstractApi { - protected $path = 'members/#id#/customEmoji'; + protected string $path = 'members/#id#/customEmoji'; } diff --git a/src/Api/Member/MemberCustomStickersApi.php b/src/Api/Member/MemberCustomStickersApi.php index b88b751..8e82d1e 100644 --- a/src/Api/Member/MemberCustomStickersApi.php +++ b/src/Api/Member/MemberCustomStickersApi.php @@ -17,5 +17,5 @@ */ class MemberCustomStickersApi extends AbstractApi { - protected $path = 'members/#id#/customStickers'; + protected string $path = 'members/#id#/customStickers'; } diff --git a/src/Api/Member/MemberNotificationsApi.php b/src/Api/Member/MemberNotificationsApi.php index 4ad91ca..1a8122e 100644 --- a/src/Api/Member/MemberNotificationsApi.php +++ b/src/Api/Member/MemberNotificationsApi.php @@ -14,7 +14,7 @@ */ class MemberNotificationsApi extends AbstractApi { - protected $path = 'members/#id#/notifications'; + protected string $path = 'members/#id#/notifications'; /** * Get notifications related to a given list. diff --git a/src/Api/Member/MemberOrganizationsApi.php b/src/Api/Member/MemberOrganizationsApi.php index 94885dc..3c359db 100644 --- a/src/Api/Member/MemberOrganizationsApi.php +++ b/src/Api/Member/MemberOrganizationsApi.php @@ -14,7 +14,7 @@ */ class MemberOrganizationsApi extends AbstractApi { - protected $path = 'members/#id#/organizations'; + protected string $path = 'members/#id#/organizations'; /** * Get organizations related to a given member. diff --git a/src/Api/Member/MemberSavedSearchesApi.php b/src/Api/Member/MemberSavedSearchesApi.php index 7e218de..f424e1e 100644 --- a/src/Api/Member/MemberSavedSearchesApi.php +++ b/src/Api/Member/MemberSavedSearchesApi.php @@ -21,5 +21,5 @@ */ class MemberSavedSearchesApi extends AbstractApi { - protected $path = 'members/#id#/savedSearches'; + protected string $path = 'members/#id#/savedSearches'; } diff --git a/src/Api/MemberApi.php b/src/Api/MemberApi.php index b5c525a..14b73f6 100644 --- a/src/Api/MemberApi.php +++ b/src/Api/MemberApi.php @@ -35,7 +35,7 @@ class MemberApi extends AbstractApi /** * @see https://trello.com/docs/api/member/#get-1-members-idmember-or-username-field */ - public static $fields = [ + public static array $fields = [ 'avatarHash', 'bio', 'bioData', @@ -64,7 +64,7 @@ class MemberApi extends AbstractApi 'premiumFeatures', ]; - protected $path = 'members'; + protected string $path = 'members'; /** * Find a member by id or username. diff --git a/src/Api/NotificationApi.php b/src/Api/NotificationApi.php index 6cf1441..f5af595 100644 --- a/src/Api/NotificationApi.php +++ b/src/Api/NotificationApi.php @@ -16,7 +16,7 @@ class NotificationApi extends AbstractApi * * @see https://trello.com/docs/api/notification/#get-1-notifications-idnotification-field */ - public static $fields = [ + public static array $fields = [ 'unread', 'type', 'date', @@ -24,7 +24,7 @@ class NotificationApi extends AbstractApi 'idMemberCreator', ]; - protected $path = 'notifications'; + protected string $path = 'notifications'; /** * @see https://trello.com/docs/api/notification/#get-1-notifications-idnotification diff --git a/src/Api/Organization/OrganizationBoardsApi.php b/src/Api/Organization/OrganizationBoardsApi.php index bdf769a..c640220 100644 --- a/src/Api/Organization/OrganizationBoardsApi.php +++ b/src/Api/Organization/OrganizationBoardsApi.php @@ -8,7 +8,7 @@ class OrganizationBoardsApi extends AbstractApi { - protected $path = 'organization/#id#/boards'; + protected string $path = 'organization/#id#/boards'; /** * Get boards related to a given organization. diff --git a/src/Api/OrganizationApi.php b/src/Api/OrganizationApi.php index bb294d8..abbb9a3 100644 --- a/src/Api/OrganizationApi.php +++ b/src/Api/OrganizationApi.php @@ -16,7 +16,7 @@ class OrganizationApi extends AbstractApi /** * @see https://trello.com/docs/api/organization/#get-1-organizations-idorg-or-name-field */ - public static $fields = [ + public static array $fields = [ 'name', 'displayName', 'desc', @@ -35,7 +35,7 @@ class OrganizationApi extends AbstractApi 'premiumFeatures', ]; - protected $path = 'organizations'; + protected string $path = 'organizations'; /** * Find an organization by id. diff --git a/src/Api/Token/TokenWebhooksApi.php b/src/Api/Token/TokenWebhooksApi.php index 4ec07a0..bd90d4a 100644 --- a/src/Api/Token/TokenWebhooksApi.php +++ b/src/Api/Token/TokenWebhooksApi.php @@ -13,7 +13,7 @@ */ class TokenWebhooksApi extends AbstractApi { - protected $path = 'tokens/#id#/webhooks'; + protected string $path = 'tokens/#id#/webhooks'; /** * Get webhooks related to a given token. diff --git a/src/Api/TokenApi.php b/src/Api/TokenApi.php index d60971c..958dfe8 100644 --- a/src/Api/TokenApi.php +++ b/src/Api/TokenApi.php @@ -16,7 +16,7 @@ class TokenApi extends AbstractApi /** * @see https://trello.com/docs/api/token/#get-1-tokens-token-field */ - public static $fields = [ + public static array $fields = [ 'identifier', 'idMember', 'dateCreated', @@ -24,7 +24,7 @@ class TokenApi extends AbstractApi 'permissions', ]; - protected $path = 'tokens'; + protected string $path = 'tokens'; /** * Find a token by id. diff --git a/src/Api/WebhookApi.php b/src/Api/WebhookApi.php index 42e22ec..4a33989 100644 --- a/src/Api/WebhookApi.php +++ b/src/Api/WebhookApi.php @@ -15,14 +15,14 @@ class WebhookApi extends AbstractApi /** * @see https://trello.com/docs/api/webhook/#get-1-webhooks-idwebhook-field */ - public static $fields = [ + public static array $fields = [ 'description', 'idModel', 'callbackURL', 'active', ]; - protected $path = 'webhooks'; + protected string $path = 'webhooks'; /** * Find a webhook by id. diff --git a/src/Client.php b/src/Client.php index 6f48d6e..c2b1ba4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -19,14 +19,8 @@ class Client implements ClientInterface { - /** - * @var TrelloClientInterface - */ - private $trelloClient; - - public function __construct(TrelloClientInterface $trelloClient) + public function __construct(private readonly TrelloClientInterface $trelloClient) { - $this->trelloClient = $trelloClient; } public static function create(TrelloClientInterface $trelloClient): ClientInterface diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index 31f4af0..d967637 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -15,37 +15,19 @@ */ class HttpClient implements HttpClientInterface { - /** - * @var ClientInterface - */ - protected $baseHttpClient; - - /** - * @var RequestFactoryInterface - */ - protected $requestFactory; - /** * @var HttpExceptionHandler */ - protected $httpExceptionHandler; - - /** - * @var StreamFactoryInterface - */ - private $streamFactory; + protected HttpExceptionHandler $httpExceptionHandler; /** * HttpClient constructor. */ public function __construct( - ClientInterface $baseHttpClient, - RequestFactoryInterface $requestFactory, - StreamFactoryInterface $streamFactory + protected ClientInterface $baseHttpClient, + protected RequestFactoryInterface $requestFactory, + private readonly StreamFactoryInterface $streamFactory ) { - $this->baseHttpClient = $baseHttpClient; - $this->requestFactory = $requestFactory; - $this->streamFactory = $streamFactory; $this->httpExceptionHandler = new HttpExceptionHandler(); } diff --git a/src/Client/TrelloClient.php b/src/Client/TrelloClient.php index 9b6858b..a65761b 100644 --- a/src/Client/TrelloClient.php +++ b/src/Client/TrelloClient.php @@ -8,23 +8,11 @@ class TrelloClient implements TrelloClientInterface { - /** - * @var HttpClientInterface - */ - private $httpClient; - - /** - * @var UriGeneratorInterface - */ - private $uriGenerator; - /** * ResourceClient constructor. */ - public function __construct(HttpClientInterface $httpClient, UriGeneratorInterface $uriGenerator) + public function __construct(private readonly HttpClientInterface $httpClient, private readonly UriGeneratorInterface $uriGenerator) { - $this->httpClient = $httpClient; - $this->uriGenerator = $uriGenerator; } public static function create(HttpClientInterface $httpClient, UriGeneratorInterface $uriGenerator): TrelloClientInterface diff --git a/src/ClientBuilder.php b/src/ClientBuilder.php index 7665417..947ad57 100644 --- a/src/ClientBuilder.php +++ b/src/ClientBuilder.php @@ -19,17 +19,17 @@ class ClientBuilder /** * @var HttpClientInterface|null */ - private $httpClient; + private ?HttpClientInterface $httpClient = null; /** * @var RequestFactoryInterface|null */ - private $requestFactory; + private ?RequestFactoryInterface $requestFactory = null; /** * @var StreamFactoryInterface|null */ - private $streamFactory; + private ?StreamFactoryInterface $streamFactory = null; public function getHttpClient(): HttpClientInterface { diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index 793d98a..9c9f248 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -14,31 +14,18 @@ class Configuration implements ConfigurationInterface /** * @var string */ - private $baseUri = 'https://api.trello.com/%s'; - - /** - * @var string - */ - private $apiKey; - - /** - * @var string - */ - private $apiToken; + private string $baseUri = 'https://api.trello.com/%s'; /** * @var int */ - private $apiVersion; + private int $apiVersion; /** * Configuration constructor. */ - public function __construct(string $apiKey, string $apiToken, int $apiVersion = 1) + public function __construct(private readonly string $apiKey, private readonly string $apiToken, int $apiVersion = 1) { - $this->apiKey = $apiKey; - $this->apiToken = $apiToken; - if (!in_array($apiVersion, static::SUPPORTED_API_VERSIONS, true)) { throw new InvalidApiVersionException(sprintf('Invalid api version "%s".', $apiVersion)); } diff --git a/src/Manager.php b/src/Manager.php index 653c79d..a91a162 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -24,17 +24,11 @@ class Manager implements ManagerInterface { - /** - * @var ClientInterface - */ - protected $client; - /** * Constructor. */ - public function __construct(ClientInterface $client) + public function __construct(protected ClientInterface $client) { - $this->client = $client; } /** diff --git a/src/Routing/UriGenerator.php b/src/Routing/UriGenerator.php index b7d13e7..7a3e71c 100755 --- a/src/Routing/UriGenerator.php +++ b/src/Routing/UriGenerator.php @@ -11,17 +11,11 @@ */ class UriGenerator implements UriGeneratorInterface { - /** - * @var ConfigurationInterface - */ - private $configuration; - /** * UriGenerator constructor. */ - public function __construct(ConfigurationInterface $configuration) + public function __construct(private readonly ConfigurationInterface $configuration) { - $this->configuration = $configuration; } public static function create(ConfigurationInterface $configuration): UriGeneratorInterface diff --git a/src/WebhookEventManager.php b/src/WebhookEventManager.php index 9c36669..d7dafb9 100644 --- a/src/WebhookEventManager.php +++ b/src/WebhookEventManager.php @@ -30,9 +30,9 @@ class WebhookEventManager extends Manager implements WebhookEventManagerInterface { /** - * @var EventDispatcherInterface + * @var EventDispatcher|EventDispatcherInterface */ - protected $dispatcher; + protected EventDispatcher|EventDispatcherInterface $dispatcher; /** * Constructor. diff --git a/tests/Api/AbstractApiTest.php b/tests/Api/AbstractApiTest.php index b64201a..5faebd4 100644 --- a/tests/Api/AbstractApiTest.php +++ b/tests/Api/AbstractApiTest.php @@ -4,22 +4,25 @@ namespace Semaio\TrelloApi\Tests\Api; +use DateMalformedStringException; +use DateTime; +use DateTimeZone; use GuzzleHttp\Client as GuzzleClient; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Client\TrelloClientInterface; use Semaio\TrelloApi\Tests\Fake\AbstractApiFake; class AbstractApiTest extends TestCase { - /** - * @test - */ + #[Test] public function it_can_pass_get_request_to_client(): void { $response = ['value']; $httpClient = $this->getTrelloClientMock(); - $httpClient->expects(static::any()) + $httpClient ->method('get') ->with('/path', [ 'param1' => 'param1value', @@ -37,15 +40,13 @@ public function it_can_pass_get_request_to_client(): void ])); } - /** - * @test - */ + #[Test] public function it_can_pass_post_request_to_client(): void { $response = ['value']; $httpClient = $this->getTrelloClientMock(); - $httpClient->expects(static::once()) + $httpClient->expects($this->once()) ->method('post') ->with('/path', [ 'param1' => 'param1value', @@ -63,15 +64,13 @@ public function it_can_pass_post_request_to_client(): void ])); } - /** - * @test - */ + #[Test] public function it_can_pass_patch_request_to_client(): void { $response = ['value']; $httpClient = $this->getTrelloClientMock(); - $httpClient->expects(static::once()) + $httpClient->expects($this->once()) ->method('patch') ->with('/path', [ 'param1' => 'param1value', @@ -89,15 +88,13 @@ public function it_can_pass_patch_request_to_client(): void ])); } - /** - * @test - */ + #[Test] public function it_can_pass_put_request_to_client(): void { $response = ['value']; $httpClient = $this->getTrelloClientMock(); - $httpClient->expects(static::once()) + $httpClient->expects($this->once()) ->method('put') ->with('/path', [ 'param1' => 'param1value', @@ -115,15 +112,13 @@ public function it_can_pass_put_request_to_client(): void ])); } - /** - * @test - */ + #[Test] public function it_can_pass_delete_request_to_client(): void { $response = ['value']; $httpClient = $this->getTrelloClientMock(); - $httpClient->expects(static::once()) + $httpClient->expects($this->once()) ->method('delete') ->with('/path', [ 'param1' => 'param1value', @@ -142,8 +137,9 @@ public function it_can_pass_delete_request_to_client(): void } /** - * @test + * @throws DateMalformedStringException */ + #[Test] public function it_can_transform_parameters(): void { $parameters = [ @@ -153,7 +149,7 @@ public function it_can_transform_parameters(): void 'bool_true' => true, 'bool_false' => false, ], - 'date' => new \DateTime('2020-01-01 10:00:00', new \DateTimeZone('UTC')), + 'date' => new DateTime('2020-01-01 10:00:00', new DateTimeZone('UTC')), ]; $api = new AbstractApiFake($this->getTrelloClientMock()); @@ -169,9 +165,9 @@ public function it_can_transform_parameters(): void } /** - * @return HttpClientInterface + * @return MockObject|TrelloClientInterface */ - protected function getTrelloClientMock() + protected function getTrelloClientMock(): TrelloClientInterface|MockObject { return $this->getMockBuilder(TrelloClientInterface::class) ->disableOriginalConstructor() @@ -181,13 +177,13 @@ protected function getTrelloClientMock() /** * @return GuzzleClient */ - protected function getHttpClientMock() + protected function getHttpClientMock(): GuzzleClient { $mock = $this->getMockBuilder(GuzzleClient::class) ->onlyMethods(['send']) ->getMock(); - $mock->expects(static::any())->method('send'); + $mock->method('send'); return $mock; } diff --git a/tests/Api/ActionApiTest.php b/tests/Api/ActionApiTest.php index 9c6fc51..fae042e 100644 --- a/tests/Api/ActionApiTest.php +++ b/tests/Api/ActionApiTest.php @@ -4,19 +4,17 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\ActionApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; -/** - * @group unit - */ +#[Group('unit')] class ActionApiTest extends ApiTestCase { - protected $apiPath = 'actions'; + protected string $apiPath = 'actions'; - /** - * @test - */ + #[Test] public function shouldShowAction(): void { $response = [ @@ -24,7 +22,7 @@ public function shouldShowAction(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -32,9 +30,7 @@ public function shouldShowAction(): void static::assertEquals($response, $api->show($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldUpdateAction(): void { $response = [ @@ -42,7 +38,7 @@ public function shouldUpdateAction(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -50,15 +46,13 @@ public function shouldUpdateAction(): void static::assertEquals($response, $api->update($this->fakeId, $response)); } - /** - * @test - */ + #[Test] public function shouldRemoveAction(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldRemoveAction(): void static::assertEquals($response, $api->remove($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldSetText(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldSetText(): void $text = 'Lorem Ipsum'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/text') ->willReturn($response); @@ -84,15 +76,13 @@ public function shouldSetText(): void static::assertEquals($response, $api->setText($this->fakeId, $text)); } - /** - * @test - */ + #[Test] public function shouldGetBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/board') ->willReturn($response); @@ -100,15 +90,13 @@ public function shouldGetBoard(): void static::assertEquals($response, $api->getBoard($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetBoardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/board/name') ->willReturn($response); @@ -116,28 +104,24 @@ public function shouldGetBoardField(): void static::assertEquals($response, $api->getBoardField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingBoardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getBoardField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetList(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/list') ->willReturn($response); @@ -145,15 +129,13 @@ public function shouldGetList(): void static::assertEquals($response, $api->getList($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetListField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/list/name') ->willReturn($response); @@ -161,28 +143,24 @@ public function shouldGetListField(): void static::assertEquals($response, $api->getListField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingListField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getListField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetCard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/card') ->willReturn($response); @@ -190,15 +168,13 @@ public function shouldGetCard(): void static::assertEquals($response, $api->getCard($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetCardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/card/name') ->willReturn($response); @@ -206,28 +182,24 @@ public function shouldGetCardField(): void static::assertEquals($response, $api->getCardField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingCardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getCardField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/member') ->willReturn($response); @@ -235,15 +207,13 @@ public function shouldGetMember(): void static::assertEquals($response, $api->getMember($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetMemberField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/member/bio') ->willReturn($response); @@ -251,28 +221,24 @@ public function shouldGetMemberField(): void static::assertEquals($response, $api->getMemberField($this->fakeParentId, 'bio')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingMemberField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getMemberField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetCreator(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/memberCreator') ->willReturn($response); @@ -280,15 +246,13 @@ public function shouldGetCreator(): void static::assertEquals($response, $api->getCreator($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetCreatorField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/memberCreator/bio') ->willReturn($response); @@ -296,28 +260,24 @@ public function shouldGetCreatorField(): void static::assertEquals($response, $api->getCreatorField($this->fakeParentId, 'bio')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingCreatorField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getCreatorField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetOrganization(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/organization') ->willReturn($response); @@ -325,15 +285,13 @@ public function shouldGetOrganization(): void static::assertEquals($response, $api->getOrganization($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/organization/name') ->willReturn($response); @@ -341,20 +299,18 @@ public function shouldGetOrganizationField(): void static::assertEquals($response, $api->getOrganizationField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingOrganizationField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getOrganizationField($this->fakeParentId, 'unexisting'); } - protected function getApiClass() + protected function getApiClass(): string { return ActionApi::class; } diff --git a/tests/Api/ApiTestCase.php b/tests/Api/ApiTestCase.php index c58b1fb..8d495ed 100644 --- a/tests/Api/ApiTestCase.php +++ b/tests/Api/ApiTestCase.php @@ -4,28 +4,29 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Client\TrelloClientInterface; abstract class ApiTestCase extends TestCase { - protected $fakeId = '5461efc60872da1eca5bf45c'; + protected string $fakeId = '5461efc60872da1eca5bf45c'; - protected $fakeParentId = '5461efc60872da1eca5bf45d'; + protected string $fakeParentId = '5461efc60872da1eca5bf45d'; abstract protected function getApiClass(); - protected function fakeId($model = 'any') + protected function fakeId($model = 'any'): string { return md5($model); } - protected function getPath() + protected function getPath(): array|string|null { return preg_replace('/\#id\#/', $this->fakeParentId, $this->apiPath); } - protected function getApiMock() + protected function getApiMock(): MockObject { $mock = $this->getMockBuilder(TrelloClientInterface::class) ->disableOriginalConstructor() diff --git a/tests/Api/Board/BoardActionsApiTest.php b/tests/Api/Board/BoardActionsApiTest.php index 7c1500d..4f2ec88 100644 --- a/tests/Api/Board/BoardActionsApiTest.php +++ b/tests/Api/Board/BoardActionsApiTest.php @@ -4,23 +4,21 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardActionsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardActionsApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/actions'; + protected string $apiPath = 'boards/#id#/actions'; - /** - * @test - */ + #[Test] public function shouldGetAllActions(): void { $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn([]); @@ -28,7 +26,7 @@ public function shouldGetAllActions(): void static::assertEquals([], $api->all($this->fakeParentId)); } - protected function getApiClass() + protected function getApiClass(): string { return BoardActionsApi::class; } diff --git a/tests/Api/Board/BoardCardListsApiTest.php b/tests/Api/Board/BoardCardListsApiTest.php index 43cbec8..f9f8546 100644 --- a/tests/Api/Board/BoardCardListsApiTest.php +++ b/tests/Api/Board/BoardCardListsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardCardListsApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardCardListsApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/lists'; + protected string $apiPath = 'boards/#id#/lists'; - /** - * @test - */ + #[Test] public function shouldGetAllCardLists(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetAllCardLists(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardListsWithDefaultFilter(): void { $response = ['response']; @@ -41,7 +37,7 @@ public function shouldFilterCardListsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -49,9 +45,7 @@ public function shouldFilterCardListsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardListsWithStringArgument(): void { $response = ['response']; @@ -59,7 +53,7 @@ public function shouldFilterCardListsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -67,9 +61,7 @@ public function shouldFilterCardListsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterCardListsWithArrayArgument(): void { $response = ['response']; @@ -77,7 +69,7 @@ public function shouldFilterCardListsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -85,9 +77,7 @@ public function shouldFilterCardListsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldCreateCardlist(): void { $data = [ @@ -95,7 +85,7 @@ public function shouldCreateCardlist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($data); @@ -103,9 +93,7 @@ public function shouldCreateCardlist(): void static::assertEquals($data, $api->create($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotCreateCardlistWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -115,12 +103,12 @@ public function shouldNotCreateCardlistWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $data); } - protected function getApiClass() + protected function getApiClass(): string { return BoardCardListsApi::class; } diff --git a/tests/Api/Board/BoardCardsApiTest.php b/tests/Api/Board/BoardCardsApiTest.php index b421b7c..ebecfd2 100644 --- a/tests/Api/Board/BoardCardsApiTest.php +++ b/tests/Api/Board/BoardCardsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardCardsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardCardsApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/cards'; + protected string $apiPath = 'boards/#id#/cards'; - /** - * @test - */ + #[Test] public function shouldGetAllCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllCards(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithDefaultFilter(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldFilterCardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldFilterCardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithStringArgument(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldFilterCardsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldFilterCardsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithArrayArgument(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldFilterCardsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -84,15 +76,13 @@ public function shouldFilterCardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldShowCard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -100,7 +90,7 @@ public function shouldShowCard(): void static::assertEquals($response, $api->show($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return BoardCardsApi::class; } diff --git a/tests/Api/Board/BoardChecklistsApiTest.php b/tests/Api/Board/BoardChecklistsApiTest.php index 96cc698..2410210 100644 --- a/tests/Api/Board/BoardChecklistsApiTest.php +++ b/tests/Api/Board/BoardChecklistsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardChecklistsApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardChecklistsApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/checklists'; + protected string $apiPath = 'boards/#id#/checklists'; - /** - * @test - */ + #[Test] public function shouldGetAllChecklists(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetAllChecklists(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldCreateChecklist(): void { $data = [ @@ -41,7 +37,7 @@ public function shouldCreateChecklist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($data); @@ -49,9 +45,7 @@ public function shouldCreateChecklist(): void static::assertEquals($data, $api->create($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotCreateChecklistWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -59,12 +53,12 @@ public function shouldNotCreateChecklistWithoutName(): void $data = []; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $data); } - protected function getApiClass() + protected function getApiClass(): string { return BoardChecklistsApi::class; } diff --git a/tests/Api/Board/BoardLabelsApiTest.php b/tests/Api/Board/BoardLabelsApiTest.php index 58a84e6..4fb335a 100644 --- a/tests/Api/Board/BoardLabelsApiTest.php +++ b/tests/Api/Board/BoardLabelsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardLabelsApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardLabelsApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/labels'; + protected string $apiPath = 'boards/#id#/labels'; - /** - * @test - */ + #[Test] public function shouldGetLabels(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetLabels(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldShowALabel(): void { $response = ['response']; @@ -41,7 +37,7 @@ public function shouldShowALabel(): void $color = 'green'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$color) ->willReturn($response); @@ -49,9 +45,7 @@ public function shouldShowALabel(): void static::assertEquals($response, $api->show($this->fakeParentId, $color)); } - /** - * @test - */ + #[Test] public function shouldNotShowUnexistingLabel(): void { $this->expectException(InvalidArgumentException::class); @@ -59,14 +53,12 @@ public function shouldNotShowUnexistingLabel(): void $color = 'unexisting'; $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->show($this->fakeParentId, $color); } - /** - * @test - */ + #[Test] public function shouldSetLabelName(): void { $response = ['response']; @@ -75,7 +67,7 @@ public function shouldSetLabelName(): void $name = 'Enhancement'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with('boards/'.$this->fakeParentId.'/labelNames/'.$color) ->willReturn($response); @@ -83,9 +75,7 @@ public function shouldSetLabelName(): void static::assertEquals($response, $api->setName($this->fakeParentId, $color, $name)); } - /** - * @test - */ + #[Test] public function shouldNotSetNameOfUnexistingLabel(): void { $this->expectException(InvalidArgumentException::class); @@ -94,14 +84,12 @@ public function shouldNotSetNameOfUnexistingLabel(): void $name = 'Enhancement'; $api = $this->getApiMock(); - $api->expects(static::never())->method('put'); + $api->expects($this->never())->method('put'); $api->setName($this->fakeParentId, $color, $name); } - /** - * @test - */ + #[Test] public function shouldCreateLabel(): void { $response = ['response']; @@ -110,7 +98,7 @@ public function shouldCreateLabel(): void $name = 'Enhancement'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with('boards/'.$this->fakeParentId.'/labels/') ->willReturn($response); @@ -118,9 +106,7 @@ public function shouldCreateLabel(): void static::assertEquals($response, $api->create($this->fakeParentId, $color, $name)); } - /** - * @test - */ + #[Test] public function shouldNotCreateUnexistingLabel(): void { $this->expectException(InvalidArgumentException::class); @@ -129,12 +115,12 @@ public function shouldNotCreateUnexistingLabel(): void $name = 'Enhancement'; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $color, $name); } - protected function getApiClass() + protected function getApiClass(): string { return BoardLabelsApi::class; } diff --git a/tests/Api/Board/BoardMembersApiTest.php b/tests/Api/Board/BoardMembersApiTest.php index 25168ae..a48ebf4 100644 --- a/tests/Api/Board/BoardMembersApiTest.php +++ b/tests/Api/Board/BoardMembersApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Board; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardMembersApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class BoardMembersApiTest extends ApiTestCase { - protected $apiPath = 'boards/#id#/members'; + protected string $apiPath = 'boards/#id#/members'; - /** - * @test - */ + #[Test] public function shouldGetAllMembers(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,15 +29,13 @@ public function shouldGetAllMembers(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldRemoveMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -47,15 +43,13 @@ public function shouldRemoveMember(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldInviteMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath()) ->willReturn($response); @@ -63,28 +57,24 @@ public function shouldInviteMember(): void static::assertEquals($response, $api->invite($this->fakeParentId, 'john@doe.com', 'John Doe', 'normal')); } - /** - * @test - */ + #[Test] public function shouldNotInviteMemberWithUnexistingRole(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('put'); + $api->expects($this->never())->method('put'); $api->invite($this->fakeParentId, 'john@doe.com', 'John Doe', 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetMemberCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$this->fakeId.'/cards') ->willReturn($response); @@ -92,9 +82,7 @@ public function shouldGetMemberCards(): void static::assertEquals($response, $api->cards($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldFilterMembersWithDefaultFilter(): void { $response = ['response']; @@ -102,7 +90,7 @@ public function shouldFilterMembersWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -110,9 +98,7 @@ public function shouldFilterMembersWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterMembersWithStringArgument(): void { $response = ['response']; @@ -120,7 +106,7 @@ public function shouldFilterMembersWithStringArgument(): void $filter = 'admins'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/admins') ->willReturn($response); @@ -128,9 +114,7 @@ public function shouldFilterMembersWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterMembersWithArrayArgument(): void { $response = ['response']; @@ -138,7 +122,7 @@ public function shouldFilterMembersWithArrayArgument(): void $filter = ['admins', 'owners']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/admins,owners') ->willReturn($response); @@ -146,15 +130,13 @@ public function shouldFilterMembersWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldGetInvitedMembers(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited') ->willReturn($response); @@ -162,15 +144,13 @@ public function shouldGetInvitedMembers(): void static::assertEquals($response, $api->getInvitedMembers($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetInvitedMembersField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited/bio') ->willReturn($response); @@ -178,28 +158,24 @@ public function shouldGetInvitedMembersField(): void static::assertEquals($response, $api->getInvitedMembersField($this->fakeParentId, 'bio')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingInvitedMembersField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getInvitedMembersField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetRole(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -207,20 +183,18 @@ public function shouldSetRole(): void static::assertEquals($response, $api->setRole($this->fakeParentId, $this->fakeId, 'normal')); } - /** - * @test - */ + #[Test] public function shouldNotSetUnexistingRole(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->setRole($this->fakeParentId, $this->fakeId, 'unexisting'); } - protected function getApiClass() + protected function getApiClass(): string { return BoardMembersApi::class; } diff --git a/tests/Api/Board/BoardMembershipsApiTest.php b/tests/Api/Board/BoardMembershipsApiTest.php deleted file mode 100644 index d51e029..0000000 --- a/tests/Api/Board/BoardMembershipsApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return BoardMembershipsApi::class; - } -} diff --git a/tests/Api/Board/BoardMyPreferencesApiTest.php b/tests/Api/Board/BoardMyPreferencesApiTest.php deleted file mode 100644 index 2794591..0000000 --- a/tests/Api/Board/BoardMyPreferencesApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return BoardMyPreferencesApi::class; - } -} diff --git a/tests/Api/Board/BoardPowerUpsApiTest.php b/tests/Api/Board/BoardPowerUpsApiTest.php deleted file mode 100644 index af2712e..0000000 --- a/tests/Api/Board/BoardPowerUpsApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return BoardPowerUpsApi::class; - } -} diff --git a/tests/Api/Board/BoardPreferencesApiTest.php b/tests/Api/Board/BoardPreferencesApiTest.php deleted file mode 100644 index 8ea9d70..0000000 --- a/tests/Api/Board/BoardPreferencesApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return BoardPreferencesApi::class; - } -} diff --git a/tests/Api/BoardApiTest.php b/tests/Api/BoardApiTest.php index cdae39c..eeb13d4 100644 --- a/tests/Api/BoardApiTest.php +++ b/tests/Api/BoardApiTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Board\BoardActionsApi; use Semaio\TrelloApi\Api\Board\BoardCardListsApi; use Semaio\TrelloApi\Api\Board\BoardCardsApi; @@ -18,18 +20,14 @@ use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class BoardApiTest extends ApiTestCase { - protected $fakeBoardId = '5461efc60872da1eca5bf45c'; + protected string $fakeBoardId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'boards'; + protected string $apiPath = 'boards'; - /** - * @test - */ + #[Test] public function shouldShowBoard(): void { $response = [ @@ -37,7 +35,7 @@ public function shouldShowBoard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId) ->willReturn($response); @@ -45,9 +43,7 @@ public function shouldShowBoard(): void static::assertEquals($response, $api->show($this->fakeBoardId)); } - /** - * @test - */ + #[Test] public function shouldCreateBoard(): void { $response = [ @@ -55,7 +51,7 @@ public function shouldCreateBoard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -63,9 +59,7 @@ public function shouldCreateBoard(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateBoardWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -75,14 +69,12 @@ public function shouldNotCreateBoardWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateBoard(): void { $response = [ @@ -90,7 +82,7 @@ public function shouldUpdateBoard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId) ->willReturn($response); @@ -98,9 +90,7 @@ public function shouldUpdateBoard(): void static::assertEquals($response, $api->update($this->fakeBoardId, $response)); } - /** - * @test - */ + #[Test] public function shouldGetField(): void { $response = ['response']; @@ -108,7 +98,7 @@ public function shouldGetField(): void $field = 'desc'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId.'/desc') ->willReturn($response); @@ -116,22 +106,18 @@ public function shouldGetField(): void static::assertEquals($response, $api->getField($this->fakeBoardId, $field)); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getField($this->fakeBoardId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetName(): void { $response = ['response']; @@ -139,7 +125,7 @@ public function shouldSetName(): void $name = 'Test Board'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId.'/name') ->willReturn($response); @@ -147,9 +133,7 @@ public function shouldSetName(): void static::assertEquals($response, $api->setName($this->fakeBoardId, $name)); } - /** - * @test - */ + #[Test] public function shouldSetDescription(): void { $response = ['response']; @@ -157,7 +141,7 @@ public function shouldSetDescription(): void $description = 'Test Board Description'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId.'/desc') ->willReturn($response); @@ -165,9 +149,7 @@ public function shouldSetDescription(): void static::assertEquals($response, $api->setDescription($this->fakeBoardId, $description)); } - /** - * @test - */ + #[Test] public function shouldSetClosed(): void { $response = ['response']; @@ -175,7 +157,7 @@ public function shouldSetClosed(): void $closed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId.'/closed') ->willReturn($response); @@ -183,9 +165,7 @@ public function shouldSetClosed(): void static::assertEquals($response, $api->setClosed($this->fakeBoardId, $closed)); } - /** - * @test - */ + #[Test] public function shouldSetSubscribed(): void { $response = ['response']; @@ -193,7 +173,7 @@ public function shouldSetSubscribed(): void $subscribed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId.'/subscribed') ->willReturn($response); @@ -201,15 +181,13 @@ public function shouldSetSubscribed(): void static::assertEquals($response, $api->setSubscribed($this->fakeBoardId, $subscribed)); } - /** - * @test - */ + #[Test] public function shouldSetViewed(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath.'/'.$this->fakeBoardId.'/markAsViewed') ->willReturn($response); @@ -217,9 +195,7 @@ public function shouldSetViewed(): void static::assertEquals($response, $api->setViewed($this->fakeBoardId)); } - /** - * @test - */ + #[Test] public function shouldSetOrganization(): void { $response = ['response']; @@ -227,7 +203,7 @@ public function shouldSetOrganization(): void $orgId = $this->fakeId('organization'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeBoardId.'/idOrganization/'.$orgId) ->willReturn($response); @@ -235,15 +211,13 @@ public function shouldSetOrganization(): void static::assertEquals($response, $api->setOrganization($this->fakeBoardId, $orgId)); } - /** - * @test - */ + #[Test] public function shouldGetOrganization(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId.'/organization') ->willReturn($response); @@ -251,15 +225,13 @@ public function shouldGetOrganization(): void static::assertEquals($response, $api->getOrganization($this->fakeBoardId)); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId.'/organization/name') ->willReturn($response); @@ -267,28 +239,24 @@ public function shouldGetOrganizationField(): void static::assertEquals($response, $api->getOrganizationField($this->fakeBoardId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingOrganizationField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getOrganizationField($this->fakeBoardId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetDeltas(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId.'/deltas') ->willReturn($response); @@ -296,15 +264,13 @@ public function shouldGetDeltas(): void static::assertEquals($response, $api->getDeltas($this->fakeBoardId)); } - /** - * @test - */ + #[Test] public function shouldGetStars(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeBoardId.'/boardStars') ->willReturn($response); @@ -312,87 +278,67 @@ public function shouldGetStars(): void static::assertEquals($response, $api->getStars($this->fakeBoardId)); } - /** - * @test - */ + #[Test] public function shouldGetActionsApiObject(): void { static::assertInstanceOf(BoardActionsApi::class, $this->getApiMock()->actions()); } - /** - * @test - */ + #[Test] public function shouldGetCardListsApiObject(): void { static::assertInstanceOf(BoardCardListsApi::class, $this->getApiMock()->lists()); } - /** - * @test - */ + #[Test] public function shouldGetCardsApiObject(): void { static::assertInstanceOf(BoardCardsApi::class, $this->getApiMock()->cards()); } - /** - * @test - */ + #[Test] public function shouldGetChecklistsApiObject(): void { static::assertInstanceOf(BoardChecklistsApi::class, $this->getApiMock()->checklists()); } - /** - * @test - */ + #[Test] public function shouldGetLabelsApiObject(): void { static::assertInstanceOf(BoardLabelsApi::class, $this->getApiMock()->labels()); } - /** - * @test - */ + #[Test] public function shouldGetMembersApiObject(): void { static::assertInstanceOf(BoardMembersApi::class, $this->getApiMock()->members()); } - /** - * @test - */ + #[Test] public function shouldGetMembershipsApiObject(): void { static::assertInstanceOf(BoardMembershipsApi::class, $this->getApiMock()->memberships()); } - /** - * @test - */ + #[Test] public function shouldGetMyPreferencesApiObject(): void { static::assertInstanceOf(BoardMyPreferencesApi::class, $this->getApiMock()->myPreferences()); } - /** - * @test - */ + #[Test] public function shouldGetPowerUpsApiObject(): void { static::assertInstanceOf(BoardPowerUpsApi::class, $this->getApiMock()->powerUps()); } - /** - * @test - */ + #[Test] public function shouldGetPreferencesApiObject(): void { static::assertInstanceOf(BoardPreferencesApi::class, $this->getApiMock()->preferences()); } - protected function getApiClass() + protected function getApiClass(): string { return BoardApi::class; } diff --git a/tests/Api/Card/CardActionsApiTest.php b/tests/Api/Card/CardActionsApiTest.php index 5202770..a3c6cbf 100644 --- a/tests/Api/Card/CardActionsApiTest.php +++ b/tests/Api/Card/CardActionsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardActionsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardActionsApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/actions'; + protected string $apiPath = 'cards/#id#/actions'; - /** - * @test - */ + #[Test] public function shouldGetAllActions(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllActions(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldAddComment(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldAddComment(): void $text = 'Comment text'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath().'/comments') ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldAddComment(): void static::assertEquals($response, $api->addComment($this->fakeParentId, $text)); } - /** - * @test - */ + #[Test] public function shouldUpdateComment(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldUpdateComment(): void $text = 'Comment text updated'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath().'/'.$this->fakeId.'/comments') ->willReturn($response); @@ -66,15 +60,13 @@ public function shouldUpdateComment(): void static::assertEquals($response, $api->updateComment($this->fakeParentId, $this->fakeId, $text)); } - /** - * @test - */ + #[Test] public function shouldRemoveComment(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId.'/comments') ->willReturn($response); @@ -82,7 +74,7 @@ public function shouldRemoveComment(): void static::assertEquals($response, $api->removeComment($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardActionsApi::class; } diff --git a/tests/Api/Card/CardAttachmentsApiTest.php b/tests/Api/Card/CardAttachmentsApiTest.php index 02aacf4..4bbf769 100644 --- a/tests/Api/Card/CardAttachmentsApiTest.php +++ b/tests/Api/Card/CardAttachmentsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardAttachmentsApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardAttachmentsApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/attachments'; + protected string $apiPath = 'cards/#id#/attachments'; - /** - * @test - */ + #[Test] public function shouldGetAllAttachments(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,15 +29,13 @@ public function shouldGetAllAttachments(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldShowAttachment(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -47,9 +43,7 @@ public function shouldShowAttachment(): void static::assertEquals($response, $api->show($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldCreateAttachment(): void { $data = [ @@ -57,7 +51,7 @@ public function shouldCreateAttachment(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($data); @@ -65,9 +59,7 @@ public function shouldCreateAttachment(): void static::assertEquals($data, $api->create($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotCreateAttachmentWhenParamsIncomplete(): void { $this->expectException(MissingArgumentException::class); @@ -75,20 +67,18 @@ public function shouldNotCreateAttachmentWhenParamsIncomplete(): void $data = []; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldRemoveAttachment(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -96,15 +86,13 @@ public function shouldRemoveAttachment(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldSetAsCover(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with('cards/'.$this->fakeParentId.'/idAttachmentCover') ->willReturn($response); @@ -112,7 +100,7 @@ public function shouldSetAsCover(): void static::assertEquals($response, $api->setAsCover($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardAttachmentsApi::class; } diff --git a/tests/Api/Card/CardChecklistsApiTest.php b/tests/Api/Card/CardChecklistsApiTest.php index 087e045..fb44522 100644 --- a/tests/Api/Card/CardChecklistsApiTest.php +++ b/tests/Api/Card/CardChecklistsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardChecklistsApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardChecklistsApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/checklists'; + protected string $apiPath = 'cards/#id#/checklists'; - /** - * @test - */ + #[Test] public function shouldGetAllChecklists(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('cards/'.$this->fakeParentId.'/checklists') ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetAllChecklists(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldCreateChecklist(): void { $data = [ @@ -41,7 +37,7 @@ public function shouldCreateChecklist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($data); @@ -49,9 +45,7 @@ public function shouldCreateChecklist(): void static::assertEquals($data, $api->create($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotCreateChecklistWithoutNameSourceChecklistIdOrValue(): void { $this->expectException(MissingArgumentException::class); @@ -59,20 +53,18 @@ public function shouldNotCreateChecklistWithoutNameSourceChecklistIdOrValue(): v $data = []; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldRemoveChecklist(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -80,15 +72,13 @@ public function shouldRemoveChecklist(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetItemStates(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('cards/'.$this->fakeParentId.'/checkItemStates') ->willReturn($response); @@ -96,9 +86,7 @@ public function shouldGetItemStates(): void static::assertEquals($response, $api->itemStates($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldUpdateItem(): void { $item = [ @@ -107,7 +95,7 @@ public function shouldUpdateItem(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath().'/'.$this->fakeId('checklist').'/checkItem/'.$this->fakeId) ->willReturn($item); @@ -115,9 +103,7 @@ public function shouldUpdateItem(): void static::assertEquals($item, $api->updateItem($this->fakeParentId, $this->fakeId('checklist'), $this->fakeId, $item)); } - /** - * @test - */ + #[Test] public function shouldCreateItem(): void { $item = [ @@ -126,7 +112,7 @@ public function shouldCreateItem(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath().'/'.$this->fakeId('checklist').'/checkItem') ->willReturn($item); @@ -134,15 +120,13 @@ public function shouldCreateItem(): void static::assertEquals($item, $api->createItem($this->fakeParentId, $this->fakeId('checklist'), 'Test', $item)); } - /** - * @test - */ + #[Test] public function shouldRemoveItem(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId('checklist').'/checkItem/'.$this->fakeId) ->willReturn($response); @@ -150,15 +134,13 @@ public function shouldRemoveItem(): void static::assertEquals($response, $api->removeItem($this->fakeParentId, $this->fakeId('checklist'), $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldConvertItemToCard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath().'/'.$this->fakeId('checklist').'/checkItem/'.$this->fakeId.'/convertToCard') ->willReturn($response); @@ -166,7 +148,7 @@ public function shouldConvertItemToCard(): void static::assertEquals($response, $api->convertItemToCard($this->fakeParentId, $this->fakeId('checklist'), $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardChecklistsApi::class; } diff --git a/tests/Api/Card/CardLabelsApiTest.php b/tests/Api/Card/CardLabelsApiTest.php index dfa65a7..d054dee 100644 --- a/tests/Api/Card/CardLabelsApiTest.php +++ b/tests/Api/Card/CardLabelsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardLabelsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardLabelsApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/idLabels'; + protected string $apiPath = 'cards/#id#/idLabels'; - /** - * @test - */ + #[Test] public function shouldSetLabels(): void { $labels = ['green', 'purple']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath()) ->willReturn($labels); @@ -30,9 +28,7 @@ public function shouldSetLabels(): void static::assertEquals($labels, $api->set($this->fakeParentId, $labels)); } - /** - * @test - */ + #[Test] public function shouldRemoveALabel(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldRemoveALabel(): void $label = 'green'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$label) ->willReturn($response); @@ -48,7 +44,7 @@ public function shouldRemoveALabel(): void static::assertEquals($response, $api->remove($this->fakeParentId, $label)); } - protected function getApiClass() + protected function getApiClass(): string { return CardLabelsApi::class; } diff --git a/tests/Api/Card/CardMembersApiTest.php b/tests/Api/Card/CardMembersApiTest.php index 1cfb31f..c4a7764 100644 --- a/tests/Api/Card/CardMembersApiTest.php +++ b/tests/Api/Card/CardMembersApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardMembersApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardMembersApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/members'; + protected string $apiPath = 'cards/#id#/members'; - /** - * @test - */ + #[Test] public function shouldGetAllMembers(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetAllMembers(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldSetMembers(): void { $data = [ @@ -43,7 +39,7 @@ public function shouldSetMembers(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath()) ->willReturn($data); @@ -51,9 +47,7 @@ public function shouldSetMembers(): void static::assertEquals($data, $api->set($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotSetMembersWithEmptyArray(): void { $this->expectException(InvalidArgumentException::class); @@ -61,20 +55,18 @@ public function shouldNotSetMembersWithEmptyArray(): void $data = []; $api = $this->getApiMock(); - $api->expects(static::never())->method('put'); + $api->expects($this->never())->method('put'); $api->set($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldAddMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($response); @@ -82,15 +74,13 @@ public function shouldAddMember(): void static::assertEquals($response, $api->add($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldRemoveMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -98,15 +88,13 @@ public function shouldRemoveMember(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldAddVote(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath().'/membersVoted') ->willReturn($response); @@ -114,15 +102,13 @@ public function shouldAddVote(): void static::assertEquals($response, $api->addVote($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldRemoveVote(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/membersVoted/'.$this->fakeId) ->willReturn($response); @@ -130,7 +116,7 @@ public function shouldRemoveVote(): void static::assertEquals($response, $api->removeVote($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardMembersApi::class; } diff --git a/tests/Api/Card/CardStickersApiTest.php b/tests/Api/Card/CardStickersApiTest.php index 73a0b63..34fcd03 100644 --- a/tests/Api/Card/CardStickersApiTest.php +++ b/tests/Api/Card/CardStickersApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Card; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardStickersApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardStickersApiTest extends ApiTestCase { - protected $apiPath = 'cards/#id#/stickers'; + protected string $apiPath = 'cards/#id#/stickers'; - /** - * @test - */ + #[Test] public function shouldGetAllStickers(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,15 +29,13 @@ public function shouldGetAllStickers(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldShowSticker(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -47,9 +43,7 @@ public function shouldShowSticker(): void static::assertEquals($response, $api->show($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldCreateSticker(): void { $data = [ @@ -60,7 +54,7 @@ public function shouldCreateSticker(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($data); @@ -68,9 +62,7 @@ public function shouldCreateSticker(): void static::assertEquals($data, $api->create($this->fakeParentId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotCreateStickerWhenParamsIncomplete(): void { $this->expectException(MissingArgumentException::class); @@ -82,14 +74,12 @@ public function shouldNotCreateStickerWhenParamsIncomplete(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldUpdateSticker(): void { $data = [ @@ -99,7 +89,7 @@ public function shouldUpdateSticker(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($data); @@ -107,9 +97,7 @@ public function shouldUpdateSticker(): void static::assertEquals($data, $api->update($this->fakeParentId, $this->fakeId, $data)); } - /** - * @test - */ + #[Test] public function shouldNotUpdateStickerWithoutAtLeastOneAllowedParam(): void { $this->expectException(MissingArgumentException::class); @@ -117,20 +105,18 @@ public function shouldNotUpdateStickerWithoutAtLeastOneAllowedParam(): void $data = []; $api = $this->getApiMock(); - $api->expects(static::never())->method('put'); + $api->expects($this->never())->method('put'); $api->update($this->fakeParentId, $this->fakeId, $data); } - /** - * @test - */ + #[Test] public function shouldRemoveSticker(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -138,7 +124,7 @@ public function shouldRemoveSticker(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardStickersApi::class; } diff --git a/tests/Api/CardApiTest.php b/tests/Api/CardApiTest.php index 875bcdb..3614178 100644 --- a/tests/Api/CardApiTest.php +++ b/tests/Api/CardApiTest.php @@ -4,6 +4,9 @@ namespace Semaio\TrelloApi\Tests\Api; +use DateTime; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Card\CardActionsApi; use Semaio\TrelloApi\Api\Card\CardAttachmentsApi; use Semaio\TrelloApi\Api\Card\CardChecklistsApi; @@ -14,18 +17,14 @@ use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class CardApiTest extends ApiTestCase { - protected $fakeCardId = '5461efc60872da1eca5bf45c'; + protected string $fakeCardId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'cards'; + protected string $apiPath = 'cards'; - /** - * @test - */ + #[Test] public function shouldShowCard(): void { $response = [ @@ -33,7 +32,7 @@ public function shouldShowCard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId) ->willReturn($response); @@ -41,9 +40,7 @@ public function shouldShowCard(): void static::assertEquals($response, $api->show($this->fakeCardId)); } - /** - * @test - */ + #[Test] public function shouldCreateCard(): void { $response = [ @@ -52,7 +49,7 @@ public function shouldCreateCard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -60,9 +57,7 @@ public function shouldCreateCard(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateCardWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -73,15 +68,13 @@ public function shouldNotCreateCardWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never()) + $api->expects($this->never()) ->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldNotCreateCardWithoutListId(): void { $this->expectException(MissingArgumentException::class); @@ -92,14 +85,12 @@ public function shouldNotCreateCardWithoutListId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateCard(): void { $response = [ @@ -107,7 +98,7 @@ public function shouldUpdateCard(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId) ->willReturn($response); @@ -115,9 +106,7 @@ public function shouldUpdateCard(): void static::assertEquals($response, $api->update($this->fakeCardId, $response)); } - /** - * @test - */ + #[Test] public function shouldGetField(): void { $response = ['response']; @@ -125,7 +114,7 @@ public function shouldGetField(): void $field = 'desc'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId.'/desc') ->willReturn($response); @@ -133,28 +122,24 @@ public function shouldGetField(): void static::assertEquals($response, $api->getField($this->fakeCardId, $field)); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getField($this->fakeCardId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetName(): void { $name = 'Test Board'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/name') ->willReturn([$name]); @@ -162,15 +147,13 @@ public function shouldSetName(): void static::assertEquals([$name], $api->setName($this->fakeCardId, $name)); } - /** - * @test - */ + #[Test] public function shouldSetDescription(): void { $description = 'Test Card Description'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/desc') ->willReturn([$description]); @@ -178,15 +161,13 @@ public function shouldSetDescription(): void static::assertEquals([$description], $api->setDescription($this->fakeCardId, $description)); } - /** - * @test - */ + #[Test] public function shouldSetClosed(): void { $closed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/closed') ->willReturn([$closed]); @@ -194,15 +175,13 @@ public function shouldSetClosed(): void static::assertEquals([$closed], $api->setClosed($this->fakeCardId, $closed)); } - /** - * @test - */ + #[Test] public function shouldSetSubscribed(): void { $subscribed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/subscribed') ->willReturn([$subscribed]); @@ -210,15 +189,13 @@ public function shouldSetSubscribed(): void static::assertEquals([$subscribed], $api->setSubscribed($this->fakeCardId, $subscribed)); } - /** - * @test - */ + #[Test] public function shouldSetPosition(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/pos') ->willReturn($response); @@ -226,15 +203,13 @@ public function shouldSetPosition(): void static::assertEquals($response, $api->setPosition($this->fakeCardId, 'top')); } - /** - * @test - */ + #[Test] public function shouldSetPositionNumber(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/pos') ->willReturn($response); @@ -242,25 +217,21 @@ public function shouldSetPositionNumber(): void static::assertEquals($response, $api->setPositionNumber($this->fakeCardId, 1)); } - /** - * @test - */ + #[Test] public function shouldSetDueDate(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/due') ->willReturn($response); - static::assertEquals($response, $api->setDueDate($this->fakeCardId, new \DateTime('tomorrow'))); + static::assertEquals($response, $api->setDueDate($this->fakeCardId, new DateTime('tomorrow'))); } - /** - * @test - */ + #[Test] public function shouldSetList(): void { $response = ['response']; @@ -268,7 +239,7 @@ public function shouldSetList(): void $listId = $this->fakeId('list'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/idList') ->willReturn($response); @@ -276,15 +247,13 @@ public function shouldSetList(): void static::assertEquals($response, $api->setList($this->fakeCardId, $listId)); } - /** - * @test - */ + #[Test] public function shouldGetList(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId.'/list') ->willReturn($response); @@ -292,15 +261,13 @@ public function shouldGetList(): void static::assertEquals($response, $api->getList($this->fakeCardId)); } - /** - * @test - */ + #[Test] public function shouldGetListField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId.'/list/name') ->willReturn($response); @@ -308,22 +275,18 @@ public function shouldGetListField(): void static::assertEquals($response, $api->getListField($this->fakeCardId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingListField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getListField($this->fakeCardId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetBoard(): void { $response = ['response']; @@ -331,7 +294,7 @@ public function shouldSetBoard(): void $listId = $this->fakeId('list'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeCardId.'/idBoard') ->willReturn($response); @@ -339,15 +302,13 @@ public function shouldSetBoard(): void static::assertEquals($response, $api->setBoard($this->fakeCardId, $listId)); } - /** - * @test - */ + #[Test] public function shouldGetBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId.'/board') ->willReturn($response); @@ -355,15 +316,13 @@ public function shouldGetBoard(): void static::assertEquals($response, $api->getBoard($this->fakeCardId)); } - /** - * @test - */ + #[Test] public function shouldGetBoardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeCardId.'/board/name') ->willReturn($response); @@ -371,68 +330,54 @@ public function shouldGetBoardField(): void static::assertEquals($response, $api->getBoardField($this->fakeCardId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingBoardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getBoardField($this->fakeCardId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetActionsApiObject(): void { static::assertInstanceOf(CardActionsApi::class, $this->getApiMock()->actions()); } - /** - * @test - */ + #[Test] public function shouldGetAttachmentsApiObject(): void { static::assertInstanceOf(CardAttachmentsApi::class, $this->getApiMock()->attachments()); } - /** - * @test - */ + #[Test] public function shouldGetChecklistsApiObject(): void { static::assertInstanceOf(CardChecklistsApi::class, $this->getApiMock()->checklists()); } - /** - * @test - */ + #[Test] public function shouldGetLabelsApiObject(): void { static::assertInstanceOf(CardLabelsApi::class, $this->getApiMock()->labels()); } - /** - * @test - */ + #[Test] public function shouldGetMembersApiObject(): void { static::assertInstanceOf(CardMembersApi::class, $this->getApiMock()->members()); } - /** - * @test - */ + #[Test] public function shouldGetStickersApiObject(): void { static::assertInstanceOf(CardStickersApi::class, $this->getApiMock()->stickers()); } - protected function getApiClass() + protected function getApiClass(): string { return CardApi::class; } diff --git a/tests/Api/CardList/CardListActionsApiTest.php b/tests/Api/CardList/CardListActionsApiTest.php index f57424e..ba6ccf6 100644 --- a/tests/Api/CardList/CardListActionsApiTest.php +++ b/tests/Api/CardList/CardListActionsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\CardList; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\CardList\CardListActionsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardListActionsApiTest extends ApiTestCase { - protected $apiPath = 'lists/#id#/actions'; + protected string $apiPath = 'lists/#id#/actions'; - /** - * @test - */ + #[Test] public function shouldGetAllActions(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,7 +28,7 @@ public function shouldGetAllActions(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardListActionsApi::class; } diff --git a/tests/Api/CardList/CardListCardsApiTest.php b/tests/Api/CardList/CardListCardsApiTest.php index 71ab94f..a463a4f 100644 --- a/tests/Api/CardList/CardListCardsApiTest.php +++ b/tests/Api/CardList/CardListCardsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\CardList; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\CardList\CardListCardsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class CardListCardsApiTest extends ApiTestCase { - protected $apiPath = 'lists/#id#/cards'; + protected string $apiPath = 'lists/#id#/cards'; - /** - * @test - */ + #[Test] public function shouldGetAllCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllCards(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithDefaultFilter(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldFilterCardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldFilterCardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithStringArgument(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldFilterCardsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldFilterCardsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithArrayArgument(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldFilterCardsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -84,9 +76,7 @@ public function shouldFilterCardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldCreateCard(): void { $response = ['response']; @@ -94,7 +84,7 @@ public function shouldCreateCard(): void $name = 'Test card'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($response); @@ -102,15 +92,13 @@ public function shouldCreateCard(): void static::assertEquals($response, $api->create($this->fakeParentId, $name)); } - /** - * @test - */ + #[Test] public function shouldArchiveAllCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with('lists/'.$this->fakeId.'/archiveAllCards') ->willReturn($response); @@ -118,9 +106,7 @@ public function shouldArchiveAllCards(): void static::assertEquals($response, $api->archiveAll($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldMoveAllCards(): void { $response = ['response']; @@ -129,7 +115,7 @@ public function shouldMoveAllCards(): void $boardId = $this->fakeId('board'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with('lists/'.$this->fakeId.'/moveAllCards') ->willReturn($response); @@ -137,7 +123,7 @@ public function shouldMoveAllCards(): void static::assertEquals($response, $api->moveAll($this->fakeId, $boardId, $destId)); } - protected function getApiClass() + protected function getApiClass(): string { return CardListCardsApi::class; } diff --git a/tests/Api/CardListApiTest.php b/tests/Api/CardListApiTest.php index de26b68..c9e3e7f 100644 --- a/tests/Api/CardListApiTest.php +++ b/tests/Api/CardListApiTest.php @@ -4,24 +4,22 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\CardList\CardListActionsApi; use Semaio\TrelloApi\Api\CardList\CardListCardsApi; use Semaio\TrelloApi\Api\CardListApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class CardListApiTest extends ApiTestCase { - protected $fakeListId = '5461efc60872da1eca5bf45c'; + protected string $fakeListId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'lists'; + protected string $apiPath = 'lists'; - /** - * @test - */ + #[Test] public function shouldShowList(): void { $response = [ @@ -29,7 +27,7 @@ public function shouldShowList(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('lists/'.$this->fakeListId) ->willReturn($response); @@ -37,9 +35,7 @@ public function shouldShowList(): void static::assertEquals($response, $api->show($this->fakeListId)); } - /** - * @test - */ + #[Test] public function shouldCreateList(): void { $response = [ @@ -48,7 +44,7 @@ public function shouldCreateList(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -56,9 +52,7 @@ public function shouldCreateList(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateListWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -68,14 +62,12 @@ public function shouldNotCreateListWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldNotCreateListWithoutBoardId(): void { $this->expectException(MissingArgumentException::class); @@ -85,14 +77,12 @@ public function shouldNotCreateListWithoutBoardId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateList(): void { $response = [ @@ -100,7 +90,7 @@ public function shouldUpdateList(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId) ->willReturn($response); @@ -108,9 +98,7 @@ public function shouldUpdateList(): void static::assertEquals($response, $api->update($this->fakeListId, $response)); } - /** - * @test - */ + #[Test] public function shouldSetBoard(): void { $response = ['response']; @@ -118,7 +106,7 @@ public function shouldSetBoard(): void $lisId = $this->fakeId('list'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/idBoard') ->willReturn($response); @@ -126,15 +114,13 @@ public function shouldSetBoard(): void static::assertEquals($response, $api->setBoard($this->fakeId, $lisId)); } - /** - * @test - */ + #[Test] public function shouldGetBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeListId.'/board') ->willReturn($response); @@ -142,15 +128,13 @@ public function shouldGetBoard(): void static::assertEquals($response, $api->getBoard($this->fakeListId)); } - /** - * @test - */ + #[Test] public function shouldGetBoardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeListId.'/board/name') ->willReturn($response); @@ -158,22 +142,18 @@ public function shouldGetBoardField(): void static::assertEquals($response, $api->getBoardField($this->fakeListId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingBoardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getBoardField($this->fakeListId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetName(): void { $response = ['response']; @@ -181,7 +161,7 @@ public function shouldSetName(): void $name = 'Test Checklist'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId.'/name') ->willReturn($response); @@ -189,15 +169,13 @@ public function shouldSetName(): void static::assertEquals($response, $api->setName($this->fakeListId, $name)); } - /** - * @test - */ + #[Test] public function shouldSetPosition(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId.'/pos') ->willReturn($response); @@ -205,15 +183,13 @@ public function shouldSetPosition(): void static::assertEquals($response, $api->setPosition($this->fakeListId, 'top')); } - /** - * @test - */ + #[Test] public function shouldSetPositionNumber(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId.'/pos') ->willReturn($response); @@ -221,9 +197,7 @@ public function shouldSetPositionNumber(): void static::assertEquals($response, $api->setPositionNumber($this->fakeListId, 1)); } - /** - * @test - */ + #[Test] public function shouldSetClosed(): void { $response = ['response']; @@ -231,7 +205,7 @@ public function shouldSetClosed(): void $closed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId.'/closed') ->willReturn($response); @@ -239,9 +213,7 @@ public function shouldSetClosed(): void static::assertEquals($response, $api->setClosed($this->fakeListId, $closed)); } - /** - * @test - */ + #[Test] public function shouldSetSubscribed(): void { $response = ['response']; @@ -249,7 +221,7 @@ public function shouldSetSubscribed(): void $subscribed = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeListId.'/subscribed') ->willReturn($response); @@ -257,23 +229,19 @@ public function shouldSetSubscribed(): void static::assertEquals($response, $api->setSubscribed($this->fakeListId, $subscribed)); } - /** - * @test - */ + #[Test] public function shouldGetActionsApiObject(): void { static::assertInstanceOf(CardListActionsApi::class, $this->getApiMock()->actions()); } - /** - * @test - */ + #[Test] public function shouldGetCardsApiObject(): void { static::assertInstanceOf(CardListCardsApi::class, $this->getApiMock()->cards()); } - protected function getApiClass() + protected function getApiClass(): string { return CardListApi::class; } diff --git a/tests/Api/Checklist/ChecklistCardsApiTest.php b/tests/Api/Checklist/ChecklistCardsApiTest.php index b6db746..172d403 100644 --- a/tests/Api/Checklist/ChecklistCardsApiTest.php +++ b/tests/Api/Checklist/ChecklistCardsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Checklist; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Checklist\ChecklistCardsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class ChecklistCardsApiTest extends ApiTestCase { - protected $apiPath = 'checklists/#id#/cards'; + protected string $apiPath = 'checklists/#id#/cards'; - /** - * @test - */ + #[Test] public function shouldGetAllCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllCards(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithDefaultFilter(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldFilterCardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldFilterCardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithStringArgument(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldFilterCardsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldFilterCardsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithArrayArgument(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldFilterCardsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -84,7 +76,7 @@ public function shouldFilterCardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - protected function getApiClass() + protected function getApiClass(): string { return ChecklistCardsApi::class; } diff --git a/tests/Api/Checklist/ChecklistItemsApiTest.php b/tests/Api/Checklist/ChecklistItemsApiTest.php index fea8169..50d17ac 100644 --- a/tests/Api/Checklist/ChecklistItemsApiTest.php +++ b/tests/Api/Checklist/ChecklistItemsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Checklist; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Checklist\ChecklistItemsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class ChecklistItemsApiTest extends ApiTestCase { - protected $apiPath = 'checklists/#id#/checkItems'; + protected string $apiPath = 'checklists/#id#/checkItems'; - /** - * @test - */ + #[Test] public function shouldGetAllItems(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllItems(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldUpdateItem(): void { $response = [ @@ -41,11 +37,11 @@ public function shouldUpdateItem(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($response); @@ -53,15 +49,13 @@ public function shouldUpdateItem(): void static::assertEquals($response, $api->update($this->fakeParentId, $this->fakeId, $response)); } - /** - * @test - */ + #[Test] public function shouldRemoveItem(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -69,9 +63,7 @@ public function shouldRemoveItem(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldCreateItem(): void { $response = ['response']; @@ -79,7 +71,7 @@ public function shouldCreateItem(): void $name = 'Test Item'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($response); @@ -87,7 +79,7 @@ public function shouldCreateItem(): void static::assertEquals($response, $api->create($this->fakeParentId, $name, [], true)); } - protected function getApiClass() + protected function getApiClass(): string { return ChecklistItemsApi::class; } diff --git a/tests/Api/ChecklistApiTest.php b/tests/Api/ChecklistApiTest.php index 11752e3..354e172 100644 --- a/tests/Api/ChecklistApiTest.php +++ b/tests/Api/ChecklistApiTest.php @@ -4,24 +4,22 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Checklist\ChecklistCardsApi; use Semaio\TrelloApi\Api\Checklist\ChecklistItemsApi; use Semaio\TrelloApi\Api\ChecklistApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class ChecklistApiTest extends ApiTestCase { - protected $fakeChecklistId = '5461efc60872da1eca5bf45c'; + protected string $fakeChecklistId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'checklists'; + protected string $apiPath = 'checklists'; - /** - * @test - */ + #[Test] public function shouldShowChecklist(): void { $response = [ @@ -29,7 +27,7 @@ public function shouldShowChecklist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeChecklistId) ->willReturn($response); @@ -37,9 +35,7 @@ public function shouldShowChecklist(): void static::assertEquals($response, $api->show($this->fakeChecklistId)); } - /** - * @test - */ + #[Test] public function shouldCreateChecklist(): void { $response = [ @@ -48,7 +44,7 @@ public function shouldCreateChecklist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -56,9 +52,7 @@ public function shouldCreateChecklist(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateChecklistWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -68,14 +62,12 @@ public function shouldNotCreateChecklistWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldNotCreateChecklistWithoutCardId(): void { $this->expectException(MissingArgumentException::class); @@ -85,14 +77,12 @@ public function shouldNotCreateChecklistWithoutCardId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateChecklist(): void { $response = [ @@ -100,7 +90,7 @@ public function shouldUpdateChecklist(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeChecklistId) ->willReturn($response); @@ -108,15 +98,13 @@ public function shouldUpdateChecklist(): void static::assertEquals($response, $api->update($this->fakeChecklistId, $response)); } - /** - * @test - */ + #[Test] public function shouldRemoveChecklist(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->apiPath.'/'.$this->fakeChecklistId) ->willReturn($response); @@ -124,9 +112,7 @@ public function shouldRemoveChecklist(): void static::assertEquals($response, $api->remove($this->fakeChecklistId)); } - /** - * @test - */ + #[Test] public function shouldGetField(): void { $response = ['response']; @@ -134,7 +120,7 @@ public function shouldGetField(): void $field = 'name'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/name') ->willReturn($response); @@ -142,15 +128,13 @@ public function shouldGetField(): void static::assertEquals($response, $api->getField($this->fakeChecklistId, $field)); } - /** - * @test - */ + #[Test] public function shouldGetBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/board') ->willReturn($response); @@ -158,15 +142,13 @@ public function shouldGetBoard(): void static::assertEquals($response, $api->getBoard($this->fakeChecklistId)); } - /** - * @test - */ + #[Test] public function shouldGetBoardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/board/name') ->willReturn($response); @@ -174,22 +156,18 @@ public function shouldGetBoardField(): void static::assertEquals($response, $api->getBoardField($this->fakeChecklistId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingBoardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getBoardField($this->fakeChecklistId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldSetCard(): void { $response = ['response']; @@ -197,7 +175,7 @@ public function shouldSetCard(): void $card = $this->fakeId('card'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/idCard') ->willReturn($response); @@ -205,9 +183,7 @@ public function shouldSetCard(): void static::assertEquals($response, $api->setCard($this->fakeChecklistId, $card)); } - /** - * @test - */ + #[Test] public function shouldSetName(): void { $response = ['response']; @@ -215,7 +191,7 @@ public function shouldSetName(): void $name = 'Test Checklist'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/name') ->willReturn($response); @@ -223,15 +199,13 @@ public function shouldSetName(): void static::assertEquals($response, $api->setName($this->fakeChecklistId, $name)); } - /** - * @test - */ + #[Test] public function shouldSetPosition(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/pos') ->willReturn($response); @@ -239,15 +213,13 @@ public function shouldSetPosition(): void static::assertEquals($response, $api->setPosition($this->fakeChecklistId, 'top')); } - /** - * @test - */ + #[Test] public function shouldSetPositionNumber(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeChecklistId.'/pos') ->willReturn($response); @@ -255,23 +227,19 @@ public function shouldSetPositionNumber(): void static::assertEquals($response, $api->setPositionNumber($this->fakeChecklistId, 1)); } - /** - * @test - */ + #[Test] public function shouldGetItemsApiObject(): void { static::assertInstanceOf(ChecklistItemsApi::class, $this->getApiMock()->items()); } - /** - * @test - */ + #[Test] public function shouldGetCardsApiObject(): void { static::assertInstanceOf(ChecklistCardsApi::class, $this->getApiMock()->cards()); } - protected function getApiClass() + protected function getApiClass(): string { return ChecklistApi::class; } diff --git a/tests/Api/LabelApiTest.php b/tests/Api/LabelApiTest.php index b55deeb..0376e78 100644 --- a/tests/Api/LabelApiTest.php +++ b/tests/Api/LabelApiTest.php @@ -4,21 +4,19 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\LabelApi; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class LabelApiTest extends ApiTestCase { - protected $fakeLabelId = '5461efc60872da1eca5bf45c'; + protected string $fakeLabelId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'labels'; + protected string $apiPath = 'labels'; - /** - * @test - */ + #[Test] public function shouldShowLabel(): void { $response = [ @@ -26,7 +24,7 @@ public function shouldShowLabel(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeLabelId) ->willReturn($response); @@ -34,9 +32,7 @@ public function shouldShowLabel(): void static::assertEquals($response, $api->show($this->fakeLabelId)); } - /** - * @test - */ + #[Test] public function shouldCreateLabel(): void { $response = [ @@ -46,7 +42,7 @@ public function shouldCreateLabel(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -54,9 +50,7 @@ public function shouldCreateLabel(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldCreateLabelWithoutColor(): void { $response = [ @@ -65,7 +59,7 @@ public function shouldCreateLabelWithoutColor(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -73,9 +67,7 @@ public function shouldCreateLabelWithoutColor(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateLabelWithoutBoardId(): void { $this->expectException(MissingArgumentException::class); @@ -85,14 +77,12 @@ public function shouldNotCreateLabelWithoutBoardId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldNotCreateLabelWithoutName(): void { $this->expectException(MissingArgumentException::class); @@ -102,14 +92,12 @@ public function shouldNotCreateLabelWithoutName(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateLabel(): void { $response = [ @@ -117,7 +105,7 @@ public function shouldUpdateLabel(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeLabelId) ->willReturn($response); @@ -125,9 +113,7 @@ public function shouldUpdateLabel(): void static::assertEquals($response, $api->update($this->fakeLabelId, $response)); } - /** - * @test - */ + #[Test] public function shouldSetFieldValueLabel(): void { $field = 'name'; @@ -137,7 +123,7 @@ public function shouldSetFieldValueLabel(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeLabelId.'/'.$field) ->willReturn($response); @@ -145,15 +131,13 @@ public function shouldSetFieldValueLabel(): void static::assertEquals($response, $api->set($this->fakeLabelId, $field, $value)); } - /** - * @test - */ + #[Test] public function shouldRemoveLabel(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->apiPath.'/'.$this->fakeLabelId) ->willReturn($response); @@ -161,7 +145,7 @@ public function shouldRemoveLabel(): void static::assertEquals($response, $api->remove($this->fakeLabelId)); } - protected function getApiClass() + protected function getApiClass(): string { return LabelApi::class; } diff --git a/tests/Api/Member/Board/MemberBoardBackgroundsApiTest.php b/tests/Api/Member/Board/MemberBoardBackgroundsApiTest.php deleted file mode 100644 index f8adf69..0000000 --- a/tests/Api/Member/Board/MemberBoardBackgroundsApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberBoardBackgroundsApi::class; - } -} diff --git a/tests/Api/Member/Board/MemberBoardStarsApiTest.php b/tests/Api/Member/Board/MemberBoardStarsApiTest.php deleted file mode 100644 index e7d0db7..0000000 --- a/tests/Api/Member/Board/MemberBoardStarsApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberBoardStarsApi::class; - } -} diff --git a/tests/Api/Member/MemberActionsApiTest.php b/tests/Api/Member/MemberActionsApiTest.php index 0ebfbcb..24e6f16 100644 --- a/tests/Api/Member/MemberActionsApiTest.php +++ b/tests/Api/Member/MemberActionsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Member; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\MemberActionsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class MemberActionsApiTest extends ApiTestCase { - protected $apiPath = 'members/#id#/actions'; + protected string $apiPath = 'members/#id#/actions'; - /** - * @test - */ + #[Test] public function shouldGetAllActions(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,7 +28,7 @@ public function shouldGetAllActions(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - protected function getApiClass() + protected function getApiClass(): string { return MemberActionsApi::class; } diff --git a/tests/Api/Member/MemberBoardsApiTest.php b/tests/Api/Member/MemberBoardsApiTest.php index 6120bb1..0b37059 100644 --- a/tests/Api/Member/MemberBoardsApiTest.php +++ b/tests/Api/Member/MemberBoardsApiTest.php @@ -4,28 +4,26 @@ namespace Semaio\TrelloApi\Tests\Api\Member; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\Board\MemberBoardBackgroundsApi; use Semaio\TrelloApi\Api\Member\Board\MemberBoardStarsApi; use Semaio\TrelloApi\Api\Member\MemberBoardsApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class MemberBoardsApiTest extends ApiTestCase { - protected $apiPath = 'members/#id#/boards'; + protected string $apiPath = 'members/#id#/boards'; - /** - * @test - */ + #[Test] public function shouldGetAllBoards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -33,9 +31,7 @@ public function shouldGetAllBoards(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterBoardsWithDefaultFilter(): void { $response = ['response']; @@ -43,7 +39,7 @@ public function shouldFilterBoardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -51,9 +47,7 @@ public function shouldFilterBoardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterBoardsWithStringArgument(): void { $response = ['response']; @@ -61,7 +55,7 @@ public function shouldFilterBoardsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -69,9 +63,7 @@ public function shouldFilterBoardsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterBoardsWithArrayArgument(): void { $response = ['response']; @@ -79,7 +71,7 @@ public function shouldFilterBoardsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -87,15 +79,13 @@ public function shouldFilterBoardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldGetInvitedTo(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited') ->willReturn($response); @@ -103,15 +93,13 @@ public function shouldGetInvitedTo(): void static::assertEquals($response, $api->invitedTo($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetInvitedToField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited/name') ->willReturn($response); @@ -119,28 +107,24 @@ public function shouldGetInvitedToField(): void static::assertEquals($response, $api->invitedToField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingInvitedToField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->invitedToField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldPinBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with('members/'.$this->fakeParentId.'/idBoardsPinned') ->willReturn($response); @@ -148,15 +132,13 @@ public function shouldPinBoard(): void static::assertEquals($response, $api->pin($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldUnpinBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with('members/'.$this->fakeParentId.'/idBoardsPinned/'.$this->fakeId) ->willReturn($response); @@ -164,23 +146,19 @@ public function shouldUnpinBoard(): void static::assertEquals($response, $api->unpin($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetBackgroundsApiObject(): void { static::assertInstanceOf(MemberBoardBackgroundsApi::class, $this->getApiMock()->backgrounds()); } - /** - * @test - */ + #[Test] public function shouldGetStarsApiObject(): void { static::assertInstanceOf(MemberBoardStarsApi::class, $this->getApiMock()->stars()); } - protected function getApiClass() + protected function getApiClass(): string { return MemberBoardsApi::class; } diff --git a/tests/Api/Member/MemberCardsApiTest.php b/tests/Api/Member/MemberCardsApiTest.php index bfb4e80..4006560 100644 --- a/tests/Api/Member/MemberCardsApiTest.php +++ b/tests/Api/Member/MemberCardsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Member; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\MemberCardsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class MemberCardsApiTest extends ApiTestCase { - protected $apiPath = 'members/#id#/cards'; + protected string $apiPath = 'members/#id#/cards'; - /** - * @test - */ + #[Test] public function shouldGetAllCards(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllCards(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithDefaultFilter(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldFilterCardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldFilterCardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithStringArgument(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldFilterCardsWithStringArgument(): void $filter = 'open'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open') ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldFilterCardsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterCardsWithArrayArgument(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldFilterCardsWithArrayArgument(): void $filter = ['open', 'closed']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/open,closed') ->willReturn($response); @@ -84,7 +76,7 @@ public function shouldFilterCardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - protected function getApiClass() + protected function getApiClass(): string { return MemberCardsApi::class; } diff --git a/tests/Api/Member/MemberCustomBackgroundsApiTest.php b/tests/Api/Member/MemberCustomBackgroundsApiTest.php deleted file mode 100644 index 1ff4f31..0000000 --- a/tests/Api/Member/MemberCustomBackgroundsApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberCustomBackgroundsApi::class; - } -} diff --git a/tests/Api/Member/MemberCustomEmojiApiTest.php b/tests/Api/Member/MemberCustomEmojiApiTest.php deleted file mode 100644 index 34ce2c3..0000000 --- a/tests/Api/Member/MemberCustomEmojiApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberCustomEmojiApi::class; - } -} diff --git a/tests/Api/Member/MemberCustomStickersApiTest.php b/tests/Api/Member/MemberCustomStickersApiTest.php deleted file mode 100644 index 810b312..0000000 --- a/tests/Api/Member/MemberCustomStickersApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberCustomStickersApi::class; - } -} diff --git a/tests/Api/Member/MemberNotificationsApiTest.php b/tests/Api/Member/MemberNotificationsApiTest.php index 485b3f0..0afc3cf 100644 --- a/tests/Api/Member/MemberNotificationsApiTest.php +++ b/tests/Api/Member/MemberNotificationsApiTest.php @@ -4,25 +4,23 @@ namespace Semaio\TrelloApi\Tests\Api\Member; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\MemberNotificationsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class MemberNotificationsApiTest extends ApiTestCase { - protected $apiPath = 'members/#id#/notifications'; + protected string $apiPath = 'members/#id#/notifications'; - /** - * @test - */ + #[Test] public function shouldGetAllNotifications(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -30,9 +28,7 @@ public function shouldGetAllNotifications(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterNotificationsWithDefaultFilter(): void { $response = ['response']; @@ -40,7 +36,7 @@ public function shouldFilterNotificationsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -48,9 +44,7 @@ public function shouldFilterNotificationsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterNotificationsWithStringArgument(): void { $response = ['response']; @@ -58,7 +52,7 @@ public function shouldFilterNotificationsWithStringArgument(): void $filter = 'createCard'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/createCard') ->willReturn($response); @@ -66,9 +60,7 @@ public function shouldFilterNotificationsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterNotificationsWithArrayArgument(): void { $response = ['response']; @@ -76,7 +68,7 @@ public function shouldFilterNotificationsWithArrayArgument(): void $filter = ['createCard', 'updateCard']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/createCard,updateCard') ->willReturn($response); @@ -84,7 +76,7 @@ public function shouldFilterNotificationsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - protected function getApiClass() + protected function getApiClass(): string { return MemberNotificationsApi::class; } diff --git a/tests/Api/Member/MemberOrganizationsApiTest.php b/tests/Api/Member/MemberOrganizationsApiTest.php index 14ac201..96ddb82 100644 --- a/tests/Api/Member/MemberOrganizationsApiTest.php +++ b/tests/Api/Member/MemberOrganizationsApiTest.php @@ -4,26 +4,24 @@ namespace Semaio\TrelloApi\Tests\Api\Member; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\MemberOrganizationsApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class MemberOrganizationsApiTest extends ApiTestCase { - protected $apiPath = 'members/#id#/organizations'; + protected string $apiPath = 'members/#id#/organizations'; - /** - * @test - */ + #[Test] public function shouldGetAllOrganizations(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -31,9 +29,7 @@ public function shouldGetAllOrganizations(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationsWithDefaultFilter(): void { $response = ['response']; @@ -41,7 +37,7 @@ public function shouldFilterOrganizationsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -49,9 +45,7 @@ public function shouldFilterOrganizationsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationsWithStringArgument(): void { $response = ['response']; @@ -59,7 +53,7 @@ public function shouldFilterOrganizationsWithStringArgument(): void $filter = 'members'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/members') ->willReturn($response); @@ -67,9 +61,7 @@ public function shouldFilterOrganizationsWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationsWithArrayArgument(): void { $response = ['response']; @@ -77,7 +69,7 @@ public function shouldFilterOrganizationsWithArrayArgument(): void $filter = ['members', 'public']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/members,public') ->willReturn($response); @@ -85,15 +77,13 @@ public function shouldFilterOrganizationsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationsAMemberIsInvitedTo(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited') ->willReturn($response); @@ -101,9 +91,7 @@ public function shouldGetOrganizationsAMemberIsInvitedTo(): void static::assertEquals($response, $api->invitedTo($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetFieldOfAnOrganizationAMemberIsInvitedTo(): void { $response = ['response']; @@ -111,7 +99,7 @@ public function shouldGetFieldOfAnOrganizationAMemberIsInvitedTo(): void $field = 'desc'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'Invited/desc') ->willReturn($response); @@ -119,9 +107,7 @@ public function shouldGetFieldOfAnOrganizationAMemberIsInvitedTo(): void static::assertEquals($response, $api->invitedToField($this->fakeParentId, $field)); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingFieldOfAnOrganizationAMemberIsInvitedTo(): void { $this->expectException(InvalidArgumentException::class); @@ -129,12 +115,12 @@ public function shouldNotGetUnexistingFieldOfAnOrganizationAMemberIsInvitedTo(): $field = 'unexisting'; $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->invitedToField($this->fakeParentId, $field); } - protected function getApiClass() + protected function getApiClass(): string { return MemberOrganizationsApi::class; } diff --git a/tests/Api/Member/MemberSavedSearchesApiTest.php b/tests/Api/Member/MemberSavedSearchesApiTest.php deleted file mode 100644 index f1dcb82..0000000 --- a/tests/Api/Member/MemberSavedSearchesApiTest.php +++ /dev/null @@ -1,31 +0,0 @@ -getApiClass()) - ); - } - - protected function getApiClass() - { - return MemberSavedSearchesApi::class; - } -} diff --git a/tests/Api/MemberApiTest.php b/tests/Api/MemberApiTest.php index a57bc1e..0b9af08 100644 --- a/tests/Api/MemberApiTest.php +++ b/tests/Api/MemberApiTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Member\Board\MemberBoardBackgroundsApi; use Semaio\TrelloApi\Api\Member\Board\MemberBoardStarsApi; use Semaio\TrelloApi\Api\Member\MemberActionsApi; @@ -17,18 +19,14 @@ use Semaio\TrelloApi\Api\Member\MemberSavedSearchesApi; use Semaio\TrelloApi\Api\MemberApi; -/** - * @group unit - */ +#[Group('unit')] class MemberApiTest extends ApiTestCase { - protected $fakeMemberId = '5461efc60872da1eca5bf45c'; + protected string $fakeMemberId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'members'; + protected string $apiPath = 'members'; - /** - * @test - */ + #[Test] public function shouldShowMember(): void { $response = [ @@ -36,7 +34,7 @@ public function shouldShowMember(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeMemberId) ->willReturn($response); @@ -44,9 +42,7 @@ public function shouldShowMember(): void static::assertEquals($response, $api->show($this->fakeMemberId)); } - /** - * @test - */ + #[Test] public function shouldUpdateMember(): void { $response = [ @@ -54,7 +50,7 @@ public function shouldUpdateMember(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId) ->willReturn($response); @@ -62,9 +58,7 @@ public function shouldUpdateMember(): void static::assertEquals($response, $api->update($this->fakeMemberId, $response)); } - /** - * @test - */ + #[Test] public function shouldGetDeltas(): void { $response = [ @@ -72,7 +66,7 @@ public function shouldGetDeltas(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeMemberId.'/deltas') ->willReturn($response); @@ -80,9 +74,7 @@ public function shouldGetDeltas(): void static::assertEquals($response, $api->getDeltas($this->fakeMemberId)); } - /** - * @test - */ + #[Test] public function shouldSetUsername(): void { $response = ['response']; @@ -90,7 +82,7 @@ public function shouldSetUsername(): void $username = 'TestUser'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId.'/username') ->willReturn($response); @@ -98,9 +90,7 @@ public function shouldSetUsername(): void static::assertEquals($response, $api->setUsername($this->fakeMemberId, $username)); } - /** - * @test - */ + #[Test] public function shouldSetBio(): void { $response = ['response']; @@ -108,7 +98,7 @@ public function shouldSetBio(): void $bio = 'bio'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId.'/bio') ->willReturn($response); @@ -116,9 +106,7 @@ public function shouldSetBio(): void static::assertEquals($response, $api->setBio($this->fakeMemberId, $bio)); } - /** - * @test - */ + #[Test] public function shouldSetAvatar(): void { $response = ['response']; @@ -126,7 +114,7 @@ public function shouldSetAvatar(): void $avatar = 'avatar'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath.'/'.$this->fakeMemberId.'/avatar') ->willReturn($response); @@ -134,9 +122,7 @@ public function shouldSetAvatar(): void static::assertEquals($response, $api->setAvatar($this->fakeMemberId, $avatar)); } - /** - * @test - */ + #[Test] public function shouldSetAvatarSource(): void { $response = ['response']; @@ -144,7 +130,7 @@ public function shouldSetAvatarSource(): void $avatarSource = 'avatarSource'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId.'/avatarSource') ->willReturn($response); @@ -152,9 +138,7 @@ public function shouldSetAvatarSource(): void static::assertEquals($response, $api->setAvatarSource($this->fakeMemberId, $avatarSource)); } - /** - * @test - */ + #[Test] public function shouldSetInitials(): void { $response = ['response']; @@ -162,7 +146,7 @@ public function shouldSetInitials(): void $initials = 'AA'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId.'/initials') ->willReturn($response); @@ -170,9 +154,7 @@ public function shouldSetInitials(): void static::assertEquals($response, $api->setInitials($this->fakeMemberId, $initials)); } - /** - * @test - */ + #[Test] public function shouldSetFullName(): void { $response = ['response']; @@ -180,7 +162,7 @@ public function shouldSetFullName(): void $fullName = 'John Doe'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeMemberId.'/fullName') ->willReturn($response); @@ -188,95 +170,73 @@ public function shouldSetFullName(): void static::assertEquals($response, $api->setFullName($this->fakeMemberId, $fullName)); } - /** - * @test - */ + #[Test] public function shouldGetActionsApiObject(): void { static::assertInstanceOf(MemberActionsApi::class, $this->getApiMock()->actions()); } - /** - * @test - */ + #[Test] public function shouldGetBoardsApiObject(): void { static::assertInstanceOf(MemberBoardsApi::class, $this->getApiMock()->boards()); } - /** - * @test - */ + #[Test] public function shouldGetCardsApiObject(): void { static::assertInstanceOf(MemberCardsApi::class, $this->getApiMock()->cards()); } - /** - * @test - */ + #[Test] public function shouldGetCustomBackgroundsApiObject(): void { static::assertInstanceOf(MemberCustomBackgroundsApi::class, $this->getApiMock()->customBackgrounds()); } - /** - * @test - */ + #[Test] public function shouldGetCustomEmojiApiObject(): void { static::assertInstanceOf(MemberCustomEmojiApi::class, $this->getApiMock()->customEmoji()); } - /** - * @test - */ + #[Test] public function shouldGetCustomStickersApiObject(): void { static::assertInstanceOf(MemberCustomStickersApi::class, $this->getApiMock()->customStickers()); } - /** - * @test - */ + #[Test] public function shouldGetNotificationsApiObject(): void { static::assertInstanceOf(MemberNotificationsApi::class, $this->getApiMock()->notifications()); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationsApiObject(): void { static::assertInstanceOf(MemberOrganizationsApi::class, $this->getApiMock()->organizations()); } - /** - * @test - */ + #[Test] public function shouldGetSavedSearchesApiObject(): void { static::assertInstanceOf(MemberSavedSearchesApi::class, $this->getApiMock()->savedSearches()); } - /** - * @test - */ + #[Test] public function shouldGetBoardBackgroundsApiObject(): void { static::assertInstanceOf(MemberBoardBackgroundsApi::class, $this->getApiMock()->boards()->backgrounds()); } - /** - * @test - */ + #[Test] public function shouldGetBoardStarsApiObject(): void { static::assertInstanceOf(MemberBoardStarsApi::class, $this->getApiMock()->boards()->stars()); } - protected function getApiClass() + protected function getApiClass(): string { return MemberApi::class; } diff --git a/tests/Api/NotificationApiTest.php b/tests/Api/NotificationApiTest.php index 55c6471..d94f30a 100644 --- a/tests/Api/NotificationApiTest.php +++ b/tests/Api/NotificationApiTest.php @@ -4,19 +4,17 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\NotificationApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; -/** - * @group unit - */ +#[Group('unit')] class NotificationApiTest extends ApiTestCase { - protected $apiPath = 'notifications'; + protected string $apiPath = 'notifications'; - /** - * @test - */ + #[Test] public function shouldShowNotification(): void { $response = [ @@ -24,7 +22,7 @@ public function shouldShowNotification(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('notifications/'.$this->fakeId) ->willReturn($response); @@ -32,9 +30,7 @@ public function shouldShowNotification(): void static::assertEquals($response, $api->show($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldUpdateNotification(): void { $response = [ @@ -42,7 +38,7 @@ public function shouldUpdateNotification(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with('notifications/'.$this->fakeId) ->willReturn($response); @@ -50,9 +46,7 @@ public function shouldUpdateNotification(): void static::assertEquals($response, $api->update($this->fakeId, $response)); } - /** - * @test - */ + #[Test] public function shouldSetUnread(): void { $response = [ @@ -60,7 +54,7 @@ public function shouldSetUnread(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with('notifications/'.$this->fakeId.'/unread') ->willReturn($response); @@ -68,15 +62,13 @@ public function shouldSetUnread(): void static::assertEquals($response, $api->setUnread($this->fakeId, true)); } - /** - * @test - */ + #[Test] public function shouldSetAllRead(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with('notifications/all/read') ->willReturn($response); @@ -84,15 +76,13 @@ public function shouldSetAllRead(): void static::assertEquals($response, $api->setAllRead()); } - /** - * @test - */ + #[Test] public function shouldGetEntities(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('notifications/'.$this->fakeId.'/entities') ->willReturn($response); @@ -100,15 +90,13 @@ public function shouldGetEntities(): void static::assertEquals($response, $api->getEntities($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetBoard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/board') ->willReturn($response); @@ -116,15 +104,13 @@ public function shouldGetBoard(): void static::assertEquals($response, $api->getBoard($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetBoardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/board/name') ->willReturn($response); @@ -132,28 +118,24 @@ public function shouldGetBoardField(): void static::assertEquals($response, $api->getBoardField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingBoardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getBoardField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetList(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/list') ->willReturn($response); @@ -161,15 +143,13 @@ public function shouldGetList(): void static::assertEquals($response, $api->getList($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetListField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/list/name') ->willReturn($response); @@ -177,28 +157,24 @@ public function shouldGetListField(): void static::assertEquals($response, $api->getListField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingListField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getListField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetCard(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/card') ->willReturn($response); @@ -206,15 +182,13 @@ public function shouldGetCard(): void static::assertEquals($response, $api->getCard($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetCardField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/card/name') ->willReturn($response); @@ -222,28 +196,24 @@ public function shouldGetCardField(): void static::assertEquals($response, $api->getCardField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingCardField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getCardField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/member') ->willReturn($response); @@ -251,15 +221,13 @@ public function shouldGetMember(): void static::assertEquals($response, $api->getMember($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetMemberField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/member/bio') ->willReturn($response); @@ -267,28 +235,24 @@ public function shouldGetMemberField(): void static::assertEquals($response, $api->getMemberField($this->fakeParentId, 'bio')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingMemberField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getMemberField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetCreator(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/memberCreator') ->willReturn($response); @@ -296,15 +260,13 @@ public function shouldGetCreator(): void static::assertEquals($response, $api->getCreator($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetCreatorField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/memberCreator/bio') ->willReturn($response); @@ -312,28 +274,24 @@ public function shouldGetCreatorField(): void static::assertEquals($response, $api->getCreatorField($this->fakeParentId, 'bio')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingCreatorField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getCreatorField($this->fakeParentId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetOrganization(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/organization') ->willReturn($response); @@ -341,15 +299,13 @@ public function shouldGetOrganization(): void static::assertEquals($response, $api->getOrganization($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeParentId.'/organization/name') ->willReturn($response); @@ -357,20 +313,18 @@ public function shouldGetOrganizationField(): void static::assertEquals($response, $api->getOrganizationField($this->fakeParentId, 'name')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingOrganizationField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getOrganizationField($this->fakeParentId, 'unexisting'); } - protected function getApiClass() + protected function getApiClass(): string { return NotificationApi::class; } diff --git a/tests/Api/Organization/OrganizationBoardsApiTest.php b/tests/Api/Organization/OrganizationBoardsApiTest.php index d7c6c3f..c0cbb18 100644 --- a/tests/Api/Organization/OrganizationBoardsApiTest.php +++ b/tests/Api/Organization/OrganizationBoardsApiTest.php @@ -4,22 +4,21 @@ namespace Semaio\TrelloApi\Tests\Api\Organization; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Organization\OrganizationBoardsApi; use Semaio\TrelloApi\Tests\Api\ApiTestCase; class OrganizationBoardsApiTest extends ApiTestCase { - protected $apiPath = 'organization/#id#/boards'; + protected string $apiPath = 'organization/#id#/boards'; - /** - * @test - */ + #[Test] public function shouldGetAllActions(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -27,9 +26,7 @@ public function shouldGetAllActions(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationBoardsWithDefaultFilter(): void { $response = ['response']; @@ -37,7 +34,7 @@ public function shouldFilterOrganizationBoardsWithDefaultFilter(): void $defaultFilter = 'all'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$defaultFilter) ->willReturn($response); @@ -45,9 +42,7 @@ public function shouldFilterOrganizationBoardsWithDefaultFilter(): void static::assertEquals($response, $api->filter($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationBoardssWithStringArgument(): void { $response = ['response']; @@ -55,7 +50,7 @@ public function shouldFilterOrganizationBoardssWithStringArgument(): void $filter = 'members'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/members') ->willReturn($response); @@ -63,9 +58,7 @@ public function shouldFilterOrganizationBoardssWithStringArgument(): void static::assertEquals($response, $api->filter($this->fakeParentId, $filter)); } - /** - * @test - */ + #[Test] public function shouldFilterOrganizationBoardsWithArrayArgument(): void { $response = ['response']; @@ -73,7 +66,7 @@ public function shouldFilterOrganizationBoardsWithArrayArgument(): void $filter = ['members', 'public']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/members,public') ->willReturn($response); @@ -81,7 +74,7 @@ public function shouldFilterOrganizationBoardsWithArrayArgument(): void static::assertEquals($response, $api->filters($this->fakeParentId, $filter)); } - protected function getApiClass() + protected function getApiClass(): string { return OrganizationBoardsApi::class; } diff --git a/tests/Api/OrganizationApiTest.php b/tests/Api/OrganizationApiTest.php index 4d97e2a..6f82168 100644 --- a/tests/Api/OrganizationApiTest.php +++ b/tests/Api/OrganizationApiTest.php @@ -4,17 +4,15 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Organization\OrganizationBoardsApi; use Semaio\TrelloApi\Api\OrganizationApi; -/** - * @group unit - */ +#[Group('unit')] class OrganizationApiTest extends ApiTestCase { - /** - * @test - */ + #[Test] public function shouldShowOrganization(): void { $response = [ @@ -22,7 +20,7 @@ public function shouldShowOrganization(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with('organizations/54744b094fef0c7d704ca379') ->willReturn($response); @@ -30,15 +28,13 @@ public function shouldShowOrganization(): void static::assertEquals($response, $api->show('54744b094fef0c7d704ca379')); } - /** - * @test - */ + #[Test] public function shouldGetOrganizationBoardsApiObject(): void { static::assertInstanceOf(OrganizationBoardsApi::class, $this->getApiMock()->boards()); } - protected function getApiClass() + protected function getApiClass(): string { return OrganizationApi::class; } diff --git a/tests/Api/Token/TokenWebhooksApiTest.php b/tests/Api/Token/TokenWebhooksApiTest.php index 2258035..f90081e 100644 --- a/tests/Api/Token/TokenWebhooksApiTest.php +++ b/tests/Api/Token/TokenWebhooksApiTest.php @@ -4,20 +4,18 @@ namespace Semaio\TrelloApi\Tests\Api\Token; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Token\TokenWebhooksApi; use Semaio\TrelloApi\Exception\MissingArgumentException; use Semaio\TrelloApi\Tests\Api\ApiTestCase; -/** - * @group unit - */ +#[Group('unit')] class TokenWebhooksApiTest extends ApiTestCase { - protected $apiPath = 'tokens/#id#/webhooks'; + protected string $apiPath = 'tokens/#id#/webhooks'; - /** - * @test - */ + #[Test] public function shouldCreateWebhook(): void { $response = [ @@ -26,7 +24,7 @@ public function shouldCreateWebhook(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->getPath()) ->willReturn($response); @@ -34,9 +32,7 @@ public function shouldCreateWebhook(): void static::assertEquals($response, $api->create($this->fakeParentId, $response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateWebhookWithoutCallbackUrl(): void { $this->expectException(MissingArgumentException::class); @@ -46,14 +42,12 @@ public function shouldNotCreateWebhookWithoutCallbackUrl(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeId, $data); } - /** - * @test - */ + #[Test] public function shouldNotCreateWebhookWithoutModelId(): void { $this->expectException(MissingArgumentException::class); @@ -63,14 +57,12 @@ public function shouldNotCreateWebhookWithoutModelId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($this->fakeId, $data); } - /** - * @test - */ + #[Test] public function shouldUpdateWebhook(): void { $response = [ @@ -79,7 +71,7 @@ public function shouldUpdateWebhook(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->getPath()) ->willReturn($response); @@ -87,9 +79,7 @@ public function shouldUpdateWebhook(): void static::assertEquals($response, $api->update($this->fakeParentId, $response)); } - /** - * @test - */ + #[Test] public function shouldNotUpdateWebhookWithoutCallbackUrl(): void { $this->expectException(MissingArgumentException::class); @@ -99,14 +89,12 @@ public function shouldNotUpdateWebhookWithoutCallbackUrl(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->update($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldNotUpdateWebhookWithoutModelId(): void { $this->expectException(MissingArgumentException::class); @@ -116,20 +104,18 @@ public function shouldNotUpdateWebhookWithoutModelId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->update($this->fakeParentId, $data); } - /** - * @test - */ + #[Test] public function shouldRemoveWebhook(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -137,15 +123,13 @@ public function shouldRemoveWebhook(): void static::assertEquals($response, $api->remove($this->fakeParentId, $this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetAllWebhooks(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath()) ->willReturn($response); @@ -153,15 +137,13 @@ public function shouldGetAllWebhooks(): void static::assertEquals($response, $api->all($this->fakeParentId)); } - /** - * @test - */ + #[Test] public function shouldShowWebhook(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->getPath().'/'.$this->fakeId) ->willReturn($response); @@ -169,7 +151,7 @@ public function shouldShowWebhook(): void static::assertEquals($response, $api->show($this->fakeParentId, $this->fakeId)); } - protected function getApiClass() + protected function getApiClass(): string { return TokenWebhooksApi::class; } diff --git a/tests/Api/TokenApiTest.php b/tests/Api/TokenApiTest.php index b0308fe..505d11a 100644 --- a/tests/Api/TokenApiTest.php +++ b/tests/Api/TokenApiTest.php @@ -4,22 +4,20 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\Token\TokenWebhooksApi; use Semaio\TrelloApi\Api\TokenApi; use Semaio\TrelloApi\Exception\InvalidArgumentException; -/** - * @group unit - */ +#[Group('unit')] class TokenApiTest extends ApiTestCase { - protected $fakeId = '5461efc60872da1eca5bf45c'; + protected string $fakeId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'tokens'; + protected string $apiPath = 'tokens'; - /** - * @test - */ + #[Test] public function shouldShowToken(): void { $response = [ @@ -27,7 +25,7 @@ public function shouldShowToken(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -35,15 +33,13 @@ public function shouldShowToken(): void static::assertEquals($response, $api->show($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldRemoveToken(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -51,15 +47,13 @@ public function shouldRemoveToken(): void static::assertEquals($response, $api->remove($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetMember(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeId.'/member') ->willReturn($response); @@ -67,15 +61,13 @@ public function shouldGetMember(): void static::assertEquals($response, $api->getMember($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldGetMemberField(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeId.'/member/fullName') ->willReturn($response); @@ -83,28 +75,24 @@ public function shouldGetMemberField(): void static::assertEquals($response, $api->getMemberField($this->fakeId, 'fullName')); } - /** - * @test - */ + #[Test] public function shouldNotGetUnexistingMemberField(): void { $this->expectException(InvalidArgumentException::class); $api = $this->getApiMock(); - $api->expects(static::never())->method('get'); + $api->expects($this->never())->method('get'); $api->getMemberField($this->fakeId, 'unexisting'); } - /** - * @test - */ + #[Test] public function shouldGetWebhooksApiObject(): void { static::assertInstanceOf(TokenWebhooksApi::class, $this->getApiMock()->webhooks()); } - protected function getApiClass() + protected function getApiClass(): string { return TokenApi::class; } diff --git a/tests/Api/WebhookApiTest.php b/tests/Api/WebhookApiTest.php index d6ed299..1d64c0c 100644 --- a/tests/Api/WebhookApiTest.php +++ b/tests/Api/WebhookApiTest.php @@ -4,21 +4,19 @@ namespace Semaio\TrelloApi\Tests\Api; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Semaio\TrelloApi\Api\WebhookApi; use Semaio\TrelloApi\Exception\MissingArgumentException; -/** - * @group unit - */ +#[Group('unit')] class WebhookApiTest extends ApiTestCase { - protected $fakeId = '5461efc60872da1eca5bf45c'; + protected string $fakeId = '5461efc60872da1eca5bf45c'; - protected $apiPath = 'webhooks'; + protected string $apiPath = 'webhooks'; - /** - * @test - */ + #[Test] public function shouldShowWebhook(): void { $response = [ @@ -26,7 +24,7 @@ public function shouldShowWebhook(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('get') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -34,15 +32,13 @@ public function shouldShowWebhook(): void static::assertEquals($response, $api->show($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldRemoveToken(): void { $response = ['response']; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('delete') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -50,9 +46,7 @@ public function shouldRemoveToken(): void static::assertEquals($response, $api->remove($this->fakeId)); } - /** - * @test - */ + #[Test] public function shouldSetDescription(): void { $response = ['response']; @@ -60,7 +54,7 @@ public function shouldSetDescription(): void $description = 'Test Webhook Description'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/description') ->willReturn($response); @@ -68,9 +62,7 @@ public function shouldSetDescription(): void static::assertEquals($response, $api->setDescription($this->fakeId, $description)); } - /** - * @test - */ + #[Test] public function shouldSetCallbackUrl(): void { $response = ['response']; @@ -78,7 +70,7 @@ public function shouldSetCallbackUrl(): void $description = 'Test Webhook CallbackUrl'; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/callbackUrl') ->willReturn($response); @@ -86,9 +78,7 @@ public function shouldSetCallbackUrl(): void static::assertEquals($response, $api->setCallbackUrl($this->fakeId, $description)); } - /** - * @test - */ + #[Test] public function shouldSetModel(): void { $response = ['response']; @@ -96,7 +86,7 @@ public function shouldSetModel(): void $modelId = $this->fakeId('webhook'); $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/idModel') ->willReturn($response); @@ -104,9 +94,7 @@ public function shouldSetModel(): void static::assertEquals($response, $api->setModel($this->fakeId, $modelId)); } - /** - * @test - */ + #[Test] public function shouldSetActive(): void { $response = ['response']; @@ -114,7 +102,7 @@ public function shouldSetActive(): void $status = true; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId.'/active') ->willReturn($response); @@ -122,9 +110,7 @@ public function shouldSetActive(): void static::assertEquals($response, $api->setActive($this->fakeId, $status)); } - /** - * @test - */ + #[Test] public function shouldCreateWebhook(): void { $response = [ @@ -133,7 +119,7 @@ public function shouldCreateWebhook(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('post') ->with($this->apiPath) ->willReturn($response); @@ -141,9 +127,7 @@ public function shouldCreateWebhook(): void static::assertEquals($response, $api->create($response)); } - /** - * @test - */ + #[Test] public function shouldNotCreateWebhookWithoutCallbackUrl(): void { $this->expectException(MissingArgumentException::class); @@ -153,14 +137,12 @@ public function shouldNotCreateWebhookWithoutCallbackUrl(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldNotCreateWebhookWithoutModelId(): void { $this->expectException(MissingArgumentException::class); @@ -170,14 +152,12 @@ public function shouldNotCreateWebhookWithoutModelId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->create($data); } - /** - * @test - */ + #[Test] public function shouldUpdateWebhook(): void { $response = [ @@ -186,7 +166,7 @@ public function shouldUpdateWebhook(): void ]; $api = $this->getApiMock(); - $api->expects(static::once()) + $api->expects($this->once()) ->method('put') ->with($this->apiPath.'/'.$this->fakeId) ->willReturn($response); @@ -194,9 +174,7 @@ public function shouldUpdateWebhook(): void static::assertEquals($response, $api->update($this->fakeId, $response)); } - /** - * @test - */ + #[Test] public function shouldNotUpdateWebhookWithoutCallbackUrl(): void { $this->expectException(MissingArgumentException::class); @@ -206,14 +184,12 @@ public function shouldNotUpdateWebhookWithoutCallbackUrl(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->update($this->fakeId, $data); } - /** - * @test - */ + #[Test] public function shouldNotUpdateWebhookWithoutModelId(): void { $this->expectException(MissingArgumentException::class); @@ -223,12 +199,12 @@ public function shouldNotUpdateWebhookWithoutModelId(): void ]; $api = $this->getApiMock(); - $api->expects(static::never())->method('post'); + $api->expects($this->never())->method('post'); $api->update($this->fakeId, $data); } - protected function getApiClass() + protected function getApiClass(): string { return WebhookApi::class; } diff --git a/tests/Client/HttpClientTest.php b/tests/Client/HttpClientTest.php index 02cd114..5b02434 100644 --- a/tests/Client/HttpClientTest.php +++ b/tests/Client/HttpClientTest.php @@ -4,8 +4,11 @@ namespace Semaio\TrelloApi\Tests\Client; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; @@ -23,23 +26,26 @@ class HttpClientTest extends TestCase /** * @var ClientInterface|MockObject */ - protected $baseHttpClient; + protected ClientInterface|MockObject $baseHttpClient; /** * @var RequestFactoryInterface|MockObject */ - protected $requestFactory; + protected MockObject|RequestFactoryInterface $requestFactory; /** * @var StreamFactoryInterface|MockObject */ - protected $streamFactory; + protected MockObject|StreamFactoryInterface $streamFactory; /** * @var HttpClient */ - protected $httpClient; + protected HttpClient $httpClient; + /** + * @throws Exception + */ protected function setUp(): void { $this->baseHttpClient = $this->createMock(ClientInterface::class); @@ -53,9 +59,7 @@ protected function setUp(): void ); } - /** - * @test - */ + #[Test] public function it_can_create_http_client(): void { $client = HttpClient::create($this->baseHttpClient, $this->requestFactory, $this->streamFactory); @@ -64,8 +68,10 @@ public function it_can_create_http_client(): void } /** - * @test + * @throws Exception + * @throws ClientExceptionInterface */ + #[Test] public function it_can_send_request_with_string_body(): void { $httpMethod = 'POST'; @@ -75,7 +81,7 @@ public function it_can_send_request_with_string_body(): void /** @var MockObject|RequestInterface $request */ $request = $this->createMock(RequestInterface::class); - $this->requestFactory->expects(static::once()) + $this->requestFactory->expects($this->once()) ->method('createRequest') ->with($httpMethod, $uri) ->willReturn($request); @@ -83,12 +89,12 @@ public function it_can_send_request_with_string_body(): void /** @var MockObject|StreamInterface $stream */ $stream = $this->createMock(StreamInterface::class); - $this->streamFactory->expects(static::once()) + $this->streamFactory->expects($this->once()) ->method('createStream') ->with($body) ->willReturn($stream); - $request->expects(static::once()) + $request->expects($this->once()) ->method('withBody') ->with($stream) ->willReturnSelf(); @@ -96,7 +102,7 @@ public function it_can_send_request_with_string_body(): void /** @var MockObject|ResponseInterface $response */ $response = $this->createMock(ResponseInterface::class); - $this->baseHttpClient->expects(static::once()) + $this->baseHttpClient->expects($this->once()) ->method('sendRequest') ->with($request) ->willReturn($response); @@ -105,8 +111,10 @@ public function it_can_send_request_with_string_body(): void } /** - * @test + * @throws ClientExceptionInterface + * @throws Exception */ + #[Test] public function it_can_send_request_with_stream_body(): void { $httpMethod = 'POST'; @@ -117,12 +125,12 @@ public function it_can_send_request_with_stream_body(): void /** @var MockObject|RequestInterface $request */ $request = $this->createMock(RequestInterface::class); - $this->requestFactory->expects(static::once()) + $this->requestFactory->expects($this->once()) ->method('createRequest') ->with($httpMethod, $uri) ->willReturn($request); - $request->expects(static::once()) + $request->expects($this->once()) ->method('withBody') ->with($body) ->willReturnSelf(); @@ -130,7 +138,7 @@ public function it_can_send_request_with_stream_body(): void /** @var MockObject|ResponseInterface $response */ $response = $this->createMock(ResponseInterface::class); - $this->baseHttpClient->expects(static::once()) + $this->baseHttpClient->expects($this->once()) ->method('sendRequest') ->with($request) ->willReturn($response); @@ -139,8 +147,10 @@ public function it_can_send_request_with_stream_body(): void } /** - * @test + * @throws Exception + * @throws ClientExceptionInterface */ + #[Test] public function it_can_send_request(): void { $httpMethod = 'POST'; @@ -152,12 +162,12 @@ public function it_can_send_request(): void /** @var MockObject|RequestInterface $request */ $request = $this->createMock(RequestInterface::class); - $this->requestFactory->expects(static::once()) + $this->requestFactory->expects($this->once()) ->method('createRequest') ->with($httpMethod, $uri) ->willReturn($request); - $request->expects(static::once()) + $request->expects($this->once()) ->method('withHeader') ->with('header', 'content') ->willReturnSelf(); @@ -165,11 +175,11 @@ public function it_can_send_request(): void /** @var MockObject|ResponseInterface $response */ $response = $this->createMock(ResponseInterface::class); - $this->baseHttpClient->expects(static::once()) + $this->baseHttpClient->expects($this->once()) ->method('sendRequest') ->with($request) ->willReturn($response); - $this->httpClient->sendRequest($httpMethod, $uri, $headers, null); + $this->httpClient->sendRequest($httpMethod, $uri, $headers); } } diff --git a/tests/Client/HttpExceptionHandlerTest.php b/tests/Client/HttpExceptionHandlerTest.php index 7aa60ee..e2469b1 100644 --- a/tests/Client/HttpExceptionHandlerTest.php +++ b/tests/Client/HttpExceptionHandlerTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests\Client; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -25,18 +27,21 @@ class HttpExceptionHandlerTest extends TestCase /** * @var HttpExceptionHandler */ - protected $httpExceptionHandler; + protected HttpExceptionHandler $httpExceptionHandler; /** * @var RequestInterface|MockObject */ - protected $request; + protected MockObject|RequestInterface $request; /** * @var ResponseInterface|MockObject */ - protected $response; + protected ResponseInterface|MockObject $response; + /** + * @throws Exception + */ protected function setUp(): void { $this->httpExceptionHandler = new HttpExceptionHandler(); @@ -44,140 +49,124 @@ protected function setUp(): void $this->response = $this->createMock(ResponseInterface::class); } - /** - * @test - */ + #[Test] public function it_never_handles_successful_response(): void { - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(200); - $this->response->expects(static::never())->method('getReasonPhrase'); + $this->response->expects($this->never())->method('getReasonPhrase'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_redirection_http_exception(): void { $this->expectException(RedirectionHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(300); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_bad_request_http_exception(): void { $this->expectException(BadRequestHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(400); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_unauthorized_http_exception(): void { $this->expectException(UnauthorizedHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(401); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_not_found_http_exception(): void { $this->expectException(NotFoundHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(404); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_unprocessable_entity_http_exception(): void { $this->expectException(UnprocessableEntityHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(422); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_client_error_http_exception(): void { $this->expectException(ClientErrorHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(429); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); $this->httpExceptionHandler->handle($this->request, $this->response); } - /** - * @test - */ + #[Test] public function it_handles_server_error_http_exception(): void { $this->expectException(ServerErrorHttpException::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(500); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getReasonPhrase') ->willReturn('reason'); diff --git a/tests/Client/ResponseHandlerTest.php b/tests/Client/ResponseHandlerTest.php index a521f2b..832db18 100644 --- a/tests/Client/ResponseHandlerTest.php +++ b/tests/Client/ResponseHandlerTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests\Client; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -16,8 +18,9 @@ class ResponseHandlerTest extends TestCase { /** - * @test + * @throws Exception */ + #[Test] public function it_can_handle_successful_response(): void { $expectedResponse = ['response']; @@ -25,11 +28,11 @@ public function it_can_handle_successful_response(): void $response = $this->createMock(ResponseInterface::class); $stream = $this->createMock(StreamInterface::class); - $response->expects(static::once()) + $response->expects($this->once()) ->method('getBody') ->willReturn($stream); - $stream->expects(static::once()) + $stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($expectedResponse)); @@ -37,8 +40,9 @@ public function it_can_handle_successful_response(): void } /** - * @test + * @throws Exception */ + #[Test] public function it_will_not_handle_invalid_response(): void { $this->expectException(InvalidJsonResponseException::class); @@ -46,11 +50,11 @@ public function it_will_not_handle_invalid_response(): void $response = $this->createMock(ResponseInterface::class); $stream = $this->createMock(StreamInterface::class); - $response->expects(static::once()) + $response->expects($this->once()) ->method('getBody') ->willReturn($stream); - $stream->expects(static::once()) + $stream->expects($this->once()) ->method('getContents') ->willReturn('{"avatarNumber": "2'); diff --git a/tests/Client/TrelloClientTest.php b/tests/Client/TrelloClientTest.php index 8b8be8c..65e65c4 100644 --- a/tests/Client/TrelloClientTest.php +++ b/tests/Client/TrelloClientTest.php @@ -4,6 +4,9 @@ namespace Semaio\TrelloApi\Tests\Client; +use JsonException; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; @@ -18,28 +21,31 @@ class TrelloClientTest extends TestCase /** * @var HttpClientInterface|MockObject */ - protected $httpClient; + protected MockObject|HttpClientInterface $httpClient; /** * @var UriGeneratorInterface|MockObject */ - protected $uriGenerator; + protected MockObject|UriGeneratorInterface $uriGenerator; /** * @var ResponseInterface|MockObject */ - protected $response; + protected ResponseInterface|MockObject $response; /** * @var StreamInterface|MockObject */ - protected $stream; + protected MockObject|StreamInterface $stream; /** * @var TrelloClient */ - protected $trelloClient; + protected TrelloClient $trelloClient; + /** + * @throws Exception + */ protected function setUp(): void { $this->httpClient = $this->createMock(HttpClientInterface::class); @@ -53,9 +59,7 @@ protected function setUp(): void ); } - /** - * @test - */ + #[Test] public function it_can_create_trello_client(): void { $client = TrelloClient::create($this->httpClient, $this->uriGenerator); @@ -64,26 +68,27 @@ public function it_can_create_trello_client(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_get_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('GET', $generatedUri) ->willReturn($this->response); @@ -97,26 +102,27 @@ public function it_can_send_get_requests(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_head_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('HEAD', $generatedUri) ->willReturn($this->response); @@ -130,26 +136,27 @@ public function it_can_send_head_requests(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_post_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('POST', $generatedUri) ->willReturn($this->response); @@ -163,26 +170,27 @@ public function it_can_send_post_requests(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_patch_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('PATCH', $generatedUri) ->willReturn($this->response); @@ -196,26 +204,27 @@ public function it_can_send_patch_requests(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_put_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('PUT', $generatedUri) ->willReturn($this->response); @@ -229,26 +238,27 @@ public function it_can_send_put_requests(): void } /** - * @test + * @throws JsonException */ + #[Test] public function it_can_send_delete_requests(): void { $generatedUri = 'path?key=value'; $contents = ['contents']; - $this->uriGenerator->expects(static::once()) + $this->uriGenerator->expects($this->once()) ->method('generate') ->willReturn($generatedUri); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($this->stream); - $this->stream->expects(static::once()) + $this->stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode($contents)); - $this->httpClient->expects(static::once()) + $this->httpClient->expects($this->once()) ->method('sendRequest') ->with('DELETE', $generatedUri) ->willReturn($this->response); diff --git a/tests/ClientBuilderTest.php b/tests/ClientBuilderTest.php index e44d5b1..ce1c8cd 100644 --- a/tests/ClientBuilderTest.php +++ b/tests/ClientBuilderTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface as HttpClientInterface; @@ -21,23 +23,26 @@ class ClientBuilderTest extends TestCase /** * @var HttpClientInterface|MockObject */ - protected $httpClient; + protected HttpClientInterface|MockObject $httpClient; /** * @var RequestFactoryInterface|MockObject */ - protected $requestFactory; + protected MockObject|RequestFactoryInterface $requestFactory; /** * @var StreamFactoryInterface|MockObject */ - protected $streamFactory; + protected MockObject|StreamFactoryInterface $streamFactory; /** * @var ClientBuilder */ - protected $clientBuilder; + protected ClientBuilder $clientBuilder; + /** + * @throws Exception + */ protected function setUp(): void { $this->httpClient = $this->createMock(HttpClientInterface::class); @@ -47,60 +52,46 @@ protected function setUp(): void $this->clientBuilder = new ClientBuilder(); } - /** - * @test - */ + #[Test] public function it_can_retrieve_http_client_from_discovery(): void { static::assertNotSame($this->httpClient, $this->clientBuilder->getHttpClient()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_http_client(): void { $this->clientBuilder->setHttpClient($this->httpClient); static::assertSame($this->httpClient, $this->clientBuilder->getHttpClient()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_request_factory_from_discovery(): void { static::assertNotSame($this->requestFactory, $this->clientBuilder->getRequestFactory()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_request_factory(): void { $this->clientBuilder->setRequestFactory($this->requestFactory); static::assertSame($this->requestFactory, $this->clientBuilder->getRequestFactory()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_stream_factory_from_discovery(): void { static::assertNotSame($this->streamFactory, $this->clientBuilder->getStreamFactory()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_stream_factory(): void { $this->clientBuilder->setStreamFactory($this->streamFactory); static::assertSame($this->streamFactory, $this->clientBuilder->getStreamFactory()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_client(): void { $client = $this->clientBuilder->build('KEY', 'TOKEN'); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index a8d7266..5738ed2 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Api\ActionApi; @@ -21,9 +22,7 @@ class ClientTest extends TestCase { - /** - * @test - */ + #[Test] public function it_can_create_client(): void { $client = Client::create($this->getTrelloClientMock()); @@ -31,81 +30,61 @@ public function it_can_create_client(): void static::assertInstanceOf(Client::class, $client); } - /** - * @test - */ + #[Test] public function it_can_retrieve_action_api(): void { static::assertInstanceOf(ActionApi::class, $this->getClient()->getActionApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_board_api(): void { static::assertInstanceOf(BoardApi::class, $this->getClient()->getBoardApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_card_api(): void { static::assertInstanceOf(CardApi::class, $this->getClient()->getCardApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_checklist_api(): void { static::assertInstanceOf(ChecklistApi::class, $this->getClient()->getChecklistApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_list_api(): void { static::assertInstanceOf(CardListApi::class, $this->getClient()->getCardListApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_member_api(): void { static::assertInstanceOf(MemberApi::class, $this->getClient()->getMemberApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_notification_api(): void { static::assertInstanceOf(NotificationApi::class, $this->getClient()->getNotificationApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_organization_api(): void { static::assertInstanceOf(OrganizationApi::class, $this->getClient()->getOrganizationApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_token_api(): void { static::assertInstanceOf(TokenApi::class, $this->getClient()->getTokenApi()); } - /** - * @test - */ + #[Test] public function it_can_retrieve_webhook_api(): void { static::assertInstanceOf(WebhookApi::class, $this->getClient()->getWebhookApi()); @@ -116,7 +95,7 @@ protected function getClient(): Client return new Client($this->getTrelloClientMock()); } - protected function getTrelloClientMock(): MockObject + protected function getTrelloClientMock(): MockObject|TrelloClientInterface { return $this->getMockBuilder(TrelloClientInterface::class) ->disableOriginalConstructor() diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 464f4e3..a9d15bf 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests\Configuration; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Configuration\Configuration; use Semaio\TrelloApi\Exception\InvalidApiVersionException; @@ -13,9 +14,7 @@ */ class ConfigurationTest extends TestCase { - /** - * @test - */ + #[Test] public function it_can_build_configuration_object(): void { $baseUri = 'https://api.trello.com/1'; @@ -28,9 +27,7 @@ public function it_can_build_configuration_object(): void static::assertEquals($apiToken, $configuration->getApiToken()); } - /** - * @test - */ + #[Test] public function it_can_not_use_invalid_api_version(): void { $this->expectException(InvalidApiVersionException::class); diff --git a/tests/Exception/HttpExceptionTest.php b/tests/Exception/HttpExceptionTest.php index ec1f8cb..88e731a 100644 --- a/tests/Exception/HttpExceptionTest.php +++ b/tests/Exception/HttpExceptionTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests\Exception; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -18,24 +19,27 @@ class HttpExceptionTest extends TestCase /** * @var RequestInterface|MockObject */ - protected $request; + protected MockObject|RequestInterface $request; /** * @var ResponseInterface|MockObject */ - protected $response; + protected ResponseInterface|MockObject $response; /** * @var HttpException */ - protected $httpException; + protected HttpException $httpException; + /** + * @throws Exception + */ protected function setUp(): void { $this->request = $this->createMock(RequestInterface::class); $this->response = $this->createMock(ResponseInterface::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(500); diff --git a/tests/Exception/InvalidJsonResponseExceptionTest.php b/tests/Exception/InvalidJsonResponseExceptionTest.php index 33a08f0..36dc4e1 100644 --- a/tests/Exception/InvalidJsonResponseExceptionTest.php +++ b/tests/Exception/InvalidJsonResponseExceptionTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests\Exception; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Exception\InvalidJsonResponseException; @@ -12,16 +13,14 @@ class InvalidJsonResponseExceptionTest extends TestCase /** * @var InvalidJsonResponseException */ - protected $invalidJsonResponseException; + protected InvalidJsonResponseException $invalidJsonResponseException; protected function setUp(): void { $this->invalidJsonResponseException = new InvalidJsonResponseException('message'); } - /** - * @test - */ + #[Test] public function it_can_retrieve_response_body(): void { static::assertEquals('message', $this->invalidJsonResponseException->getResponseBody()); diff --git a/tests/Exception/MissingArgumentExceptionTest.php b/tests/Exception/MissingArgumentExceptionTest.php index f1367a6..d38847a 100644 --- a/tests/Exception/MissingArgumentExceptionTest.php +++ b/tests/Exception/MissingArgumentExceptionTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests\Exception; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Exception\MissingArgumentException; @@ -12,16 +13,14 @@ class MissingArgumentExceptionTest extends TestCase /** * @var MissingArgumentException */ - protected $missingArgumentException; + protected MissingArgumentException $missingArgumentException; protected function setUp(): void { $this->missingArgumentException = new MissingArgumentException('message'); } - /** - * @test - */ + #[Test] public function it_can_retrieve_response_body(): void { static::assertEquals('One or more of required ("message") parameters are missing!', $this->missingArgumentException->getMessage()); diff --git a/tests/Exception/UnprocessableEntityHttpExceptionTest.php b/tests/Exception/UnprocessableEntityHttpExceptionTest.php index a0ba601..63d4ca8 100644 --- a/tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -4,6 +4,8 @@ namespace Semaio\TrelloApi\Tests\Exception; +use JsonException; +use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -19,24 +21,27 @@ class UnprocessableEntityHttpExceptionTest extends TestCase /** * @var RequestInterface|MockObject */ - protected $request; + protected MockObject|RequestInterface $request; /** * @var ResponseInterface|MockObject */ - protected $response; + protected ResponseInterface|MockObject $response; /** * @var UnprocessableEntityHttpException */ - protected $unprocessableEntityHttpException; + protected UnprocessableEntityHttpException $unprocessableEntityHttpException; + /** + * @throws Exception + */ protected function setUp(): void { $this->request = $this->createMock(RequestInterface::class); $this->response = $this->createMock(ResponseInterface::class); - $this->response->expects(static::any()) + $this->response ->method('getStatusCode') ->willReturn(500); @@ -47,20 +52,24 @@ protected function setUp(): void ); } + /** + * @throws Exception + * @throws JsonException + */ public function testGetResponseErrors(): void { /** @var MockObject|StreamInterface $stream */ $stream = $this->createMock(StreamInterface::class); - $this->response->expects(static::once()) + $this->response->expects($this->once()) ->method('getBody') ->willReturn($stream); - $stream->expects(static::any()) + $stream ->method('rewind') ->willReturnSelf(); - $stream->expects(static::once()) + $stream->expects($this->once()) ->method('getContents') ->willReturn(json_encode(['contents'])); diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index e83081e..f47e56d 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -4,10 +4,12 @@ namespace Semaio\TrelloApi\Tests; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Client; use Semaio\TrelloApi\Client\TrelloClientInterface; +use Semaio\TrelloApi\ClientInterface; use Semaio\TrelloApi\Manager; use Semaio\TrelloApi\Model\ActionModelInterface; use Semaio\TrelloApi\Model\BoardModelInterface; @@ -21,9 +23,7 @@ class ManagerTest extends TestCase { - /** - * @test - */ + #[Test] public function it_can_retrieve_action_model(): void { static::assertInstanceOf( @@ -32,9 +32,7 @@ public function it_can_retrieve_action_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_board_model(): void { static::assertInstanceOf( @@ -43,9 +41,7 @@ public function it_can_retrieve_board_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_board_model_with_id(): void { static::assertInstanceOf( @@ -54,9 +50,7 @@ public function it_can_retrieve_board_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_card_model(): void { static::assertInstanceOf( @@ -65,9 +59,7 @@ public function it_can_retrieve_card_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_card_model_with_id(): void { static::assertInstanceOf( @@ -76,9 +68,7 @@ public function it_can_retrieve_card_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_cardlist_model(): void { static::assertInstanceOf( @@ -87,9 +77,7 @@ public function it_can_retrieve_cardlist_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_cardlist_model_with_id(): void { static::assertInstanceOf( @@ -98,9 +86,7 @@ public function it_can_retrieve_cardlist_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_checklist_model(): void { static::assertInstanceOf( @@ -109,9 +95,7 @@ public function it_can_retrieve_checklist_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_checklist_model_with_id(): void { static::assertInstanceOf( @@ -120,9 +104,7 @@ public function it_can_retrieve_checklist_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_member_model(): void { static::assertInstanceOf( @@ -131,9 +113,7 @@ public function it_can_retrieve_member_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_member_model_with_id(): void { static::assertInstanceOf( @@ -142,9 +122,7 @@ public function it_can_retrieve_member_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_organization_model(): void { static::assertInstanceOf( @@ -153,9 +131,7 @@ public function it_can_retrieve_organization_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_organization_model_with_id(): void { static::assertInstanceOf( @@ -164,9 +140,7 @@ public function it_can_retrieve_organization_model_with_id(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_token_model(): void { static::assertInstanceOf( @@ -175,9 +149,7 @@ public function it_can_retrieve_token_model(): void ); } - /** - * @test - */ + #[Test] public function it_can_retrieve_webhook_model(): void { static::assertInstanceOf( @@ -186,26 +158,26 @@ public function it_can_retrieve_webhook_model(): void ); } - private function getManager(bool $expectsGetMethodCalled) + private function getManager(bool $expectsGetMethodCalled): Manager { return new Manager($this->getClient($expectsGetMethodCalled)); } - private function getClient(bool $expectsGetMethodCalled) + private function getClient(bool $expectsGetMethodCalled): ClientInterface { return Client::create($this->getTrelloClientMock($expectsGetMethodCalled)); } - private function getTrelloClientMock(bool $expectsGetMethodCalled): MockObject + private function getTrelloClientMock(bool $expectsGetMethodCalled): MockObject|TrelloClientInterface { $mock = $this->getMockBuilder(TrelloClientInterface::class) ->disableOriginalConstructor() ->getMock(); if ($expectsGetMethodCalled) { - $mock->expects(static::once())->method('get'); + $mock->expects($this->once())->method('get'); } else { - $mock->expects(static::never())->method('get'); + $mock->expects($this->never())->method('get'); } return $mock; diff --git a/tests/Routing/UriGeneratorTest.php b/tests/Routing/UriGeneratorTest.php index 1e1546d..22acafe 100644 --- a/tests/Routing/UriGeneratorTest.php +++ b/tests/Routing/UriGeneratorTest.php @@ -4,6 +4,7 @@ namespace Semaio\TrelloApi\Tests\Routing; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Semaio\TrelloApi\Configuration\Configuration; use Semaio\TrelloApi\Routing\UriGenerator; @@ -13,9 +14,7 @@ */ class UriGeneratorTest extends TestCase { - /** - * @test - */ + #[Test] public function itCanGenerateUrl(): void { $uriGenerator = new UriGenerator(Configuration::create('KEY', 'TOKEN'));