diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 14da349..ed29355 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -10,20 +10,20 @@ jobs: runs-on: ubuntu-latest if: ${{ github.actor == 'dependabot[bot]' }} steps: - + - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.3.3 + uses: dependabot/fetch-metadata@v1.6 with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - + github-token: ${{ secrets.MY_GITHUB_TOKEN }} + - name: Auto-merge Dependabot PRs for semver-minor updates if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} run: gh pr merge --auto --merge "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - + - name: Auto-merge Dependabot PRs for semver-patch updates if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} run: gh pr merge --auto --merge "$PR_URL" diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 3517cf1..6f281a8 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 8148c24..51ae727 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -10,17 +10,21 @@ jobs: phpstan: name: phpstan runs-on: ubuntu-latest + + env: + PHP_VERSION: '8.3' + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: ${{ env.PHP_VERSION }} coverage: none - name: Install composer dependencies - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 - name: Run PHPStan - run: ./vendor/bin/phpstan analyse src --error-format=github \ No newline at end of file + run: ./vendor/bin/phpstan analyse src --error-format=github diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..edd3131 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + pull_request: + types: + - closed + branches: + - main +jobs: + release: + name: Release + runs-on: ubuntu-latest + + env: + INITIAL_VERSION: 11.0.0 + RELEASE_BRANCHES: main + DEFAULT_BUMP: patch + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Bump version and push tag + uses: anothrNick/github-tag-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} + WITH_V: true + INITIAL_VERSION: ${{ env.INITIAL_VERSION }} + RELEASE_BRANCHES: ${{ env.RELEASE_BRANCHES }} + DEFAULT_BUMP: ${{ env.DEFAULT_BUMP }} \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ae885d2..599c236 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,17 +15,14 @@ jobs: matrix: os: [ ubuntu-latest, windows-latest ] php: [ 8.2, 8.3 ] - laravel: [ 10.* ] + laravel: [ 11.* ] stability: [ prefer-lowest, prefer-stable ] - include: - - laravel: 10.* - testbench: 8.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -41,7 +38,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Set phpunit.xml @@ -51,7 +48,7 @@ jobs: run: vendor/bin/pest - name: Store test reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Store report retention-days: 1 diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..1374b60 --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":"pest_2.36.0","defects":[],"times":{"P\\Tests\\Requests\\SingleTicketRequestTest::__pest_evaluable_it_can_get_a_single_ticket":0.001,"P\\Tests\\Requests\\CreateSingleTicketRequestTest::__pest_evaluable_it_can_get_create_a_single_ticket":0.046,"P\\Tests\\Core\\ArchTest::__pest_evaluable_it_will_not_use_any_debug_function":0.059,"P\\Tests\\Requests\\CountTicketsRequestTest::__pest_evaluable_it_can_count_all_tickets":0.001,"P\\Tests\\Requests\\AllTicketsRequestTest::__pest_evaluable_it_can_get_all_tickets":0.006,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_compile_the_correct_authentication_string_for_token_method":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_compile_the_correct_authentication_string_for_basic_method":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_not_throw_an_exception_if_a_subdomain_is_set":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_not_throw_an_exception_if_an_auth_method_valid":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_return_the_base_path":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_an_exception_if_an_auth_method_is_not_set":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_and_authentication_error_when_details_are_incorrect":0.001,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_an_exception_if_a_token_is_not_provided_when_using_the_token_method":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_an_exception_if_a_subdomain_is_not_set":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_not_throw_an_exception_if_a_password_is_provided_when_using_the_password_method":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_not_throw_an_exception_if_a_token_is_provided_when_using_the_token_method":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_an_exception_if_an_auth_method_invalid":0,"P\\Tests\\Connectors\\ZendeskConnectorTest::__pest_evaluable_it_will_throw_an_exception_if_a_password_is_not_provided_when_using_the_basic_method":0,"P\\Tests\\Requests\\CreateAttachmentRequestTest::__pest_evaluable_it_can_create_an_attachment":0.001}} \ No newline at end of file diff --git a/composer.json b/composer.json index 93a9af9..2a31874 100644 --- a/composer.json +++ b/composer.json @@ -1,85 +1,85 @@ { - "name": "codebar-ag/laravel-zendesk", - "description": "Zendesk integration with Laravel", - "keywords": [ - "zendesk", - "laravel", - "codebar-ag", - "laravel-zendesk" - ], - "homepage": "https://github.com/codebar-ag/laravel-zendesk", - "license": "MIT", - "authors": [ - { - "name": "Sebastian Fix", - "email": "sebastian.fix@codebar.ch", - "homepage": "https://www.codebar.ch", - "role": "Developer" - }, - { - "name": "Rhys Lees", - "role": "Software-Developer" - } - ], - "require": { - "php": "^8.2", - "guzzlehttp/guzzle": "^7.8", - "illuminate/contracts": "^10.0", - "laravel/framework": "^10.28", - "orchestra/testbench": "^8.13", - "saloonphp/cache-plugin": "^3.0", - "saloonphp/laravel-plugin": "^3.0", - "saloonphp/saloon": "^3.0", - "spatie/laravel-data": "^3.9", - "spatie/laravel-package-tools": "^1.16" + "name": "codebar-ag/laravel-zendesk", + "description": "Zendesk integration with Laravel", + "keywords": [ + "zendesk", + "laravel", + "codebar-ag", + "laravel-zendesk" + ], + "homepage": "https://github.com/codebar-ag/laravel-zendesk", + "license": "MIT", + "authors": [ + { + "name": "Sebastian Bürgi ", + "email": "sebastian.buergin@codebar.ch", + "homepage": "https://www.codebar.ch", + "role": "Developer" }, - "require-dev": { - "laravel/pint": "^1.13", - "nunomaduro/collision": "^7.10", - "nunomaduro/larastan": "^2.6", - "orchestra/testbench": "^8.13", - "pestphp/pest": "^2.23", - "pestphp/pest-plugin-laravel": "^2.2", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "spatie/laravel-ray": "^1.33" - }, - "autoload": { - "psr-4": { - "CodebarAg\\Zendesk\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "CodebarAg\\Zendesk\\Tests\\": "tests" - } - }, - "scripts": { - "analyse": "vendor/bin/phpstan analyse", - "test": "vendor/bin/pest", - "test-coverage": "vendor/bin/pest --coverage", - "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "composer/package-versions-deprecated": false, - "pestphp/pest-plugin": true, - "phpstan/extension-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true - } - }, - "extra": { - "laravel": { - "providers": [ - "CodebarAg\\Zendesk\\ZendeskServiceProvider" - ], - "aliases": { - "Flatfox": "CodebarAg\\Zendesk\\Facades\\Zendesk" - } - } - }, - "minimum-stability": "dev", - "prefer-stable": true + { + "name": "Rhys Lees", + "role": "Software-Developer" + } + ], + "require": { + "php": ">=8.2", + "guzzlehttp/guzzle": "^7.8", + "illuminate/contracts": "^11.0", + "laravel/framework": "^11.0", + "saloonphp/cache-plugin": "^3.0", + "saloonphp/laravel-plugin": "^3.2", + "saloonphp/saloon": "^3.4", + "spatie/laravel-data": "^4.13.1", + "spatie/laravel-package-tools": "^1.16" + }, + "require-dev": { + "laravel/pint": "^1.14", + "nunomaduro/collision": "^8.1", + "larastan/larastan": "^2.8", + "orchestra/testbench": "^9.0", + "pestphp/pest": "^2.34", + "pestphp/pest-plugin-laravel": "^2.3", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "pestphp/pest-plugin-arch": "^2.7", + "spatie/laravel-ray": "^1.35" + }, + "autoload": { + "psr-4": { + "CodebarAg\\Zendesk\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "CodebarAg\\Zendesk\\Tests\\": "tests" + } + }, + "scripts": { + "analyse": "vendor/bin/phpstan analyse", + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest --coverage", + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "composer/package-versions-deprecated": false, + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "extra": { + "laravel": { + "providers": [ + "CodebarAg\\Zendesk\\ZendeskServiceProvider" + ], + "aliases": { + "Flatfox": "CodebarAg\\Zendesk\\Facades\\Zendesk" + } + } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e005ac7..4c4eab1 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,5 +9,4 @@ parameters: tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false diff --git a/src/Dto/Tickets/AllTicketsDTO.php b/src/Dto/Tickets/AllTicketsDTO.php index 0e04158..4186efd 100644 --- a/src/Dto/Tickets/AllTicketsDTO.php +++ b/src/Dto/Tickets/AllTicketsDTO.php @@ -14,8 +14,7 @@ public function __construct( public int $count, public ?string $next_page_url, public ?string $previous_page_url, - ) { - } + ) {} public static function fromResponse(Response $response): self { diff --git a/src/Dto/Tickets/Attachments/AttachmentDTO.php b/src/Dto/Tickets/Attachments/AttachmentDTO.php index a139f48..c0f0f89 100644 --- a/src/Dto/Tickets/Attachments/AttachmentDTO.php +++ b/src/Dto/Tickets/Attachments/AttachmentDTO.php @@ -23,8 +23,7 @@ public function __construct( public ?array $thumbnails, public ?string $url, public ?string $width, - ) { - } + ) {} public static function fromArray(array $data): self { diff --git a/src/Dto/Tickets/Attachments/ThumbnailDTO.php b/src/Dto/Tickets/Attachments/ThumbnailDTO.php index 74db1d3..c454e75 100644 --- a/src/Dto/Tickets/Attachments/ThumbnailDTO.php +++ b/src/Dto/Tickets/Attachments/ThumbnailDTO.php @@ -22,8 +22,7 @@ public function __construct( public ?int $size, public ?string $url, public ?string $width, - ) { - } + ) {} public static function fromArray(array $data): self { diff --git a/src/Dto/Tickets/Attachments/UploadDTO.php b/src/Dto/Tickets/Attachments/UploadDTO.php index 3e75673..815bb6e 100644 --- a/src/Dto/Tickets/Attachments/UploadDTO.php +++ b/src/Dto/Tickets/Attachments/UploadDTO.php @@ -14,8 +14,7 @@ public function __construct( public Carbon $expires_at, public array $attachments, public AttachmentDTO $attachment, - ) { - } + ) {} public static function fromResponse(Response $response): self { diff --git a/src/Dto/Tickets/Comments/CommentDTO.php b/src/Dto/Tickets/Comments/CommentDTO.php index 43cdc6a..5bbf54a 100644 --- a/src/Dto/Tickets/Comments/CommentDTO.php +++ b/src/Dto/Tickets/Comments/CommentDTO.php @@ -22,8 +22,7 @@ public function __construct( public ?string $type, public ?array $uploads, public ?array $via, - ) { - } + ) {} public static function fromArray(array $data): self { diff --git a/src/Dto/Tickets/CountTicketsDTO.php b/src/Dto/Tickets/CountTicketsDTO.php index 28260df..8da6431 100644 --- a/src/Dto/Tickets/CountTicketsDTO.php +++ b/src/Dto/Tickets/CountTicketsDTO.php @@ -12,8 +12,7 @@ class CountTicketsDTO extends Data public function __construct( public ?int $value, public ?Carbon $refreshed_at, - ) { - } + ) {} public static function fromResponse(Response $response): self { diff --git a/src/Dto/Tickets/SingleTicketDTO.php b/src/Dto/Tickets/SingleTicketDTO.php index fccd446..5867a5b 100644 --- a/src/Dto/Tickets/SingleTicketDTO.php +++ b/src/Dto/Tickets/SingleTicketDTO.php @@ -64,8 +64,7 @@ public function __construct( public ?int $via_followup_source_id, public ?int $via_id, public ?array $voice_comment, - ) { - } + ) {} public static function fromResponse(Response $response): self { diff --git a/src/Requests/AllTicketsRequest.php b/src/Requests/AllTicketsRequest.php index ecd43d0..365e5ef 100644 --- a/src/Requests/AllTicketsRequest.php +++ b/src/Requests/AllTicketsRequest.php @@ -4,9 +4,9 @@ use CodebarAg\Zendesk\Dto\Tickets\AllTicketsDTO; use Exception; -use Saloon\Http\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class AllTicketsRequest extends Request { diff --git a/src/Requests/CountTicketsRequest.php b/src/Requests/CountTicketsRequest.php index dede12e..edd0633 100644 --- a/src/Requests/CountTicketsRequest.php +++ b/src/Requests/CountTicketsRequest.php @@ -4,9 +4,9 @@ use CodebarAg\Zendesk\Dto\Tickets\CountTicketsDTO; use Exception; -use Saloon\Http\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class CountTicketsRequest extends Request { diff --git a/src/Requests/CreateAttachmentRequest.php b/src/Requests/CreateAttachmentRequest.php index 416c2da..6fbc4c7 100644 --- a/src/Requests/CreateAttachmentRequest.php +++ b/src/Requests/CreateAttachmentRequest.php @@ -5,9 +5,9 @@ use CodebarAg\Zendesk\Dto\Tickets\Attachments\UploadDTO; use Exception; use Saloon\Contracts\Body\HasBody; -use Saloon\Http\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasStreamBody; class CreateAttachmentRequest extends Request implements HasBody @@ -25,8 +25,7 @@ public function __construct( protected string $fileName, protected string $mimeType, protected mixed $stream, - ) { - } + ) {} protected function defaultHeaders(): array { diff --git a/src/Requests/CreateSingleTicketRequest.php b/src/Requests/CreateSingleTicketRequest.php index 08e9beb..2b7c471 100644 --- a/src/Requests/CreateSingleTicketRequest.php +++ b/src/Requests/CreateSingleTicketRequest.php @@ -5,9 +5,9 @@ use CodebarAg\Zendesk\Dto\Tickets\SingleTicketDTO; use Exception; use Saloon\Contracts\Body\HasBody; -use Saloon\Http\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; class CreateSingleTicketRequest extends Request implements HasBody @@ -23,8 +23,7 @@ public function resolveEndpoint(): string public function __construct( readonly protected array|SingleTicketDTO $createTicket - ) { - } + ) {} protected function defaultBody(): array { diff --git a/src/Requests/SingleTicketRequest.php b/src/Requests/SingleTicketRequest.php index 20770d5..442e266 100644 --- a/src/Requests/SingleTicketRequest.php +++ b/src/Requests/SingleTicketRequest.php @@ -4,9 +4,9 @@ use CodebarAg\Zendesk\Dto\Tickets\SingleTicketDTO; use Exception; -use Saloon\Http\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class SingleTicketRequest extends Request { diff --git a/src/Zendesk.php b/src/Zendesk.php index f87aab4..a19d04d 100644 --- a/src/Zendesk.php +++ b/src/Zendesk.php @@ -2,6 +2,4 @@ namespace CodebarAg\Zendesk; -class Zendesk -{ -} +class Zendesk {} diff --git a/tests/Requests/AllTicketsRequestTest.php b/tests/Requests/AllTicketsRequestTest.php index a2767e7..602ca34 100644 --- a/tests/Requests/AllTicketsRequestTest.php +++ b/tests/Requests/AllTicketsRequestTest.php @@ -14,9 +14,7 @@ $connector = new ZendeskConnector; $connector->withMockClient($mockClient); - $response = $connector->send(new AllTicketsRequest()); - - ray($response->dto()); + $response = $connector->send(new AllTicketsRequest); $mockClient->assertSent(AllTicketsRequest::class); @@ -25,7 +23,7 @@ ->and($response->dto()->tickets[0]['subject'])->toBe('My printer is on fire!') ->and($response->dto()->tickets[0]['raw_subject'])->toBe('My printer is on fire!') ->and($response->dto()->tickets[0]['description'])->toBe('The smoke is very colorful.') - ->and($response->dto()->tickets[0]['priority'])->toBe(TicketPriority::URGENT) + ->and($response->dto()->tickets[0]['priority'])->toBe(TicketPriority::URGENT->value) ->and($response->dto()->tickets[0]['custom_fields'][1]['id'])->toBe(10350920893084) ->and($response->dto()->tickets[0]['custom_fields'][1]['value'])->toBe('Check field works') ->and($response->dto()->tickets[0]['custom_fields'][2]['id'])->toBe(10350942541980) diff --git a/tests/Requests/CountTicketsRequestTest.php b/tests/Requests/CountTicketsRequestTest.php index 62a5d77..0cadc54 100644 --- a/tests/Requests/CountTicketsRequestTest.php +++ b/tests/Requests/CountTicketsRequestTest.php @@ -13,7 +13,7 @@ $connector = new ZendeskConnector; $connector->withMockClient($mockClient); - $response = $connector->send(new CountTicketsRequest()); + $response = $connector->send(new CountTicketsRequest); $mockClient->assertSent(CountTicketsRequest::class); diff --git a/tests/TestCase.php b/tests/TestCase.php index 902105b..def33a9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,6 +5,7 @@ use CodebarAg\Zendesk\ZendeskServiceProvider; use Illuminate\Database\Eloquent\Factories\Factory; use Orchestra\Testbench\TestCase as Orchestra; +use Spatie\LaravelData\LaravelDataServiceProvider; use Spatie\LaravelData\Support\DataConfig; class TestCase extends Orchestra @@ -27,6 +28,7 @@ protected function getPackageProviders($app): array { return [ ZendeskServiceProvider::class, + LaravelDataServiceProvider::class, ]; }