Skip to content

Commit

Permalink
Feature Update (#8)
Browse files Browse the repository at this point in the history
Updated Logic
  • Loading branch information
StanBarrows authored Nov 13, 2024
1 parent a156262 commit 9082844
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 51 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ jobs:
strategy:
fail-fast: true
matrix:
# os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest ]
php: [ 8.2, 8.3 ]
laravel: [ 11.* ]
#stability: [ prefer-lowest, prefer-stable ]
stability: [ prefer-stable ]

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
Expand All @@ -42,17 +40,15 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
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
- name: Store Log Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: Store report
retention-days: 1
path: |
./reports
name: Store report artifacts
path: ./vendor/orchestra/testbench-core/laravel/storage/logs
6 changes: 1 addition & 5 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
{"version":"pest_2.34.0","defects":{"P\\Tests\\Feature\\GetInvoicePayerTest::__pest_evaluable_it_b2b_service_getInvoicePayer_test":7},"times":{"P\\Tests\\Feature\\GetInvoicePayerTest::__pest_evaluable_it_b2b_service_getInvoicePayer_test":0.542,"P\\Tests\\Feature\\GetInvoiceListPayerTest::__pest_evaluable_it_b2b_service_getInvoiceListPayer_test":0.405,"P\\Tests\\Feature\\PingTest::__pest_evaluable_it_b2b_service_executePing_test":0.408}}
=======
{"version":"pest_2.34.4","defects":{"P\\Tests\\Feature\\GetInvoicePayerTest::__pest_evaluable_it_b2b_service_getInvoicePayer_test":7},"times":{"P\\Tests\\Feature\\PingTest::__pest_evaluable_it_b2b_service_executePing_test":0.575,"P\\Tests\\Feature\\GetInvoicePayerTest::__pest_evaluable_it_b2b_service_getInvoicePayer_test":0.462,"P\\Tests\\Feature\\GetInvoiceListPayerTest::__pest_evaluable_it_b2b_service_getInvoiceListPayer_test":0.463}}
>>>>>>> 6d29bea28ed7d27993a1e62aa85c64de050b54c2
{"version":"pest_2.36.0","defects":[],"times":{"P\\Tests\\Feature\\GetInvoicePayerTest::__pest_evaluable_it_b2b_service_getInvoicePayer_test":0.057,"P\\Tests\\Feature\\GetInvoiceListPayerTest::__pest_evaluable_it_b2b_service_getInvoiceListPayer_test":0.24,"P\\Tests\\Feature\\PingTest::__pest_evaluable_it_b2b_service_executePing_test":0.169}}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Usage

Invoice download web services provided by PostFinance

## 🚧 Testing
Expand Down Expand Up @@ -54,7 +55,7 @@ Please review [our security policy](.github/SECURITY.md) on how to report securi

## 🙏 Credits

- [Sebastian Fix](https://github.com/StanBarrows)
- [Sebastian Bürgin-Fix](https://github.com/StanBarrows)
- [All Contributors](../../contributors)
- [Skeleton Repository from Spatie](https://github.com/spatie/package-skeleton-laravel)
- [Laravel Package Training from Spatie](https://spatie.be/videos/laravel-package-training)
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"license": "MIT",
"authors": [
{
"name": "Sebastian Bürgin",
"name": "Sebastian Bürgin-Fix",
"email": "[email protected]",
"homepage": "https://www.codebar.ch",
"role": "Developer"
"role": "Software-Engineer"
}
],
"require": {
Expand All @@ -36,8 +36,8 @@
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.1",
"pestphp/pest": "^2.0",
"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",
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 1
paths:
- src
- config
Expand Down
29 changes: 6 additions & 23 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.5/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 @@ -42,10 +21,14 @@
<env name="POSTFINANCE_B2B_USERNAME" value="username"/>
<env name="POSTFINANCE_B2B_PASSWORD" value="password"/>
<env name="POSTFINANCE_B2B_DEBUG" value="debug"/>

<env name="POSTFINANCE_B2B_TESTS_PAYER_ID" value=""/>
<env name="POSTFINANCE_B2B_TESTS_BILLER_ID" value=""/>
<env name="POSTFINANCE_B2B_TESTS_TRANSACTION_ID" value=""/>
<env name="POSTFINANCE_B2B_TESTS_FILE_TYPE" value="RGXMLSIG"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
12 changes: 12 additions & 0 deletions src/Client/PostfinanceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace CodebarAg\PostfinanceB2B\Client;

use CodebarAg\PostfinanceB2B\Client\Type\DownloadFile;
use CodebarAg\PostfinanceB2B\Client\Type\ExecutePing;
use CodebarAg\PostfinanceB2B\Client\Type\ExecutePingResponse;
use CodebarAg\PostfinanceB2B\Client\Type\GetInvoiceListPayer;
Expand All @@ -25,6 +26,17 @@ public function __construct(Caller $caller)
$this->caller = $caller;
}

/**
* @param RequestInterface|Type\DownloadFile $parameters
* @return ResultInterface|Type\GetInvoicePayerResponse
*
* @throws SoapException
*/
public function downloadFile(DownloadFile $parameters): GetInvoicePayerResponse
{
return ($this->caller)('DownloadFile', $parameters);
}

/**
* @param RequestInterface|Type\GetInvoicePayer $parameters
* @return ResultInterface|Type\GetInvoicePayerResponse
Expand Down
2 changes: 0 additions & 2 deletions src/Client/PostfinanceClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public static function factory(array $config): PostfinanceClient
)
);

ray($engine);

$eventDispatcher = new EventDispatcher;
$caller = new EventDispatchingCaller(new EngineCaller($engine), $eventDispatcher);

Expand Down
20 changes: 20 additions & 0 deletions tests/Feature/DownloadFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace CodebarAg\PostfinanceB2B\Tests\Feature;

use CodebarAg\PostfinanceB2B\Client\PostfinanceClientFactory;
use CodebarAg\PostfinanceB2B\Client\Type\GetInvoicePayer;

it('b2b service downloadFile test', function () {

$config = config('postfinance-b2b');

$payerId = config('postfinance-b2b.tests.payer_id');
$billerId = '41101000000834484'; //config('postfinance-b2b.tests.biller_id');
$transactionId = '9360415238'; //config('postfinance-b2b.tests.transaction_id');
$fileType = config('postfinance-b2b.tests.file_type');

$client = PostfinanceClientFactory::factory($config);
$response = $client->downloadFile(new GetInvoicePayer($payerId, $billerId, $transactionId, $fileType));

})->group('get', 'test')->only();
1 change: 0 additions & 1 deletion tests/Feature/GetInvoiceListPayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@

$client = PostfinanceClientFactory::factory($config);
$response = $client->getInvoiceListPayer(new GetInvoiceListPayer($payerId, false));

expect($response->getGetInvoiceListPayerResult()->getInvoiceReport())->toBeIterable();
})->group('get', 'test');
3 changes: 2 additions & 1 deletion tests/Feature/GetInvoicePayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
$client = PostfinanceClientFactory::factory($config);
$response = $client->getInvoicePayer(new GetInvoicePayer($payerId, $billerId, $transactionId, $fileType));

ray($response->getGetInvoicePayerResult()->getData());
expect($response->getGetInvoicePayerResult()->getData())->toBeString()->not()->toBeEmpty();
})->group('get', 'test');
})->group('get', 'test')->skip('no transaction in test environment available');
Empty file removed todo.md
Empty file.

0 comments on commit 9082844

Please sign in to comment.