Skip to content

Commit b6c1e56

Browse files
authored
Merge pull request #342 from bowphp/refactor/code-base
Code Base Refactoring & Test Suite Enhancement
2 parents 7368afd + 03cfb3c commit b6c1e56

134 files changed

Lines changed: 9869 additions & 2124 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ name: bowphp
33
on: [ push, pull_request ]
44

55
env:
6-
FTP_HOST: localhost
7-
FTP_USER: username
8-
FTP_PASSWORD: password
9-
FTP_PORT: 21
10-
FTP_ROOT: /tmp
6+
AWS_KEY: ${{ secrets.AWS_KEY }}
7+
AWS_SECRET: ${{ secrets.AWS_SECRET }}
8+
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
9+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
10+
AWS_REGION: ${{ secrets.AWS_REGION }}
11+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
1112

1213
jobs:
1314
lunix-tests:
1415
runs-on: ${{ matrix.os }}
1516
strategy:
1617
matrix:
17-
php: [8.1, 8.2, 8.3]
18+
php: [8.1, 8.2, 8.3, 8.4]
1819
os: [ubuntu-latest]
1920
stability: [prefer-lowest, prefer-stable]
2021

@@ -39,14 +40,11 @@ jobs:
3940
uses: shivammathur/setup-php@v2
4041
with:
4142
php-version: ${{ matrix.php }}
42-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysql, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis
43+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysql, sqlite, pgsql, pdo_mysql, pdo_pgsql, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis
4344
coverage: none
4445

45-
- run: docker run -p 21:21 -p 20:20 -p 12020:12020 -p 12021:12021 -p 12022:12022 -p 12023:12023 -p 12024:12024 -p 12025:12025 -e USER=$FTP_USER -e PASS=$FTP_PASSWORD -d --name ftp papacdev/vsftpd
46-
- run: docker run -p 1080:1080 -p 1025:1025 -d --name maildev soulteary/maildev
47-
- run: docker run -p 6379:6379 -d --name redis redis
48-
- run: docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -e POSTGRES_PASSWORD=postgres -d postgis/postgis
49-
- run: docker run -d -p 11300:11300 schickling/beanstalkd
46+
- name: Set Docker containers
47+
run: docker compose up -d
5048

5149
- name: Cache Composer packages
5250
id: composer-cache
@@ -67,4 +65,4 @@ jobs:
6765
run: if [ ! -d /tmp/bowphp_testing ]; then mkdir -p /tmp/bowphp_testing; fi;
6866

6967
- name: Run test suite
70-
run: sudo composer run-script test || sudo composer run-script testdox
68+
run: ./vendor/bin/phpunit tests --configuration phpunit.dist.xml

