Skip to content

Commit ddb5723

Browse files
author
nejc
committed
feat: Add comprehensive test suite with 97 test cases
- Add Pest PHP testing framework with Laravel integration - Create unit tests for all core components (GitService, VersionControl, etc.) - Add feature tests for all command variations and options - Include configuration validation tests - Add exception handling tests - Set up PHPStan, Rector, and Pint for code quality - Add proper test infrastructure with TestCase and mocking - Cover all command scenarios: setup, check, sync, upgrade, pr - Test all presets: Vue, React, Livewire, Custom - Validate all configuration options and edge cases Tests: 97 total (13 passing, 84 with config issues to fix) Coverage: All major components and integration points
1 parent fcb16f0 commit ddb5723

File tree

1,851 files changed

+35328
-23184
lines changed

Some content is hidden

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

1,851 files changed

+35328
-23184
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.yml]
18+
indent_size = 2

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/art export-ignore
2+
/docs export-ignore
3+
/tests export-ignore
4+
/scripts export-ignore
5+
/.github export-ignore
6+
/.php_cs export-ignore
7+
.editorconfig export-ignore
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
phpstan.neon.dist export-ignore
11+
phpunit.xml.dist export-ignore
12+
rector.php export-ignore
13+
CHANGELOG.md export-ignore
14+
CONTRIBUTING.md export-ignore
15+
README.md export-ignore
16+
17+
# Keep line endings consistent across all platforms when using pint
18+
* text=auto eol=lf

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.phpunit.result.cache
2+
/.phpunit.cache
3+
/.php-cs-fixer.cache
4+
/.php-cs-fixer.php
5+
/composer.lock
6+
/phpunit.xml
7+
/vendor/
8+
*.swp
9+
*.swo
10+
.idea

DEVELOPMENT.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# LaravelPlus Updater - Development Guide
2+
3+
## 🚀 Getting Started
4+
5+
This package follows modern PHP 8.4 development practices with strict typing, proper abstractions, and comprehensive testing.
6+
7+
## 📁 Package Structure
8+
9+
```
10+
src/
11+
├── Contracts/ # Interfaces and contracts
12+
├── Console/Commands/ # Artisan commands
13+
├── Exceptions/ # Custom exceptions
14+
├── Services/ # Business logic services
15+
├── Support/ # Utility classes
16+
├── Traits/ # Reusable traits
17+
└── Config/ # Configuration files
18+
```
19+
20+
## 🛠️ Development Commands
21+
22+
### Code Formatting
23+
```bash
24+
# Format all code
25+
composer run format
26+
27+
# Check formatting without fixing
28+
composer run format:test
29+
```
30+
31+
### Testing
32+
```bash
33+
# Run all tests
34+
composer run test
35+
36+
# Run tests with coverage
37+
composer run test:coverage
38+
```
39+
40+
## 🏗️ Architecture
41+
42+
### Design Patterns Used
43+
- **Strategy Pattern** - Git merge/rebase strategies
44+
- **Factory Pattern** - Exception creation
45+
- **Template Method Pattern** - Abstract command structure
46+
- **Dependency Injection** - Service injection
47+
48+
### Key Components
49+
50+
#### Contracts (Interfaces)
51+
- `VersionControlInterface` - Git operations contract
52+
- `UpstreamCommandInterface` - Command contract
53+
54+
#### Services
55+
- `GitService` - High-level Git operations
56+
- `VersionControl` - Low-level Git command wrapper
57+
58+
#### Commands
59+
- `AbstractUpstreamCommand` - Base command with common functionality
60+
- All commands extend the abstract base class
61+
62+
#### Traits
63+
- `HasPrompts` - Laravel Prompts integration with fallback
64+
65+
## 🎯 PHP 8.4 Features Used
66+
67+
- **Strict Types** - `declare(strict_types=1)` everywhere
68+
- **Readonly Properties** - Immutable service classes
69+
- **Constructor Property Promotion** - Clean constructors
70+
- **Proper Return Types** - All methods have explicit return types
71+
- **Generic Type Hints** - `array<string, mixed>` etc.
72+
73+
## 📝 Code Standards
74+
75+
- **PSR-12** - PHP coding standard
76+
- **Laravel Pint** - Code formatting
77+
- **PHPUnit 11** - Testing framework
78+
- **Orchestra Testbench** - Laravel package testing
79+
80+
## 🔧 Adding New Features
81+
82+
1. **Create Interface** - Define contract in `Contracts/`
83+
2. **Implement Service** - Business logic in `Services/`
84+
3. **Add Command** - Extend `AbstractUpstreamCommand`
85+
4. **Write Tests** - Comprehensive test coverage
86+
5. **Format Code** - Run `composer run format`
87+
88+
## 🧪 Testing Strategy
89+
90+
- **Unit Tests** - Individual class testing
91+
- **Feature Tests** - Command integration testing
92+
- **Mocking** - Service dependencies
93+
- **Coverage** - Aim for 100% code coverage
94+
95+
## 📦 Package Development
96+
97+
### Local Development
98+
```bash
99+
# Install dependencies
100+
composer install
101+
102+
# Run formatting
103+
composer run format
104+
105+
# Run tests
106+
composer run test
107+
```
108+
109+
### Publishing
110+
```bash
111+
# Tag version
112+
git tag v1.0.0
113+
114+
# Push to GitHub
115+
git push origin v1.0.0
116+
```
117+
118+
## 🎨 Code Quality
119+
120+
- **DRY Principle** - No code duplication
121+
- **SOLID Principles** - Clean architecture
122+
- **Type Safety** - Full type hints
123+
- **Error Handling** - Custom exceptions
124+
- **Documentation** - PHPDoc blocks
125+
126+
## 🔍 Debugging
127+
128+
- Use `--test` flag for configuration validation
129+
- Check logs in `storage/logs/`
130+
- Use `--dry-run` for safe testing
131+
- Enable verbose output with `-v`
132+
133+
## 📚 Resources
134+
135+
- [Laravel Package Development](https://laravel.com/docs/packages)
136+
- [PHP 8.4 Features](https://php.net/releases/8.4/en.php)
137+
- [Laravel Pint](https://laravel.com/docs/pint)
138+
- [PHPUnit 11](https://phpunit.de/)

Pest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use LaravelPlus\LaravelUpdater\Tests\TestCase;
6+
7+
uses(TestCase::class)->in('Feature');
8+
uses()->in('Unit');
9+
10+
expect()->extend('toBeOne', function () {
11+
return $this->toBe(1);
12+
});

0 commit comments

Comments
 (0)