Skip to content

Commit e07140d

Browse files
authored
Merge pull request #10 from codebar-ag/feature-updates
Feature Updates
2 parents 6f59224 + 54c905d commit e07140d

23 files changed

+84
-385
lines changed

.github/workflows/phpstan.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: PHPStan
22

33
on:
4+
pull_request:
5+
- '**.php'
6+
- 'phpstan.neon.dist'
47
push:
58
paths:
69
- '**.php'
@@ -23,4 +26,4 @@ jobs:
2326
uses: ramsey/composer-install@v2
2427

2528
- name: Run PHPStan
26-
run: ./vendor/bin/phpstan --error-format=github
29+
run: ./vendor/bin/phpstan analyse src --error-format=github

.github/workflows/run-tests.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ jobs:
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
# os: [ ubuntu-latest, windows-latest ]
16-
os: [ ubuntu-latest ]
15+
os: [ ubuntu-latest, windows-latest ]
1716
php: [ 8.2 ]
1817
laravel: [ 10.* ]
19-
#stability: [ prefer-lowest, prefer-stable ]
20-
stability: [ prefer-stable ]
18+
stability: [ prefer-lowest, prefer-stable ]
2119
include:
2220
- laravel: 10.*
2321
testbench: 8.*
@@ -45,12 +43,11 @@ jobs:
4543
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
4644
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
4745
46+
- name: Set phpunit.xml
47+
run: cp phpunit.xml.dist phpunit.xml
48+
4849
- name: Execute tests
4950
run: vendor/bin/pest
50-
env:
51-
ZAMMAD_URL: ${{ secrets.ZAMMAD_URL }}
52-
ZAMMAD_TOKEN: ${{ secrets.ZAMMAD_TOKEN }}
53-
ZAMMAD_OBJECT_REFERENCE_ERROR_IGNORE: true
5451

