Skip to content

Commit

Permalink
Merge pull request #10 from codebar-ag/feature-updates
Browse files Browse the repository at this point in the history
Feature Updates
  • Loading branch information
StanBarrows authored Sep 20, 2023
2 parents 6f59224 + 54c905d commit e07140d
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 385 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: PHPStan

on:
pull_request:
- '**.php'
- 'phpstan.neon.dist'
push:
paths:
- '**.php'
Expand All @@ -23,4 +26,4 @@ jobs:
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
run: ./vendor/bin/phpstan analyse src --error-format=github
13 changes: 5 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ jobs:
strategy:
fail-fast: true
matrix:
# os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest ]
php: [ 8.2 ]
laravel: [ 10.* ]
#stability: [ prefer-lowest, prefer-stable ]
stability: [ prefer-stable ]
stability: [ prefer-lowest, prefer-stable ]
include:
- laravel: 10.*
testbench: 8.*
Expand Down Expand Up @@ -45,12 +43,11 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Set phpunit.xml
run: cp phpunit.xml.dist phpunit.xml

- name: Execute tests
run: vendor/bin/pest
env:
ZAMMAD_URL: ${{ secrets.ZAMMAD_URL }}
ZAMMAD_TOKEN: ${{ secrets.ZAMMAD_TOKEN }}
ZAMMAD_OBJECT_REFERENCE_ERROR_IGNORE: true

- name: Store test reports
uses: actions/upload-artifact@v2
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
"php": "^8.2",
"guzzlehttp/guzzle": "^7.2",
"illuminate/contracts": "^10.0",
"saloonphp/cache-plugin": "^2.1",
"sammyjo20/saloon": "^2.0",
"sammyjo20/saloon-laravel": "^2.0",
"laravel/framework": "10.*",
"orchestra/testbench": "8.*",
"saloonphp/cache-plugin": "^2.3",
"saloonphp/laravel-plugin": "^2.1",
"saloonphp/saloon": "^2.11",
"spatie/laravel-data": "^3.6",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"laravel/pint": "^1.5",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.4.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
Expand Down
34 changes: 9 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<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">
<testsuites>
<testsuite name="CodebarAg Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
Expand All @@ -37,8 +16,13 @@
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="ZENDESK_ENDPOINT" value="endpoint"/>
<env name="ZENDESK_EMAIL_ADDRESS" value="email_Address"/>
<env name="ZENDESK_API_TOKEN" value="token"/>
<env name="ZENDESK_SUBDOMAIN" value=""/>
<env name="ZENDESK_EMAIL_ADDRESS" value=""/>
<env name="ZENDESK_API_TOKEN" value=""/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
4 changes: 4 additions & 0 deletions src/Dto/Tickets/AllTicketsDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public function __construct(

public static function fromResponse(Response $response): self
{
if ($response->failed()) {
throw new \Exception('Failed to get all tickets', $response->status());
}

$data = $response->json();

if (! $data) {
Expand Down
13 changes: 6 additions & 7 deletions src/Dto/Tickets/CountTicketsDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace CodebarAg\Zendesk\Dto\Tickets;

use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Saloon\Http\Response;
Expand All @@ -18,15 +17,15 @@ public function __construct(

public static function fromResponse(Response $response): self
{
$data = Arr::get($response->json(), 'count');

if (! $data) {
throw new Exception('Unable to create DTO. Data missing from response.');
if ($response->failed()) {
throw new \Exception('Failed to get tickets count', $response->status());
}

$data = Arr::get($response->json(), 'count');

return new self(
value: $data['value'],
refreshed_at: Carbon::parse($data['refreshed_at']),
value: Arr::get($data, 'value'),
refreshed_at: Carbon::parse(Arr::get($data, 'refreshed_at')),
);
}
}
9 changes: 4 additions & 5 deletions src/Dto/Tickets/SingleTicketDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use CodebarAg\Zendesk\Dto\Tickets\Comments\CommentDTO;
use CodebarAg\Zendesk\Enums\TicketPriority;
use CodebarAg\Zendesk\Enums\TicketType;
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Saloon\Http\Response;
Expand Down Expand Up @@ -70,12 +69,12 @@ public function __construct(

public static function fromResponse(Response $response): self
{
$data = Arr::get($response->json(), 'ticket');

if (! $data) {
throw new Exception('Unable to create DTO. Data missing from response.');
if ($response->failed()) {
throw new \Exception('Failed to get a single ticket', $response->status());
}

$data = Arr::get($response->json(), 'ticket');

return self::fromArray($data);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Connectors/ZendeskConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

use CodebarAg\Zendesk\Requests\SingleTicketRequest;
use CodebarAg\Zendesk\ZendeskConnector;
use Illuminate\Support\Facades\Config;
use Saloon\Http\Faking\MockResponse;
use Saloon\Laravel\Http\Faking\MockClient;

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

Expand Down Expand Up @@ -165,7 +167,6 @@
expect($token)->toBe('[email protected]:test-password');
});


it('will throw and authentication error when details are incorrect', function () {
config([
'zendesk.subdomain' => 'codebarsolutionsagwrong',
Expand Down
6 changes: 6 additions & 0 deletions tests/Core/ArchTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

test('it will not use any debug function')
->expect(['dd', 'ray', 'dump'])
->not()
->toBeUsed();
Loading

0 comments on commit e07140d

Please sign in to comment.