.gitignore

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
tests/data/database.sqlite
2-
tests/data/cache/**
3-
vendor
4-
phpunit.xml
5-
.idea
6-
.DS_Store
7-
.env.json
8-
composer.lock
9-
.phpunit.result.cache
10-
bob
1+
tests/data/database.sqlite
2+
tests/data/cache/**
3+
vendor
4+
phpunit.xml
5+
.idea
6+
.DS_Store
7+
.env.json
8+
composer.lock
9+
.phpunit.result.cache
10+
bob
11+
.phpunit.cache

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,57 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- **SMTP Adapter**: Complete rewrite with RFC-compliant SMTP protocol implementation
13+
- Expanded from 8 to 21 methods for better functionality separation
14+
- Added comprehensive configuration validation (hostname, port, timeout)
15+
- Implemented multi-exception handling (SmtpException | SocketException)
16+
- Enhanced email address parsing supporting "Name <email@example.com>" format
17+
- Added optional authentication support
18+
- Created comprehensive test suite with 21 tests and 35 assertions
19+
- **FTP Service**: Connection retry logic with 3 attempts and configurable delays
20+
- **FTP Service**: Configuration constants and validation for all required fields
21+
- **FTP Service**: Automatic stream cleanup with try-finally blocks
22+
- **FTP Service**: Destructor for proper resource cleanup
23+
- **Database Notifications**: Enhanced test coverage with 4 additional comprehensive tests
24+
- **Queue System**: Graceful logger fallback in BeanstalkdAdapter
25+
26+
### Changed
27+
28+
- **FTP Service**: Complete refactoring with improved error handling and resource management (651 lines)
29+
- Enhanced all file operations methods (store, get, put, append, prepend, copy, move, delete)
30+
- Improved directory operations (files, directories, makeDirectory)
31+
- Better passive/active mode configuration
32+
- More specific and actionable error messages
33+
- Added connection state validation with `ensureConnection()` method
34+
- **Environment Configuration**: Fixed path handling by removing unreliable `realpath()` usage
35+
- **Configuration Loader**: Improved validation and error handling
36+
- **Messaging System**: Fixed PHPUnit mock issues and corrected type signatures
37+
- **Test Suite**: Renamed test methods to snake_case for consistency
38+
- **Database Tests**: Significantly expanded test coverage across connection, migration, pagination, and query builders
39+
40+
### Fixed
41+
42+
- **SMTP Adapter**: Port validation now correctly validates range (1-65535)
43+
- **SMTP Adapter**: Timeout validation now requires positive integers
44+
- **FTP Service**: Fixed directory listing parser to handle filenames with spaces
45+
- **FTP Service**: Improved error messages with connection details
46+
- **Environment Configuration**: Fixed `Env::configure()` error handling
47+
- **Queue Tests**: Fixed mock configuration issues in MessagingTest
48+
- **Notification Tests**: Added missing timestamp columns in test schema
49+
50+
### Improved
51+
52+
- **Test Coverage**: Added 29 new tests with 46 new assertions
53+
- **Error Rate**: Reduced test errors by 39% (28 → 17 errors)
54+
- **Failure Rate**: Reduced test failures by 70% (10 → 3 failures)
55+
- **Code Quality**: Better error messages across all refactored components
56+
- **Resource Management**: Proper cleanup prevents resource leaks
57+
- **Configuration Validation**: Early validation with specific error messages
58+
859
## 5.1.7 - 2024-12-21
960

1061
### What's Changed

docker-compose.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ services:
4141
- "5432:5432"
4242
environment:
4343
POSTGRES_USER: postgres
44-
POSTGRES_PASSWORD: password
44+
POSTGRES_PASSWORD: postgres
4545
POSTGRES_DB: postgres
4646
volumes:
4747
- postgres_data:/var/lib/postgresql/data
@@ -61,23 +61,23 @@ services:
6161
- "20:20"
6262
- "12020-12025:12020-12025"
6363
environment:
64-
USER: bob
65-
PASS: "12345"
64+
USER: username
65+
PASS: password
6666
volumes:
6767
- "ftp_storage:/ftp/$USER"
6868
networks:
6969
- bowphp_network
7070
mail:
71-
container_name: bowphp_mail
72-
image: maildev/maildev
71+
container_name: bowphp_mailhog
72+
image: mailhog/mailhog
7373
restart: unless-stopped
7474
ports:
75-
- "1025:25"
76-
- "1080:80"
75+
- "1025:1025"
76+
- "1080:8025"
7777
networks:
7878
- bowphp_network
7979
healthcheck:
80-
test: ["CMD", "nc", "-z", "localhost", "25"]
80+
test: ["CMD", "nc", "-z", "localhost", "1025"]
8181
interval: 10s
8282
timeout: 5s
8383
retries: 5

php.dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sendmail_path = /tmp/sendmail -t -i
1+

phpunit.dist.xml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
colors="true"
6-
bootstrap="tests/bootstrap.php"
7-
verbose="true"
8-
failOnRisky="true"
9-
failOnWarning="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
13-
stopOnFailure="false"
14-
executionOrder="random"
15-
resolveDependencies="true">
1+
<phpunit colors="true" bootstrap="tests/bootstrap.php">
162
<testsuite name="Bow Framework">
173
<directory suffix=".php">tests/</directory>
18-
<exclude>./tests/SessionTest.php</exclude>
194
</testsuite>
205
<php>
216
<env name="MYSQL_HOSTNAME" value="127.0.0.1"/>
@@ -28,18 +13,6 @@
2813
<env name="FTP_PASSWORD" value="password"/>
2914
<env name="FTP_USERNAME" value="username"/>
3015
<env name="FTP_PORT" value="21"/>
31-
<env name="FTP_ROOT" value="."/>
32-
<ini name="error_reporting" value="-1"/>
33-
<ini name="display_errors" value="On"/>
34-
<ini name="display_startup_errors" value="On"/>
16+
<env name="FTP_ROOT" value="/tmp"/>
3517
</php>
36-
<coverage>
37-
<include>
38-
<directory suffix=".php">src</directory>
39-
</include>
40-
<exclude>
41-
<directory>vendor</directory>
42-
<directory>tests</directory>
43-
</exclude>
44-
</coverage>
4518
</phpunit>

0 commit comments

Comments
 (0)