Skip to content

Commit cea3272

Browse files
committed
v1.2
1 parent 1d3b30d commit cea3272

8 files changed

Lines changed: 385 additions & 327 deletions

File tree

.github/workflows/php-tests.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Run PHP Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
php-version: ['8.0', '8.1', '8.2', '8.3']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up PHP ${{ matrix.php-version }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
25+
coverage: xdebug
26+
27+
- name: Cache Composer packages
28+
id: composer-cache
29+
uses: actions/cache@v3
30+
with:
31+
path: vendor
32+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-php-${{ matrix.php-version }}-
35+
36+
- name: Install dependencies
37+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
38+
39+
- name: Create build directory
40+
run: mkdir -p build
41+
42+
- name: Run PHPUnit with coverage
43+
run: vendor/bin/phpunit --coverage-clover=build/coverage.xml --coverage-text --testdox
44+
45+
- name: Upload coverage reports to Codecov
46+
if: matrix.php-version == '8.2'
47+
uses: codecov/codecov-action@v3
48+
with:
49+
file: build/coverage.xml
50+
flags: unittests
51+
name: codecov-umbrella
52+
fail_ci_if_error: false

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
vendor/
22
.idea/
3+
.vscode/
4+
.phpunit.result.cache
5+
build/
6+
coverage/
7+
*.log
8+
.DS_Store

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":[],"times":{"ProgressiveJsonStreamerTest::testDataAndPlaceholders":0.002}}

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Progressive JSON Streamer for PHP
22

3-
[![Sponsor on GitHub](https://img.shields.io/badge/Sponsor-❤_GitHub-ff69b4?style=for-the-badge&logo=github)](https://github.com/sponsors/egyjs)
3+
[![PHP Version](https://img.shields.io/badge/PHP-8.0%2B-blue?style=flat-square&logo=php)](https://www.php.net/)
4+
[![Tests](https://img.shields.io/github/actions/workflow/status/egyjs/PHP-Progressive-json-stream/php-tests.yml?branch=master&style=flat-square&logo=github&label=Tests)](https://github.com/egyjs/PHP-Progressive-json-stream/actions)
5+
[![Code Coverage](https://img.shields.io/codecov/c/github/egyjs/PHP-Progressive-json-stream?style=flat-square&logo=codecov)](https://codecov.io/gh/egyjs/PHP-Progressive-json-stream)
6+
[![Latest Version](https://img.shields.io/packagist/v/egyjs/progressive-json-php?style=flat-square&logo=packagist)](https://packagist.org/packages/egyjs/progressive-json-php)
7+
[![Downloads](https://img.shields.io/packagist/dt/egyjs/progressive-json-php?style=flat-square&logo=packagist)](https://packagist.org/packages/egyjs/progressive-json-php)
8+
[![License](https://img.shields.io/github/license/egyjs/PHP-Progressive-json-stream?style=flat-square)](https://github.com/egyjs/PHP-Progressive-json-stream/blob/master/LICENSE)
9+
[![Sponsor on GitHub](https://img.shields.io/badge/Sponsor-❤_GitHub-ff69b4?style=flat-square&logo=github)](https://github.com/sponsors/egyjs)
410

511
![Progressive JSON Streamer](/demo-of-progressive-json-streaming.gif)
612

@@ -619,7 +625,50 @@ $streamer->addPlaceholder('debug_info', function() {
619625

620626
---
621627

622-
## 🤝 Contributing
628+
## � Testing
629+
630+
This library comes with comprehensive PHPUnit tests to ensure reliability and maintainability.
631+
632+
### Running Tests
633+
634+
```bash
635+
# Run all tests
636+
composer test
637+
638+
# Run tests with coverage report
639+
composer test:coverage
640+
641+
# Run tests with readable output
642+
composer test:watch
643+
644+
# Direct PHPUnit commands
645+
vendor/bin/phpunit
646+
vendor/bin/phpunit --testdox
647+
vendor/bin/phpunit --coverage-text
648+
```
649+
650+
### Test Coverage
651+
652+
The test suite includes:
653+
- ✅ Basic functionality tests
654+
- ✅ Error handling and edge cases
655+
- ✅ Nested structure handling
656+
- ✅ Stream generation and output
657+
- ✅ Symfony integration tests
658+
- ✅ Configuration and validation tests
659+
660+
Coverage reports are generated in `build/coverage-html/` when running with coverage.
661+
662+
### Continuous Integration
663+
664+
GitHub Actions automatically runs tests on:
665+
- PHP 8.0, 8.1, 8.2, 8.3
666+
- Push and Pull Request events
667+
- Multiple operating systems
668+
669+
---
670+
671+
## �🤝 Contributing
623672

624673
1. Fork the repository
625674
2. Create a feature branch (`git checkout -b feature/amazing-feature`)

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@
1919
"name": "egyjs",
2020
"email": "el3zahaby@gmail.com"
2121
}
22-
]
22+
],
23+
"require-dev": {
24+
"phpunit/phpunit": "^12.2"
25+
},
26+
"scripts": {
27+
"test": "phpunit",
28+
"test:coverage": "phpunit --coverage-text --coverage-html=build/coverage-html",
29+
"test:watch": "phpunit --testdox"
30+
}
2331
}

0 commit comments

Comments
 (0)