Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e7034f7
feat(BA-1126): add unit testing infrastructure with HTTP mocking
vildanbina Jan 6, 2026
a355642
feat(BA-1126): update phpcs command to use custom standard
vildanbina Jan 8, 2026
ed38db0
tests(BA-1126): enhance unit tests with HTTP mocking and assertions
vildanbina Jan 12, 2026
c4ee760
tests(BA-1122): update GeneratorTest to use environment variables for…
vildanbina Jan 12, 2026
c2369b2
tests(BA-1122): refactor ValidatorTest to use environment variables a…
vildanbina Jan 12, 2026
ab41268
tests(BA-1123): add unit tests for HttpPost and Json handlers with co…
vildanbina Jan 12, 2026
60f63ed
tests(BA-1124): add unit tests for CustomParameters and Model classes…
vildanbina Jan 13, 2026
650ab68
tests(BA-1124): add comprehensive unit tests for all Model classes wi…
vildanbina Jan 13, 2026
a7d8e00
style: add rule to prevent extra blank lines in specific tokens
vildanbina Jan 13, 2026
3b26fcc
tests(BA-1124): add unit tests for Response and TransactionService cl…
vildanbina Jan 14, 2026
9723025
tests(BA-1121): add generateTransactionKey method and update successR…
vildanbina Jan 14, 2026
a13c905
tests(BA-1124): refactor test method names for consistency and clarity
vildanbina Jan 14, 2026
4e9a6f8
tests(BA-1125): add unit tests for various payment methods with compr…
vildanbina Jan 19, 2026
43b5979
tests(BA-1125): add missing assertions for all mock fields in payment…
vildanbina Jan 19, 2026
3f7a31f
tests(BA-1124): add unit tests for services and transaction request c…
vildanbina Jan 19, 2026
133b26a
tests(BA-1125): add unit and feature tests for payment methods and ba…
vildanbina Jan 19, 2026
95aacb8
tests(BA-1126): add unit tests for exceptions and resource constants
vildanbina Jan 19, 2026
e002edc
tests(BA-1126): add FeatureTestCase base class for auto-mocking
vildanbina Jan 21, 2026
09993a9
tests(BA-1125): add feature tests for ExternalPayment, In3Old, NoServ…
vildanbina Jan 21, 2026
b4b30c0
tests(BA-1125): refactor feature tests to use FeatureTestCase and fix…
vildanbina Jan 21, 2026
f08659d
tests(BA-1126): add unit tests for logging observers, adapters, and t…
vildanbina Jan 21, 2026
6c368a4
style: apply php-cs-fixer with same-line braces and no space after no…
vildanbina Jan 21, 2026
42b972b
refactor(BA-1121): remove legacy tests and clean up unused test helpers
vildanbina Jan 21, 2026
d96b134
chore: add github actions for tests and code style
vildanbina Jan 21, 2026
9e38afb
chore: update codestyle.yml to target develop branch for pull requests
vildanbina Jan 21, 2026
d480976
refactor: remove mixed type hints from offsetGet and jsonSerialize me…
vildanbina Jan 21, 2026
398fe76
style: apply php-cs-fixer formatting
vildanbina Jan 21, 2026
4634fc9
chore: run CI on all pull requests
vildanbina Jan 21, 2026
a3723e9
tests(BA-1124): add unit tests for config, models, and http clients
vildanbina Jan 26, 2026
03f5f70
tests(BA-1125): add unit tests for payment methods
vildanbina Jan 26, 2026
774c273
tests: remove unused imports from unit tests
vildanbina Jan 26, 2026
fda5f7f
Merge branch 'BA-1121-unit-tests' into php-cs-fixer-cleanup
vildanbina Jan 28, 2026
fd87370
Merge pull request #243 from buckaroo-it/php-cs-fixer-cleanup
vildanbina Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
name: CheckStyleAndLint
name: Code Style

on:
pull_request:
paths:
- "src/**.php"
- "example/**.php"

branches:
- master
- develop
jobs:
phpcs:
php-cs-fixer:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
stability: [prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: PHP CS Fixer

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: cs2pr, phplint, phpcs
php-version: '8.2'
extensions: json, pcre, fileinfo
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-cs-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cs-

- name: Run phplint
run: phplint --no-configuration --no-cache --no-interaction ./src/* ./example/*
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run phpcs
run: phpcs -q --report=checkstyle --standard=phpcs.xml --extensions=php ./src/* | cs2pr
- name: Run PHP CS Fixer
run: composer cs
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on:
pull_request:
branches:
- master
- develop
jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

name: PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, pcre, fileinfo
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run tests
run: composer test
21 changes: 14 additions & 7 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/example'
__DIR__ . '/example',
])
->name('*.php')
->notPath('bootstrap/*')
Expand All @@ -17,23 +17,30 @@
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'not_operator_with_successor_space' => false,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
],
],
'braces' => [
'allow_single_line_closure' => false,
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'next',
'position_after_anonymous_constructs' => 'next',
'position_after_control_structures' => 'next',
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
],
'curly_braces_position' => [
'classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
'control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end'
'control_structures_opening_brace' => 'same_line',
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
Expand All @@ -43,4 +50,4 @@
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
->setFinder($finder);
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"symfony/var-dumper": "^5.4.9",
"phpunit/phpunit": "^9.5",
"vlucas/phpdotenv": "^5.4",
"friendsofphp/php-cs-fixer": "^3.13"
"friendsofphp/php-cs-fixer": "^3.13",
"mockery/mockery": "^1.6"
},
"authors": [{
"name": "Buckaroo",
Expand All @@ -36,5 +37,12 @@
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit",
"test:unit": "phpunit --testsuite Unit",
"test:feature": "phpunit --testsuite Feature",
"cs": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
}
}
3 changes: 3 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
<exclude-pattern>src/PaymentMethods/iDealProcessing/iDealProcessing.php</exclude-pattern>
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName">
<exclude-pattern>tests/*</exclude-pattern>
</rule>

</ruleset>
16 changes: 14 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Unit tests">
<directory>tests</directory>
<testsuite name="Unit">
<directory suffix=".php">tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix=".php">tests/Feature</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

<php>
<ini name="display_errors" value="stderr"/>
<ini name="error_log" value="/dev/null"/>
<env name="BPE_WEBSITE_KEY" value="test_website_key_12345"/>
<env name="BPE_SECRET_KEY" value="test_secret_key_67890abcdef"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Handlers/Reply/ReplyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function contains(string $needle, array $data, bool $strict = false): bo
return true;
}

if (! $strict && str_contains($key, $needle))
if (! $strict && strpos($key, $needle) !== false)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CustomParameters extends Model
/**
* @var array
*/
protected array $List;
protected array $List = [];

/**
* @param array|null $data
Expand Down
4 changes: 2 additions & 2 deletions src/Transaction/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public function offsetUnset($offset): void
}

/** Implement ArrayAccess */
public function offsetGet($offset): mixed
public function offsetGet($offset)
{
return isset($this->data[$offset]) ? $this->data[$offset] : null;
}

/** Implement JsonSerializable */
public function jsonSerialize(): mixed
public function jsonSerialize()
{
return $this->data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Transaction/Response/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function offsetUnset($offset): void
}

/** Implement ArrayAccess */
public function offsetGet($offset): mixed
public function offsetGet($offset)
{
return isset($this->data[$offset]) ? $this->data[$offset] : null;
}
Expand Down
Loading
Loading