5552
- name: Store test reports
5653
uses: actions/upload-artifact@v2

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@
2121
"php": "^8.2",
2222
"guzzlehttp/guzzle": "^7.2",
2323
"illuminate/contracts": "^10.0",
24-
"saloonphp/cache-plugin": "^2.1",
25-
"sammyjo20/saloon": "^2.0",
26-
"sammyjo20/saloon-laravel": "^2.0",
24+
"laravel/framework": "10.*",
25+
"orchestra/testbench": "8.*",
26+
"saloonphp/cache-plugin": "^2.3",
27+
"saloonphp/laravel-plugin": "^2.1",
28+
"saloonphp/saloon": "^2.11",
2729
"spatie/laravel-data": "^3.6",
2830
"spatie/laravel-package-tools": "^1.9.2"
2931
},
3032
"require-dev": {
3133
"laravel/pint": "^1.5",
3234
"nunomaduro/collision": "^7.0",
3335
"nunomaduro/larastan": "^2.4.0",
34-
"orchestra/testbench": "^8.0",
3536
"pestphp/pest": "^2.0",
3637
"pestphp/pest-plugin-laravel": "^2.0",
3738
"phpstan/extension-installer": "^1.1",

phpunit.xml.dist

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
bootstrap="vendor/autoload.php"
8-
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
executionOrder="random"
15-
failOnWarning="true"
16-
failOnRisky="true"
17-
failOnEmptyTestSuite="true"
18-
beStrictAboutOutputDuringTests="true"
19-
verbose="true"
20-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
213
<testsuites>
224
<testsuite name="CodebarAg Test Suite">
235
<directory>tests</directory>
246
</testsuite>
257
</testsuites>
268
<coverage>
27-
<include>
28-
<directory suffix=".php">./src</directory>
29-
</include>
309
<report>
3110
<html outputDirectory="build/coverage"/>
3211
<text outputFile="build/coverage.txt"/>
@@ -37,8 +16,13 @@
3716
<junit outputFile="build/report.junit.xml"/>
3817
</logging>
3918
<php>
40-
<env name="ZENDESK_ENDPOINT" value="endpoint"/>
41-
<env name="ZENDESK_EMAIL_ADDRESS" value="email_Address"/>
42-
<env name="ZENDESK_API_TOKEN" value="token"/>
19+
<env name="ZENDESK_SUBDOMAIN" value=""/>
20+
<env name="ZENDESK_EMAIL_ADDRESS" value=""/>
21+
<env name="ZENDESK_API_TOKEN" value=""/>
4322
</php>
23+
<source>
24+
<include>
25+
<directory suffix=".php">./src</directory>
26+
</include>
27+
</source>
4428
</phpunit>

src/Dto/Tickets/AllTicketsDTO.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public function __construct(
1919

2020
public static function fromResponse(Response $response): self
2121
{
22+
if ($response->failed()) {
23+
throw new \Exception('Failed to get all tickets', $response->status());
24+
}
25+
2226
$data = $response->json();
2327

2428
if (! $data) {

src/Dto/Tickets/CountTicketsDTO.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace CodebarAg\Zendesk\Dto\Tickets;
44

5-
use Exception;
65
use Illuminate\Support\Arr;
76
use Illuminate\Support\Carbon;
87
use Saloon\Http\Response;
@@ -18,15 +17,15 @@ public function __construct(
1817

1918
public static function fromResponse(Response $response): self
2019
{
21-
$data = Arr::get($response->json(), 'count');
22-
23-
if (! $data) {
24-
throw new Exception('Unable to create DTO. Data missing from response.');
20+
if ($response->failed()) {
21+
throw new \Exception('Failed to get tickets count', $response->status());
2522
}
2623

24+
$data = Arr::get($response->json(), 'count');
25+
2726
return new self(
28-
value: $data['value'],
29-
refreshed_at: Carbon::parse($data['refreshed_at']),
27+
value: Arr::get($data, 'value'),
28+
refreshed_at: Carbon::parse(Arr::get($data, 'refreshed_at')),
3029
);
3130
}
3231
}

src/Dto/Tickets/SingleTicketDTO.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use CodebarAg\Zendesk\Dto\Tickets\Comments\CommentDTO;
66
use CodebarAg\Zendesk\Enums\TicketPriority;
77
use CodebarAg\Zendesk\Enums\TicketType;
8-
use Exception;
98
use Illuminate\Support\Arr;
109
use Illuminate\Support\Carbon;
1110
use Saloon\Http\Response;
@@ -70,12 +69,12 @@ public function __construct(
7069

7170
public static function fromResponse(Response $response): self
7271
{
73-
$data = Arr::get($response->json(), 'ticket');
74-
75-
if (! $data) {
76-
throw new Exception('Unable to create DTO. Data missing from response.');
72+
if ($response->failed()) {
73+
throw new \Exception('Failed to get a single ticket', $response->status());
7774
}
7875

76+
$data = Arr::get($response->json(), 'ticket');
77+
7978
return self::fromArray($data);
8079
}
8180

tests/Connectors/ZendeskConnectorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
use CodebarAg\Zendesk\Requests\SingleTicketRequest;
44
use CodebarAg\Zendesk\ZendeskConnector;
5+
use Illuminate\Support\Facades\Config;
56
use Saloon\Http\Faking\MockResponse;
67
use Saloon\Laravel\Http\Faking\MockClient;
78

89
it('will throw an exception if a subdomain is not set', closure: function () {
10+
Config::set('zendesk.subdomain');
911
$connector = new ZendeskConnector;
1012
$connector->resolveBaseUrl();
1113

@@ -165,7 +167,6 @@
165167
expect($token)->toBe('test@example.com:test-password');
166168
});
167169

168-
169170
it('will throw and authentication error when details are incorrect', function () {
170171
config([
171172
'zendesk.subdomain' => 'codebarsolutionsagwrong',

tests/Core/ArchTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
test('it will not use any debug function')
4+
->expect(['dd', 'ray', 'dump'])
5+
->not()
6+
->toBeUsed();

0 commit comments

Comments
 (0)