diff --git a/.editorconfig b/.editorconfig index 6b45e5d..2f0552d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true -[*.js] +[*.{cjs,js,mjs}] indent_size = 2 [*.scss] @@ -26,7 +26,7 @@ indent_size = 2 indent_size = 2 [*.md] -indent_size = 2 +indent_size = unset trim_trailing_whitespace = false [*.php] diff --git a/.gitignore b/.gitignore index 2400549..d8f1018 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ composer.lock .github/prompts/** .github/skills/** +# internal notes (if present) +internal + # mac ds_store (if present) .DS_Store diff --git a/.prettierignore b/.prettierignore index 7899436..468c2d8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,11 +10,8 @@ vendor/** # Dependency lockfile ignored by git. composer.lock -# Invalid JSON fixture intentionally cannot be parsed by Prettier. -tests/fixtures/providers/malformed-manifest/scaffold.json - # License texts ship verbatim. **/LICENSE* -# Auto-generated by yii2-extensions/scaffold. +# Auto-generated by php-forge/scaffold. scaffold-lock.json diff --git a/.prettierrc.json b/.prettierrc.json index c9f33af..4816f8b 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -6,7 +6,7 @@ "printWidth": 80, "overrides": [ { - "files": ["**/*.{yml,yaml}"], + "files": ["**/*.{cjs,css,js,mjs,yml,yaml}"], "options": { "tabWidth": 2 } @@ -15,8 +15,16 @@ "files": "**/*.md", "options": { "embeddedLanguageFormatting": "off", + "printWidth": 120, + "proseWrap": "always", "tabWidth": 2 } + }, + { + "files": "CHANGELOG.md", + "options": { + "proseWrap": "preserve" + } } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9f889..73ee0f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 0.2.1 Under development +## 0.3.0 Under development + +- feat!: rename package to `php-forge/scaffold` with namespace `PHPForge\Scaffold`; update `require`, `allow-plugins` and class references. ## 0.2.0 July 04, 2026 diff --git a/README.md b/README.md index e7ca3e4..ab7a4e1 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,31 @@

- - - - Yii Framework - + + PHP Forge +

Scaffold


- - Build + + PHPUnit - - Mutation + + Mutation Testing - - PHPStan + + PHPStan - - Security + + Security

- Declarative multi-layer file scaffolding for PHP projects
via Composer providers and a Console CLI
+ Declarative multi-layer file scaffolding for PHP projects
+ Distribute project files through Composer providers and manage them with a standalone Console CLI.

## Features @@ -39,18 +38,19 @@ ## Installation ```bash -composer require yii2-extensions/scaffold:^0.1 -composer config allow-plugins.yii2-extensions/scaffold true +composer config allow-plugins.php-forge/scaffold true +composer require php-forge/scaffold:^0.3 ``` -Declare the providers that are permitted to write files into your project: +Install your scaffold providers, then declare which are permitted to write files into your project: ```json { "extra": { "scaffold": { "allowed-packages": [ - "yii2-extensions/app-base" + "php-forge/baseline", + "php-forge/coding-standard" ] } } @@ -67,7 +67,7 @@ To opt out of auto-trigger and manage updates manually via `vendor/bin/scaffold` "extra": { "scaffold": { "auto": false, - "allowed-packages": ["yii2-extensions/app-base"] + "allowed-packages": ["php-forge/baseline", "php-forge/coding-standard"] } } } @@ -75,23 +75,23 @@ To opt out of auto-trigger and manage updates manually via `vendor/bin/scaffold` ## Configuration -Minimal `composer.json` for a project using one scaffold provider: +Scaffold configuration for a project with `php-forge/baseline` and `php-forge/coding-standard` already installed: ```json { "require": { - "yii2-extensions/scaffold": "^0.1", - "yii2-extensions/app-base": "^0.1" + "php-forge/scaffold": "^0.3" }, "config": { "allow-plugins": { - "yii2-extensions/scaffold": true + "php-forge/scaffold": true } }, "extra": { "scaffold": { "allowed-packages": [ - "yii2-extensions/app-base" + "php-forge/baseline", + "php-forge/coding-standard" ] } } @@ -100,8 +100,8 @@ Minimal `composer.json` for a project using one scaffold provider: ## Console commands -After `composer install`, the plugin ships a standalone Symfony Console CLI at `vendor/bin/scaffold` -that works in any PHP project (Yii2, Yii3, Laravel, Symfony, plain PHP). +After `composer install`, the plugin ships a standalone Symfony Console CLI at `vendor/bin/scaffold` that works in any +PHP project (Yii2, Yii3, Laravel, Symfony, plain PHP). | Command | What it does | | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | @@ -136,21 +136,19 @@ See [`docs/console.md`](docs/console.md) for the full reference. ## Package information [![PHP](https://img.shields.io/badge/%3E%3D8.3-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.3/en.php) -[![Latest Stable Version](https://img.shields.io/packagist/v/yii2-extensions/scaffold.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/yii2-extensions/scaffold) -[![Total Downloads](https://img.shields.io/packagist/dt/yii2-extensions/scaffold.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/yii2-extensions/scaffold) +[![Latest Stable Version](https://img.shields.io/packagist/v/php-forge/scaffold.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/php-forge/scaffold) +[![Total Downloads](https://img.shields.io/packagist/dt/php-forge/scaffold.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/php-forge/scaffold) ## Project status -[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/yii2-extensions/scaffold/actions/workflows/static.yml) -[![Quality](https://img.shields.io/github/actions/workflow/status/yii2-extensions/scaffold/quality.yml?style=for-the-badge&label=Quality&logo=github)](https://github.com/yii2-extensions/scaffold/actions/workflows/quality.yml) +[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/php-forge/scaffold/actions/workflows/static.yml) +[![Quality](https://img.shields.io/github/actions/workflow/status/php-forge/scaffold/quality.yml?style=for-the-badge&label=Quality&logo=github)](https://github.com/php-forge/scaffold/actions/workflows/quality.yml) [![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.styleci.io/repos/1212894073?branch=main) ## Our social networks [![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white&labelColor=000000)](https://x.com/Terabytesoftw) [![Follow on Facebook](https://img.shields.io/badge/-Follow%20on%20Facebook-1877F2.svg?style=for-the-badge&logo=facebook&logoColor=white&labelColor=000000)](https://www.facebook.com/wilmer.arambula.9) -[![Join our Subreddit](https://img.shields.io/badge/-Join%20our%20Subreddit-FF4500.svg?style=for-the-badge&logo=reddit&logoColor=white&labelColor=000000)](https://www.reddit.com/r/Yii2/) -[![Join on Telegram](https://img.shields.io/badge/-Join%20on%20Telegram-26A5E4.svg?style=for-the-badge&logo=telegram&logoColor=white&labelColor=000000)](https://t.me/yii_framework_in_english) ## License diff --git a/bin/scaffold b/bin/scaffold index fcb30e0..0d92aa7 100755 --- a/bin/scaffold +++ b/bin/scaffold @@ -4,14 +4,14 @@ declare(strict_types=1); /** - * Standalone entry point for the `yii2-extensions/scaffold` Symfony Console application. + * Standalone entry point for the `php-forge/scaffold` Symfony Console application. * * Resolves its Composer autoloader whether invoked from the plugin's own `bin/scaffold` (development) or from a - * consumer's `vendor/bin/scaffold` (production). Any PHP project that requires `yii2-extensions/scaffold` can run + * consumer's `vendor/bin/scaffold` (production). Any PHP project that requires `php-forge/scaffold` can run * this binary without needing a framework. */ -use yii\scaffold\Console\Application; +use PHPForge\Scaffold\Console\Application; foreach ( [ diff --git a/composer.json b/composer.json index f5eb49d..26bc14a 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,10 @@ { - "name": "yii2-extensions/scaffold", + "name": "php-forge/scaffold", "type": "composer-plugin", "description": "Declarative multi-layer file scaffolding for PHP projects via Composer providers and a Symfony Console CLI.", "keywords": [ - "yii2-extensions", + "php", + "php-forge", "composer-plugin", "scaffold", "scaffolding", @@ -41,16 +42,16 @@ }, "autoload": { "psr-4": { - "yii\\scaffold\\": "src/" + "PHPForge\\Scaffold\\": "src/" } }, "autoload-dev": { "psr-4": { - "yii\\scaffold\\tests\\": "tests/" + "PHPForge\\Scaffold\\Tests\\": "tests/" } }, "extra": { - "class": "yii\\scaffold\\Plugin", + "class": "PHPForge\\Scaffold\\Plugin", "branch-alias": { "dev-main": "0.3.x-dev" } @@ -66,7 +67,7 @@ "check-dependencies": "./vendor/bin/composer-require-checker check", "ecs": "./vendor/bin/ecs --fix", "mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=85 --min-covered-msi=85", - "mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'", + "mutation-static": "php -d memory_limit=-1 ./vendor/bin/infection --initial-tests-php-options='-d memory_limit=-1' --test-framework-extra-args='-d memory_limit=-1' --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'", "rector": "./vendor/bin/rector process", "static": "./vendor/bin/phpstan --memory-limit=-1", "tests": "./vendor/bin/phpunit" diff --git a/docs/configuration.md b/docs/configuration.md index 8303533..33f7401 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1,7 +1,7 @@ # Configuration reference -All scaffold configuration lives under the `extra.scaffold` key in the root project's `composer.json`. -Provider packages are never trusted unless they appear in `allowed-packages`. +All scaffold configuration lives under the `extra.scaffold` key in the root project's `composer.json`. Provider packages +are never trusted unless they appear in `allowed-packages`. ## allowed-packages @@ -12,17 +12,16 @@ Provider packages are never trusted unless they appear in `allowed-packages`. "extra": { "scaffold": { "allowed-packages": [ - "yii2-extensions/app-base", - "yii2-extensions/app-nginx", - "yii2-extensions/app-vue" + "php-forge/baseline", + "php-forge/coding-standard" ] } } } ``` -**Ordering matters.** When two providers declare the same destination file, the provider listed **later** wins. -This allows specialised layers to override base-layer defaults without forking them. +**Ordering matters.** When two providers declare the same destination file, the provider listed **later** wins. This +allows specialised layers to override base-layer defaults without forking them. If the list is empty or absent the plugin writes a notice and exits without modifying any files. @@ -42,9 +41,8 @@ If the list is empty or absent the plugin writes a notice and exits without modi } ``` -When `auto: false`, the plugin remains installed and authorised but does not hook into Composer events. -The CLI commands at `vendor/bin/scaffold` continue to work, so the consumer can sync provider templates -on demand: +When `auto: false`, the plugin remains installed and authorised but does not hook into Composer events. The CLI commands +at `vendor/bin/scaffold` continue to work, so the consumer can sync provider templates on demand: ```bash vendor/bin/scaffold reapply --provider=php-forge/baseline @@ -52,28 +50,29 @@ vendor/bin/scaffold diff vendor/bin/scaffold status ``` -Use this when **explicit, opt-in updates** matter more than continuous synchronisation, for example on -repositories where every change to project standards should be reviewed before being applied. +Use this when **explicit, opt-in updates** matter more than continuous synchronisation, for example on repositories +where every change to project standards should be reviewed before being applied. -Only an explicit `false` disables the auto-trigger; missing, `null`, non-boolean, or any other value defaults to -enabled to avoid silent disable on typo. +Only an explicit `false` disables the auto-trigger; missing, `null`, non-boolean, or any other value defaults to enabled +to avoid silent disable on typo. ## Full annotated example +Scaffold configuration for a project with `php-forge/baseline` and `php-forge/coding-standard` already installed: + ```json { "require": { - "yii2-extensions/scaffold": "^0.1", - "yii2-extensions/app-base": "^0.1" + "php-forge/scaffold": "^0.3" }, "config": { "allow-plugins": { - "yii2-extensions/scaffold": true + "php-forge/scaffold": true } }, "extra": { "scaffold": { - "allowed-packages": ["yii2-extensions/app-base"] + "allowed-packages": ["php-forge/baseline", "php-forge/coding-standard"] } } } @@ -81,26 +80,26 @@ enabled to avoid silent disable on typo. ## scaffold-lock.json -The plugin writes `scaffold-lock.json` at the project root after every successful run. -It records the SHA-256 hash, provider name, source path, and mode for every file it has written. +The plugin writes `scaffold-lock.json` at the project root after every successful run. It records the SHA-256 hash, +provider name, source path, and mode for every file it has written. -**Commit this file.** It serves the same role as `composer.lock`: it lets collaborators and CI -reproduce the exact scaffold state and detect files that have been modified after scaffolding. +**Commit this file.** It serves the same role as `composer.lock`: it lets collaborators and CI reproduce the exact +scaffold state and detect files that have been modified after scaffolding. Example lock entry: ```json { "providers": { - "yii2-extensions/app-base": { + "php-forge/baseline": { "version": "0.1.0", - "path": "vendor/yii2-extensions/app-base" + "path": "vendor/php-forge/baseline" } }, "files": { "config/params.php": { "hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "provider": "yii2-extensions/app-base", + "provider": "php-forge/baseline", "source": "stubs/config/params.php", "mode": "replace" } diff --git a/docs/console.md b/docs/console.md index 27c0e68..c62c02a 100644 --- a/docs/console.md +++ b/docs/console.md @@ -1,16 +1,16 @@ # Console commands -The scaffold plugin ships a standalone [Symfony Console](https://symfony.com/doc/current/components/console.html) CLI -at `vendor/bin/scaffold`. It works in any PHP project (Yii2, Yii3, Laravel, Symfony, plain PHP) with no framework -bootstrap required; the binary starts directly from Composer's autoloader. +The scaffold plugin ships a standalone [Symfony Console](https://symfony.com/doc/current/components/console.html) CLI at +`vendor/bin/scaffold`. It works in any PHP project (Yii2, Yii3, Laravel, Symfony, plain PHP) with no framework bootstrap +required; the binary starts directly from Composer's autoloader. -Run `vendor/bin/scaffold list` to discover every available command; each entry below also responds to -`--help` for detailed option documentation. +Run `vendor/bin/scaffold list` to discover every available command; each entry below also responds to `--help` for +detailed option documentation. ## vendor/bin/scaffold status -Reads `scaffold-lock.json` and compares the recorded hash of every tracked file to its current on-disk hash. -Outputs a status table. +Reads `scaffold-lock.json` and compares the recorded hash of every tracked file to its current on-disk hash. Outputs a +status table. ```bash vendor/bin/scaffold status @@ -21,10 +21,10 @@ Example output: ```text File Provider Mode Status -------------------------------------------------------------------------------------------- -config/params.php yii2-extensions/app-base replace synced -config/web.php yii2-extensions/app-base preserve synced -.env.example yii2-extensions/app-base append modified -docker/nginx/nginx.conf yii2-extensions/app-nginx replace missing +config/params.php php-forge/baseline replace synced +config/web.php php-forge/baseline preserve synced +.env.example php-forge/baseline append modified +docker/nginx/nginx.conf php-forge/coding-standard replace missing ``` | Status | Meaning | @@ -42,9 +42,9 @@ vendor/bin/scaffold diff config/params.php ``` The output starts with `--- a/` / `+++ b/` headers followed by `@@` hunk headers with three lines of -context. Lines present only in the stub are prefixed with `-`, and lines present only in the current file with `+`. -On ANSI-capable terminals the diff is colorized (bold headers, cyan hunks, green additions, red removals); pass -`--no-ansi` to force plain output. +context. Lines present only in the stub are prefixed with `-`, and lines present only in the current file with `+`. On +ANSI-capable terminals the diff is colorized (bold headers, cyan hunks, green additions, red removals); pass `--no-ansi` +to force plain output. ```diff --- a/config/params.php @@ -63,7 +63,7 @@ Re-copies stubs from `vendor/` to the project, updating `scaffold-lock.json` has vendor/bin/scaffold reapply config/params.php # reapply all files from one provider -vendor/bin/scaffold reapply --provider=yii2-extensions/app-base +vendor/bin/scaffold reapply --provider=php-forge/baseline # reapply all tracked files vendor/bin/scaffold reapply @@ -72,13 +72,13 @@ vendor/bin/scaffold reapply vendor/bin/scaffold reapply config/params.php --force ``` -Without `--force`, files whose on-disk hash differs from the lock hash are reported and skipped. -With `--force`, user-modified files are overwritten and the lock hash is updated. +Without `--force`, files whose on-disk hash differs from the lock hash are reported and skipped. With `--force`, +user-modified files are overwritten and the lock hash is updated. ## vendor/bin/scaffold eject `` `[--yes]` -Removes a file entry from `scaffold-lock.json` without deleting the file from disk. -After ejection the file is no longer managed by scaffold. +Removes a file entry from `scaffold-lock.json` without deleting the file from disk. After ejection the file is no longer +managed by scaffold. ```bash # preview what would happen @@ -103,8 +103,8 @@ Example output: ```text Provider Files ---------------------------------------------------- -yii2-extensions/app-base 4 -yii2-extensions/app-nginx 2 +php-forge/baseline 4 +php-forge/coding-standard 2 ``` ## Typical post-install workflow diff --git a/docs/installation.md b/docs/installation.md index 97d0615..2c818df 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -5,30 +5,25 @@ - [PHP](https://www.php.net/downloads) `8.3` or higher. - [Composer](https://getcomposer.org/download/) `2.9` or higher. -The plugin is framework-agnostic. It works in Yii2, Yii3, Laravel, Symfony, Slim, Mezzio, or plain -PHP projects as long as they use Composer. +The plugin is framework-agnostic. It works in Yii2, Yii3, Laravel, Symfony, Slim, Mezzio, or plain PHP projects as long +as they use Composer. ## Installation -Add the plugin to your project: +Allow the Composer plugin, then install it: ```bash -composer require yii2-extensions/scaffold:^0.1 +composer config allow-plugins.php-forge/scaffold true +composer require php-forge/scaffold:^0.3 ``` -Because `yii2-extensions/scaffold` is a Composer plugin, you must allow it explicitly: - -```bash -composer config allow-plugins.yii2-extensions/scaffold true -``` - -Or add the entry manually to your `composer.json`: +Alternatively, add the permission to your `composer.json` before running `composer require`: ```json { "config": { "allow-plugins": { - "yii2-extensions/scaffold": true + "php-forge/scaffold": true } } } @@ -36,27 +31,27 @@ Or add the entry manually to your `composer.json`: ## Authorize scaffold providers -Declare which packages are permitted to write files into your project under `extra.scaffold.allowed-packages`. -The plugin ignores all providers that are not listed here. +Install the scaffold provider packages required by your project, then declare which are permitted to write files under +`extra.scaffold.allowed-packages`. The plugin ignores all providers that are not listed here. ```json { "extra": { "scaffold": { - "allowed-packages": ["yii2-extensions/app-base"] + "allowed-packages": ["php-forge/baseline", "php-forge/coding-standard"] } } } ``` -Run `composer install` or `composer update` to trigger the scaffold process. -The plugin applies all file mappings declared by the listed providers and writes `scaffold-lock.json`. +Run `composer install` or `composer update` to trigger the scaffold process. The plugin applies all file mappings +declared by the listed providers and writes `scaffold-lock.json`. ## Commit the lockfile -`scaffold-lock.json` records the hash of every file written by the scaffold process. -Commit it to version control alongside `composer.lock` so that collaborators and CI can detect user-modified files and -reproduce the exact scaffold state. +`scaffold-lock.json` records the hash of every file written by the scaffold process. Commit it to version control +alongside `composer.lock` so that collaborators and CI can detect user-modified files and reproduce the exact scaffold +state. ```bash git add scaffold-lock.json diff --git a/docs/modes.md b/docs/modes.md index ac7699d..94d003c 100644 --- a/docs/modes.md +++ b/docs/modes.md @@ -1,8 +1,8 @@ # File modes -Every file mapping in a provider manifest declares a `mode` that controls how the plugin writes -the stub file into the project. The mode also determines how the hash-tracking mechanism reacts -when a file has been modified by the developer after scaffolding. +Provider manifests list source paths in `copy` and select write modes by destination path or glob in `modes`. The +default mode is `replace`. The mode also determines how the hash-tracking mechanism reacts when a file has been modified +by the developer after scaffolding. ## Mode reference @@ -18,39 +18,38 @@ when a file has been modified by the developer after scaffolding. After writing a file the plugin computes `sha256:` and records it in `scaffold-lock.json`. On subsequent runs the plugin compares the current on-disk hash to the recorded hash: -- **Hashes match**; the file has not been changed since the last scaffold run. The plugin re-applies the stub - (for `replace`) or skips (for `preserve`). +- **Hashes match**; the file has not been changed since the last scaffold run. The plugin re-applies the stub (for + `replace`) or skips (for `preserve`). - **Hashes differ**; the developer has modified the file. For `replace`, the plugin skips the file and writes a warning to stderr. For `preserve`, the file is always skipped regardless of hash. `append` does not compare hashes; instead it diffs the stub lines against the destination and inserts only the missing ones at their contextual position. The operation is therefore idempotent: repeated runs over a file that already -contains every stub line are a no-op. -On partial scaffold runs (`post-install-cmd`, `post-update-cmd`), `append` and `prepend` are also skipped at the -scaffolder level for files already recorded in the lockfile as a performance optimisation; the line-diff guarantees -correctness even without that skip. +contains every stub line are a no-op. On partial scaffold runs (`post-install-cmd`, `post-update-cmd`), `append` and +`prepend` are also skipped at the scaffolder level for files already recorded in the lockfile as a performance +optimisation; the line-diff guarantees correctness even without that skip. ## replace -Intended for configuration files that the scaffold system owns. The developer is expected to leave -these files as-is or accept that custom changes may be warned about on re-scaffold. +Intended for configuration files that the scaffold system owns. The developer is expected to leave these files as-is or +accept that custom changes may be warned about on re-scaffold. ```json -"config/params.php": { - "source": "stubs/config/params.php", - "mode": "replace" +{ + "copy": [{"from": "stubs/config/params.php", "to": "config/params.php"}], + "modes": {"config/params.php": "replace"} } ``` ## preserve -Intended for files that provide sensible defaults but are designed to be customised by the developer. -Once written, the file is never touched again by the scaffold process. +Intended for files that provide sensible defaults but are designed to be customised by the developer. Once written, the +file is never touched again by the scaffold process. ```json -"config/db.php": { - "source": "stubs/config/db.php", - "mode": "preserve" +{ + "copy": [{"from": "stubs/config/db.php", "to": "config/db.php"}], + "modes": {"config/db.php": "preserve"} } ``` @@ -58,10 +57,10 @@ Once written, the file is never touched again by the scaffold process. Idempotent contextual line merge. The plugin reads both the stub and the destination, splits each on `\n` (after trimming the trailing newline), and inserts the stub lines missing from the destination at their contextual position, -aligned against shared anchor lines (LCS). Presence is order-independent: a destination that contains every stub line -in a different order is left untouched. Existing lines keep their original terminators (mixed EOLs included); inserted -lines use the destination's dominant EOL. Repeated runs over a destination that already contains every stub line are -a no-op (`ApplyOutcome::Skipped`); developer-added lines are never removed or reordered. +aligned against shared anchor lines (LCS). Presence is order-independent: a destination that contains every stub line in +a different order is left untouched. Existing lines keep their original terminators (mixed EOLs included); inserted +lines use the destination's dominant EOL. Repeated runs over a destination that already contains every stub line are a +no-op (`ApplyOutcome::Skipped`); developer-added lines are never removed or reordered. Use it for line-based, comment-tolerant files where the destination may already contain the stub content (because the project follows the same baseline) or where the developer routinely adds project-specific entries: @@ -71,9 +70,9 @@ project follows the same baseline) or where the developer routinely adds project - Environment variable lists, plain-text allowlists ```json -".gitignore": { - "source": "stubs/gitignore-additions.txt", - "mode": "append" +{ + "copy": [{"from": "stubs/gitignore-additions.txt", "to": ".gitignore"}], + "modes": {".gitignore": "append"} } ``` @@ -82,20 +81,20 @@ project follows the same baseline) or where the developer routinely adds project ## prepend -Prepends the stub content before the existing destination content. -Useful for inserting PHP `declare(strict_types=1)` headers, autoload includes, or licence headers. +Prepends the stub content before the existing destination content. Useful for inserting PHP `declare(strict_types=1)` +headers, autoload includes, or licence headers. ```json -"bootstrap/web.php": { - "source": "stubs/bootstrap-header.php", - "mode": "prepend" +{ + "copy": [{"from": "stubs/bootstrap-header.php", "to": "bootstrap/web.php"}], + "modes": {"bootstrap/web.php": "prepend"} } ``` ## --force reapply workflow -When a `replace` file has been user-modified, the scaffold process warns and skips it. -To intentionally overwrite the file with the current stub, use the console command: +When a `replace` file has been user-modified, the scaffold process warns and skips it. To intentionally overwrite the +file with the current stub, use the console command: ```bash vendor/bin/scaffold reapply config/params.php --force diff --git a/docs/providers.md b/docs/providers.md index 8502d08..0a81dd7 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -23,25 +23,22 @@ Declare under `extra.scaffold` in the provider's `composer.json`: ```json { - "name": "yii2-extensions/app-backend", - "type": "yii2-scaffold", + "name": "php-forge/baseline", + "type": "library", "extra": { "scaffold": { "copy": [ - "src", - "config", - "migrations", - "public", - "resources", - "yii", - ".env.dist", - ".gitignore" + {"from": "metadata/.editorconfig", "to": ".editorconfig"}, + {"from": "metadata/gitattributes", "to": ".gitattributes"}, + {"from": "metadata/.gitignore", "to": ".gitignore"}, + {"from": "metadata/.styleci.yml", "to": ".styleci.yml"}, + {"from": "metadata/composer-require-checker.json", "to": "composer-require-checker.json"}, + {"from": "metadata/.github/linters", "to": ".github/linters"} ], "modes": { - "config/*.php": "preserve", - "public/assets/.gitkeep": "preserve", - ".env.dist": "preserve", - ".gitignore": "append" + ".editorconfig": "append", + ".gitignore": "append", + "composer-require-checker.json": "preserve" } } } @@ -54,8 +51,8 @@ For larger providers, point to a `scaffold.json` file next to `composer.json`: ```json { - "name": "yii2-extensions/app-backend", - "type": "yii2-scaffold", + "name": "php-forge/coding-standard", + "type": "library", "extra": { "scaffold": { "manifest": "scaffold.json" @@ -69,19 +66,12 @@ For larger providers, point to a `scaffold.json` file next to `composer.json`: ```json { "copy": [ - "src", - "config", - "migrations", - "public", - "resources", - "yii", - ".env.dist" + {"from": "src/config/ecs.php", "to": "ecs.php"}, + {"from": "src/config/rector.php", "to": "rector.php"} ], - "exclude": ["config/test-local.php"], "modes": { - "config/*.php": "preserve", - "public/assets/.gitkeep": "preserve", - ".env.dist": "preserve" + "ecs.php": "preserve", + "rector.php": "preserve" } } ``` @@ -134,11 +124,11 @@ can list the exact path as an explicit file entry in `copy`; explicit file entri ## Provider layout -Because `copy` walks the provider tree directly, providers look like real Yii2 apps. There is no `stubs/` wrapper and -no per-file declaration: +Because `copy` walks the provider tree directly, providers look like real Yii2 apps. There is no `stubs/` wrapper and no +per-file declaration: ```text -yii2-extensions/app-backend/ +acme/app-backend/ ├── composer.json # declares extra.scaffold or extra.scaffold.manifest ├── scaffold.json # optional external manifest ├── src/ # copied verbatim into the consumer's src/ @@ -161,8 +151,8 @@ before any consumer depends on it. The plugin validates every entry before writing: -- **Package allowlist**: the provider must appear in `allowed-packages`. Unknown providers cause an error and no file - is written. +- **Package allowlist**: the provider must appear in `allowed-packages`. Unknown providers cause an error and no file is + written. - **Path traversal rejection**: entries in `copy` and `exclude` must be relative and must not contain `..` segments. Absolute paths and Windows drive letters are rejected. - **File existence**: every path listed in `copy` must exist on disk at expansion time; missing entries fail the run diff --git a/docs/svgs/features-mobile.svg b/docs/svgs/features-mobile.svg index 38d61cf..1b3ca7a 100644 --- a/docs/svgs/features-mobile.svg +++ b/docs/svgs/features-mobile.svg @@ -2,35 +2,35 @@ - + Agnostic Framework Console binary at vendor/bin/scaffold • 5 commands • Runs in any PHP project - + Manifest-driven Inline + external JSON manifest • 4 file modes • SHA-256 hash per tracked file - + Multi-layer composition Base + server + frontend layers • Last-provider wins • Declarative ordering - + User-aware Modified files detected and warned • Preserve mode • --force reapply diff --git a/docs/svgs/features.svg b/docs/svgs/features.svg index 7b6f08b..217265d 100644 --- a/docs/svgs/features.svg +++ b/docs/svgs/features.svg @@ -1,35 +1,35 @@ - + Agnostic Framework Console binary at vendor/bin/scaffold • 5 commands • Runs in any PHP project - + Manifest-driven Inline + external JSON manifest • 4 file modes • SHA-256 hash per tracked file - + Multi-layer composition Base + server + frontend layers • Last-provider wins • Declarative ordering - + User-aware Modified files detected and warned • Preserve mode • --force reapply diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e60625d..52fd2fd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,8 @@ - + tests @@ -23,6 +23,6 @@ - + diff --git a/src/Console/Application.php b/src/Console/Application.php index 998da13..3665fd6 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; use Composer\InstalledVersions; use OutOfBoundsException; +use PHPForge\Scaffold\Console\Command\{DiffCommand, EjectCommand, ProvidersCommand, ReapplyCommand, StatusCommand}; use Symfony\Component\Console\Application as SymfonyApplication; -use yii\scaffold\Console\Command\{DiffCommand, EjectCommand, ProvidersCommand, ReapplyCommand, StatusCommand}; /** * Symfony Console application that exposes the scaffold plugin's five commands as a standalone CLI, available via @@ -21,12 +21,12 @@ final class Application extends SymfonyApplication * Fallback version returned by {@see resolveVersion()} when the package is not installed via Composer (for example, * when the source tree is loaded directly without running `composer install` first). */ - public const string FALLBACK_VERSION = '0.1.x-dev'; + public const string FALLBACK_VERSION = '0.3.x-dev'; /** * Application / Composer package name. */ - public const string NAME = 'yii2-extensions/scaffold'; + public const string NAME = 'php-forge/scaffold'; public function __construct() { diff --git a/src/Console/Command/AbstractScaffoldCommand.php b/src/Console/Command/AbstractScaffoldCommand.php index ef7bf15..f3368d7 100644 --- a/src/Console/Command/AbstractScaffoldCommand.php +++ b/src/Console/Command/AbstractScaffoldCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; @@ -13,7 +13,8 @@ * * Centralizes the `getcwd()` fail-fast check so every command reports a single, consistent diagnostic when the CWD * becomes unreadable (for example, after the parent directory is removed) instead of silently propagating an - * empty project root into {@see \yii\scaffold\Scaffold\Lock\LockFile} or {@see \yii\scaffold\Scaffold\PathResolver}. + * empty project root into {@see \PHPForge\Scaffold\Scaffold\Lock\LockFile} or + * {@see \PHPForge\Scaffold\Scaffold\PathResolver}. */ abstract class AbstractScaffoldCommand extends Command { diff --git a/src/Console/Command/DiffCommand.php b/src/Console/Command/DiffCommand.php index ffb4c5c..17d432f 100644 --- a/src/Console/Command/DiffCommand.php +++ b/src/Console/Command/DiffCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; +use PHPForge\Scaffold\Console\{SymfonyOutputWriter, VendorDirResolver}; +use PHPForge\Scaffold\Services\DiffService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\{InputArgument, InputInterface}; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\{SymfonyOutputWriter, VendorDirResolver}; -use yii\scaffold\Services\DiffService; /** * Shows a git-style unified diff between the provider stub and the current on-disk file. diff --git a/src/Console/Command/EjectCommand.php b/src/Console/Command/EjectCommand.php index 8dea3b4..dd0964a 100644 --- a/src/Console/Command/EjectCommand.php +++ b/src/Console/Command/EjectCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; +use PHPForge\Scaffold\Console\SymfonyOutputWriter; +use PHPForge\Scaffold\Services\EjectService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\{InputArgument, InputInterface, InputOption}; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\SymfonyOutputWriter; -use yii\scaffold\Services\EjectService; /** * Removes a file entry from `scaffold-lock.json` without deleting the file from disk. diff --git a/src/Console/Command/ProvidersCommand.php b/src/Console/Command/ProvidersCommand.php index 9b81c4b..527e4e0 100644 --- a/src/Console/Command/ProvidersCommand.php +++ b/src/Console/Command/ProvidersCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; +use PHPForge\Scaffold\Console\SymfonyOutputWriter; +use PHPForge\Scaffold\Services\ProvidersService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\SymfonyOutputWriter; -use yii\scaffold\Services\ProvidersService; /** * Lists all scaffold providers recorded in `scaffold-lock.json` with their file counts. diff --git a/src/Console/Command/ReapplyCommand.php b/src/Console/Command/ReapplyCommand.php index d7330cb..28327b5 100644 --- a/src/Console/Command/ReapplyCommand.php +++ b/src/Console/Command/ReapplyCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; +use PHPForge\Scaffold\Console\{SymfonyOutputWriter, VendorDirResolver}; +use PHPForge\Scaffold\Services\ReapplyService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\{InputArgument, InputInterface, InputOption}; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\{SymfonyOutputWriter, VendorDirResolver}; -use yii\scaffold\Services\ReapplyService; /** * Re-applies scaffold stubs to the project, optionally overwriting user-modified files. @@ -19,7 +19,7 @@ * vendor/bin/scaffold reapply * vendor/bin/scaffold reapply config/params.php * vendor/bin/scaffold reapply config/params.php --force - * vendor/bin/scaffold reapply --provider=yii2-extensions/app-base + * vendor/bin/scaffold reapply --provider=php-forge/baseline * ``` */ #[AsCommand( @@ -47,7 +47,7 @@ protected function configure(): void 'provider', null, InputOption::VALUE_REQUIRED, - "Restrict reapply to a provider package name (for example, 'yii2-extensions/app-base').", + "Restrict reapply to a provider package name (for example, 'php-forge/baseline').", '', ); } diff --git a/src/Console/Command/StatusCommand.php b/src/Console/Command/StatusCommand.php index ad9262d..6131255 100644 --- a/src/Console/Command/StatusCommand.php +++ b/src/Console/Command/StatusCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Console\Command; +namespace PHPForge\Scaffold\Console\Command; +use PHPForge\Scaffold\Console\SymfonyOutputWriter; +use PHPForge\Scaffold\Services\StatusService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\SymfonyOutputWriter; -use yii\scaffold\Services\StatusService; /** * Displays the status of all scaffold-tracked files relative to their recorded hashes. diff --git a/src/Console/DiffColorizer.php b/src/Console/DiffColorizer.php index a9387d8..2bc27af 100644 --- a/src/Console/DiffColorizer.php +++ b/src/Console/DiffColorizer.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; use function explode; use function implode; @@ -18,7 +18,7 @@ * * Usage example: * ```php - * $colorized = (new \yii\scaffold\Console\DiffColorizer())->colorize($unifiedDiff); + * $colorized = (new \PHPForge\Scaffold\Console\DiffColorizer())->colorize($unifiedDiff); * ``` */ final class DiffColorizer @@ -30,7 +30,7 @@ final class DiffColorizer private const string RESET = "\e[0m"; /** - * Colorizes a unified diff produced by {@see \yii\scaffold\Services\DiffService::buildDiff()}. + * Colorizes a unified diff produced by {@see \PHPForge\Scaffold\Services\DiffService::buildDiff()}. * * @param string $diff Unified diff whose first two lines are the `---`/`+++` file headers. * diff --git a/src/Console/ExitCode.php b/src/Console/ExitCode.php index 27cba94..34d49dc 100644 --- a/src/Console/ExitCode.php +++ b/src/Console/ExitCode.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; /** * Standardized exit codes returned by scaffold services. diff --git a/src/Console/OutputWriter.php b/src/Console/OutputWriter.php index cf635a6..8c0ff88 100644 --- a/src/Console/OutputWriter.php +++ b/src/Console/OutputWriter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; /** * Abstracts `stdout` / `stderr` writes so scaffold service implementations can run unchanged under console controllers, diff --git a/src/Console/SymfonyOutputWriter.php b/src/Console/SymfonyOutputWriter.php index 408f6b2..78f4d44 100644 --- a/src/Console/SymfonyOutputWriter.php +++ b/src/Console/SymfonyOutputWriter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; use Symfony\Component\Console\Output\{ConsoleOutputInterface, OutputInterface}; diff --git a/src/Console/VendorDirResolver.php b/src/Console/VendorDirResolver.php index 31763f8..3808e4e 100644 --- a/src/Console/VendorDirResolver.php +++ b/src/Console/VendorDirResolver.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Console; +namespace PHPForge\Scaffold\Console; use function file_get_contents; use function getenv; diff --git a/src/EventSubscriber.php b/src/EventSubscriber.php index 92f7bcb..a391fe7 100644 --- a/src/EventSubscriber.php +++ b/src/EventSubscriber.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold; +namespace PHPForge\Scaffold; use Composer\EventDispatcher\EventSubscriberInterface; use Composer\IO\IOInterface; use Composer\Script\{Event, ScriptEvents}; +use PHPForge\Scaffold\Manifest\{ManifestExpander, ManifestLoader, ManifestSchema}; +use PHPForge\Scaffold\Scaffold\{Applier, Scaffolder}; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Security\{PackageAllowlist, PathValidator}; use Throwable; -use yii\scaffold\Manifest\{ManifestExpander, ManifestLoader, ManifestSchema}; -use yii\scaffold\Scaffold\{Applier, Scaffolder}; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Security\{PackageAllowlist, PathValidator}; use function is_array; use function is_string; diff --git a/src/Manifest/DefaultExcludes.php b/src/Manifest/DefaultExcludes.php index af35601..fb568dd 100644 --- a/src/Manifest/DefaultExcludes.php +++ b/src/Manifest/DefaultExcludes.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; use function str_ends_with; use function substr; diff --git a/src/Manifest/FileMapping.php b/src/Manifest/FileMapping.php index db488c9..ca2b14c 100644 --- a/src/Manifest/FileMapping.php +++ b/src/Manifest/FileMapping.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; /** * Immutable value object representing a single file mapping from a scaffold provider. diff --git a/src/Manifest/FileMode.php b/src/Manifest/FileMode.php index 3f0c01a..deff674 100644 --- a/src/Manifest/FileMode.php +++ b/src/Manifest/FileMode.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; /** * Scaffold file write modes used in provider manifests and surfaced on {@see FileMapping}. diff --git a/src/Manifest/Glob.php b/src/Manifest/Glob.php index ef8efbf..4d1ceef 100644 --- a/src/Manifest/Glob.php +++ b/src/Manifest/Glob.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; use function preg_match; use function preg_quote; diff --git a/src/Manifest/ManifestExpander.php b/src/Manifest/ManifestExpander.php index 00ad575..3f34585 100644 --- a/src/Manifest/ManifestExpander.php +++ b/src/Manifest/ManifestExpander.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; use FilesystemIterator; use RecursiveCallbackFilterIterator; diff --git a/src/Manifest/ManifestLoader.php b/src/Manifest/ManifestLoader.php index cdb50af..f3e4044 100644 --- a/src/Manifest/ManifestLoader.php +++ b/src/Manifest/ManifestLoader.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; use Composer\Package\PackageInterface; use RuntimeException; diff --git a/src/Manifest/ManifestSchema.php b/src/Manifest/ManifestSchema.php index 439cd7f..afff6d9 100644 --- a/src/Manifest/ManifestSchema.php +++ b/src/Manifest/ManifestSchema.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Manifest; +namespace PHPForge\Scaffold\Manifest; use RuntimeException; diff --git a/src/Plugin.php b/src/Plugin.php index e67263e..2c75ce5 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold; +namespace PHPForge\Scaffold; use Composer\Composer; use Composer\IO\IOInterface; diff --git a/src/Scaffold/Applier.php b/src/Scaffold/Applier.php index 2dce5a1..aab4162 100644 --- a/src/Scaffold/Applier.php +++ b/src/Scaffold/Applier.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold; +namespace PHPForge\Scaffold\Scaffold; use Composer\IO\IOInterface; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{ApplyResult, ModeInterface}; +use PHPForge\Scaffold\Security\{PackageAllowlist, PathValidator}; use RuntimeException; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{ApplyResult, ModeInterface}; -use yii\scaffold\Security\{PackageAllowlist, PathValidator}; use function realpath; diff --git a/src/Scaffold/Lock/Hasher.php b/src/Scaffold/Lock/Hasher.php index b750018..c75f651 100644 --- a/src/Scaffold/Lock/Hasher.php +++ b/src/Scaffold/Lock/Hasher.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Lock; +namespace PHPForge\Scaffold\Scaffold\Lock; use RuntimeException; diff --git a/src/Scaffold/Lock/LockFile.php b/src/Scaffold/Lock/LockFile.php index d2cf482..b0c663c 100644 --- a/src/Scaffold/Lock/LockFile.php +++ b/src/Scaffold/Lock/LockFile.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Lock; +namespace PHPForge\Scaffold\Scaffold\Lock; use RuntimeException; diff --git a/src/Scaffold/Modes/AppendMode.php b/src/Scaffold/Modes/AppendMode.php index 5328803..2d8aeeb 100644 --- a/src/Scaffold/Modes/AppendMode.php +++ b/src/Scaffold/Modes/AppendMode.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\PathResolver; use RuntimeException; use SebastianBergmann\Diff\Differ; use SebastianBergmann\Diff\Output\DiffOnlyOutputBuilder; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\PathResolver; use function array_column; use function array_count_values; diff --git a/src/Scaffold/Modes/ApplyOutcome.php b/src/Scaffold/Modes/ApplyOutcome.php index 431f7ca..1d72401 100644 --- a/src/Scaffold/Modes/ApplyOutcome.php +++ b/src/Scaffold/Modes/ApplyOutcome.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; /** * Enumerates the possible outcomes after applying a scaffold file mapping. diff --git a/src/Scaffold/Modes/ApplyResult.php b/src/Scaffold/Modes/ApplyResult.php index 94526a1..46c3487 100644 --- a/src/Scaffold/Modes/ApplyResult.php +++ b/src/Scaffold/Modes/ApplyResult.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; /** * Represents the outcome of applying a single scaffold file mapping. diff --git a/src/Scaffold/Modes/ModeInterface.php b/src/Scaffold/Modes/ModeInterface.php index 479ca9f..51b5af5 100644 --- a/src/Scaffold/Modes/ModeInterface.php +++ b/src/Scaffold/Modes/ModeInterface.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; use RuntimeException; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; /** * Contract for all scaffold file-application strategies. diff --git a/src/Scaffold/Modes/PrependMode.php b/src/Scaffold/Modes/PrependMode.php index 9b96e56..8071de0 100644 --- a/src/Scaffold/Modes/PrependMode.php +++ b/src/Scaffold/Modes/PrependMode.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\PathResolver; use RuntimeException; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\PathResolver; use function sprintf; diff --git a/src/Scaffold/Modes/PreserveMode.php b/src/Scaffold/Modes/PreserveMode.php index 4456a93..bf69129 100644 --- a/src/Scaffold/Modes/PreserveMode.php +++ b/src/Scaffold/Modes/PreserveMode.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\PathResolver; use RuntimeException; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\PathResolver; use function sprintf; diff --git a/src/Scaffold/Modes/ReplaceMode.php b/src/Scaffold/Modes/ReplaceMode.php index fabb971..ad15c02 100644 --- a/src/Scaffold/Modes/ReplaceMode.php +++ b/src/Scaffold/Modes/ReplaceMode.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold\Modes; +namespace PHPForge\Scaffold\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\FileMapping; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\PathResolver; use RuntimeException; -use yii\scaffold\Manifest\FileMapping; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\PathResolver; use function sprintf; diff --git a/src/Scaffold/PathResolver.php b/src/Scaffold/PathResolver.php index 6e253b4..5558b5b 100644 --- a/src/Scaffold/PathResolver.php +++ b/src/Scaffold/PathResolver.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold; +namespace PHPForge\Scaffold\Scaffold; use RuntimeException; @@ -78,7 +78,7 @@ public static function realpathOrFallback(string $path): string * versions. * * @param string $vendorDir Absolute path to the Composer vendor directory. - * @param string $providerName Provider package name (for example, `yii2-extensions/app-base`). + * @param string $providerName Provider package name (for example, `php-forge/baseline`). * @param mixed $providerLock Decoded `providers.` entry from `scaffold-lock.json`, when present. * @param string $projectRoot Absolute path to the project root; required to expand relative lock paths. Pass an * empty string only when the caller knows that lock-recorded paths are absolute (legacy). diff --git a/src/Scaffold/Scaffolder.php b/src/Scaffold/Scaffolder.php index 95c1318..3b9b17d 100644 --- a/src/Scaffold/Scaffolder.php +++ b/src/Scaffold/Scaffolder.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Scaffold; +namespace PHPForge\Scaffold\Scaffold; use Composer\IO\IOInterface; use Composer\Package\PackageInterface; +use PHPForge\Scaffold\Manifest\{FileMode, ManifestLoader}; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Scaffold\Modes\{AppendMode, ApplyOutcome, ModeInterface, PrependMode, PreserveMode, ReplaceMode}; use Throwable; -use yii\scaffold\Manifest\{FileMode, ManifestLoader}; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\Scaffold\Modes\{AppendMode, ApplyOutcome, ModeInterface, PrependMode, PreserveMode, ReplaceMode}; use function is_array; use function is_string; diff --git a/src/Security/PackageAllowlist.php b/src/Security/PackageAllowlist.php index 9b37bf0..9f0f2a4 100644 --- a/src/Security/PackageAllowlist.php +++ b/src/Security/PackageAllowlist.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Security; +namespace PHPForge\Scaffold\Security; use RuntimeException; diff --git a/src/Security/PathValidator.php b/src/Security/PathValidator.php index 1f513e7..a51919f 100644 --- a/src/Security/PathValidator.php +++ b/src/Security/PathValidator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\Security; +namespace PHPForge\Scaffold\Security; use RuntimeException; diff --git a/src/Services/DiffService.php b/src/Services/DiffService.php index e6a6980..36fe657 100644 --- a/src/Services/DiffService.php +++ b/src/Services/DiffService.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\Services; +namespace PHPForge\Scaffold\Services; +use PHPForge\Scaffold\Console\{DiffColorizer, ExitCode, OutputWriter}; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Scaffold\PathResolver; +use PHPForge\Scaffold\Security\PathValidator; use RuntimeException; use SebastianBergmann\Diff\Differ; use SebastianBergmann\Diff\Output\StrictUnifiedDiffOutputBuilder; -use yii\scaffold\Console\{DiffColorizer, ExitCode, OutputWriter}; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\Scaffold\PathResolver; -use yii\scaffold\Security\PathValidator; use function is_file; use function preg_replace; diff --git a/src/Services/EjectService.php b/src/Services/EjectService.php index 4ec3401..4022b9f 100644 --- a/src/Services/EjectService.php +++ b/src/Services/EjectService.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace yii\scaffold\Services; +namespace PHPForge\Scaffold\Services; -use yii\scaffold\Console\{ExitCode, OutputWriter}; -use yii\scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Console\{ExitCode, OutputWriter}; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; use function sprintf; diff --git a/src/Services/ProvidersService.php b/src/Services/ProvidersService.php index 64f9881..d581ea1 100644 --- a/src/Services/ProvidersService.php +++ b/src/Services/ProvidersService.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace yii\scaffold\Services; +namespace PHPForge\Scaffold\Services; -use yii\scaffold\Console\{ExitCode, OutputWriter}; -use yii\scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Console\{ExitCode, OutputWriter}; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; use function array_fill_keys; use function array_keys; diff --git a/src/Services/ReapplyService.php b/src/Services/ReapplyService.php index 1bf1626..48c1c41 100644 --- a/src/Services/ReapplyService.php +++ b/src/Services/ReapplyService.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Services; +namespace PHPForge\Scaffold\Services; +use PHPForge\Scaffold\Console\{ExitCode, OutputWriter}; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Scaffold\PathResolver; +use PHPForge\Scaffold\Security\PathValidator; use RuntimeException; use Throwable; -use yii\scaffold\Console\{ExitCode, OutputWriter}; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Scaffold\PathResolver; -use yii\scaffold\Security\PathValidator; use function is_file; use function sprintf; diff --git a/src/Services/StatusService.php b/src/Services/StatusService.php index 7cc20e4..9627968 100644 --- a/src/Services/StatusService.php +++ b/src/Services/StatusService.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\Services; +namespace PHPForge\Scaffold\Services; +use PHPForge\Scaffold\Console\{ExitCode, OutputWriter}; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Scaffold\PathResolver; +use PHPForge\Scaffold\Security\PathValidator; use RuntimeException; use Throwable; -use yii\scaffold\Console\{ExitCode, OutputWriter}; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Scaffold\PathResolver; -use yii\scaffold\Security\PathValidator; use function max; use function sprintf; diff --git a/tests/unit/Console/ApplicationTest.php b/tests/Console/ApplicationTest.php similarity index 93% rename from tests/unit/Console/ApplicationTest.php rename to tests/Console/ApplicationTest.php index 98de1e5..43ec8a8 100644 --- a/tests/unit/Console/ApplicationTest.php +++ b/tests/Console/ApplicationTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console; +namespace PHPForge\Scaffold\Tests\Console; use Composer\InstalledVersions; +use PHPForge\Scaffold\Console\Application; +use PHPForge\Scaffold\Console\Command\{DiffCommand, EjectCommand, ProvidersCommand, ReapplyCommand, StatusCommand}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Console\Application; -use yii\scaffold\Console\Command\{DiffCommand, EjectCommand, ProvidersCommand, ReapplyCommand, StatusCommand}; use function sprintf; diff --git a/tests/unit/Console/Command/DiffCommandTest.php b/tests/Console/Command/DiffCommandTest.php similarity index 96% rename from tests/unit/Console/Command/DiffCommandTest.php rename to tests/Console/Command/DiffCommandTest.php index 97b446c..650795e 100644 --- a/tests/unit/Console/Command/DiffCommandTest.php +++ b/tests/Console/Command/DiffCommandTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console\Command; +namespace PHPForge\Scaffold\Tests\Console\Command; +use PHPForge\Scaffold\Console\Command\DiffCommand; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Console\Command\DiffCommand; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chdir; use function getcwd; @@ -149,7 +149,7 @@ public function testExecuteReturnsErrorWhenFileIsNotTracked(): void public function testExecuteReturnsFailureWhenGetcwdFails(): void { MockerState::addCondition( - 'yii\\scaffold\\Console\\Command', + 'PHPForge\\Scaffold\\Console\\Command', 'getcwd', [], false, diff --git a/tests/unit/Console/Command/EjectCommandTest.php b/tests/Console/Command/EjectCommandTest.php similarity index 94% rename from tests/unit/Console/Command/EjectCommandTest.php rename to tests/Console/Command/EjectCommandTest.php index 8cff6b8..6d7231d 100644 --- a/tests/unit/Console/Command/EjectCommandTest.php +++ b/tests/Console/Command/EjectCommandTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console\Command; +namespace PHPForge\Scaffold\Tests\Console\Command; +use PHPForge\Scaffold\Console\Command\EjectCommand; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Console\Command\EjectCommand; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chdir; use function getcwd; @@ -110,7 +110,7 @@ public function testExecuteReturnsErrorWhenFileIsNotTracked(): void public function testExecuteReturnsFailureWhenGetcwdFails(): void { MockerState::addCondition( - 'yii\\scaffold\\Console\\Command', + 'PHPForge\\Scaffold\\Console\\Command', 'getcwd', [], false, diff --git a/tests/unit/Console/Command/ProvidersCommandTest.php b/tests/Console/Command/ProvidersCommandTest.php similarity index 93% rename from tests/unit/Console/Command/ProvidersCommandTest.php rename to tests/Console/Command/ProvidersCommandTest.php index 7cfc6f5..40b84e5 100644 --- a/tests/unit/Console/Command/ProvidersCommandTest.php +++ b/tests/Console/Command/ProvidersCommandTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console\Command; +namespace PHPForge\Scaffold\Tests\Console\Command; +use PHPForge\Scaffold\Console\Command\ProvidersCommand; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Console\Command\ProvidersCommand; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chdir; use function getcwd; @@ -101,7 +101,7 @@ public function testExecutePrintsEmptyMessageWhenNoProvidersTracked(): void public function testExecuteReturnsFailureWhenGetcwdFails(): void { MockerState::addCondition( - 'yii\\scaffold\\Console\\Command', + 'PHPForge\\Scaffold\\Console\\Command', 'getcwd', [], false, diff --git a/tests/unit/Console/Command/ReapplyCommandTest.php b/tests/Console/Command/ReapplyCommandTest.php similarity index 96% rename from tests/unit/Console/Command/ReapplyCommandTest.php rename to tests/Console/Command/ReapplyCommandTest.php index 3c10850..3ffa5e3 100644 --- a/tests/unit/Console/Command/ReapplyCommandTest.php +++ b/tests/Console/Command/ReapplyCommandTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console\Command; +namespace PHPForge\Scaffold\Tests\Console\Command; +use PHPForge\Scaffold\Console\Command\ReapplyCommand; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Console\Command\ReapplyCommand; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chdir; use function getcwd; @@ -107,7 +107,7 @@ public function testExecuteReturnsErrorWhenFileFilterMatchesNothing(): void public function testExecuteReturnsFailureWhenGetcwdFails(): void { MockerState::addCondition( - 'yii\\scaffold\\Console\\Command', + 'PHPForge\\Scaffold\\Console\\Command', 'getcwd', [], false, diff --git a/tests/unit/Console/Command/StatusCommandTest.php b/tests/Console/Command/StatusCommandTest.php similarity index 94% rename from tests/unit/Console/Command/StatusCommandTest.php rename to tests/Console/Command/StatusCommandTest.php index f9d6005..96673e7 100644 --- a/tests/unit/Console/Command/StatusCommandTest.php +++ b/tests/Console/Command/StatusCommandTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console\Command; +namespace PHPForge\Scaffold\Tests\Console\Command; +use PHPForge\Scaffold\Console\Command\StatusCommand; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Console\Command\StatusCommand; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chdir; use function getcwd; @@ -117,7 +117,7 @@ public function testExecutePrintsHeaderAndRowsForTrackedFiles(): void public function testExecuteReturnsFailureWhenGetcwdFails(): void { MockerState::addCondition( - 'yii\\scaffold\\Console\\Command', + 'PHPForge\\Scaffold\\Console\\Command', 'getcwd', [], false, diff --git a/tests/unit/Console/DiffColorizerTest.php b/tests/Console/DiffColorizerTest.php similarity index 97% rename from tests/unit/Console/DiffColorizerTest.php rename to tests/Console/DiffColorizerTest.php index 108b053..dfa363f 100644 --- a/tests/unit/Console/DiffColorizerTest.php +++ b/tests/Console/DiffColorizerTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console; +namespace PHPForge\Scaffold\Tests\Console; +use PHPForge\Scaffold\Console\DiffColorizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Console\DiffColorizer; use function explode; diff --git a/tests/unit/Console/SymfonyOutputWriterTest.php b/tests/Console/SymfonyOutputWriterTest.php similarity index 97% rename from tests/unit/Console/SymfonyOutputWriterTest.php rename to tests/Console/SymfonyOutputWriterTest.php index 1234c37..90ded4b 100644 --- a/tests/unit/Console/SymfonyOutputWriterTest.php +++ b/tests/Console/SymfonyOutputWriterTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console; +namespace PHPForge\Scaffold\Tests\Console; +use PHPForge\Scaffold\Console\SymfonyOutputWriter; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; -use yii\scaffold\Console\SymfonyOutputWriter; /** * Unit tests for {@see SymfonyOutputWriter} verifying that stdout / stderr writes bypass Symfony's output formatter so diff --git a/tests/unit/Console/VendorDirResolverTest.php b/tests/Console/VendorDirResolverTest.php similarity index 98% rename from tests/unit/Console/VendorDirResolverTest.php rename to tests/Console/VendorDirResolverTest.php index 3176322..3d544f4 100644 --- a/tests/unit/Console/VendorDirResolverTest.php +++ b/tests/Console/VendorDirResolverTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Console; +namespace PHPForge\Scaffold\Tests\Console; +use PHPForge\Scaffold\Console\VendorDirResolver; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Console\VendorDirResolver; -use yii\scaffold\tests\support\TempDirectoryTrait; use function getenv; use function putenv; diff --git a/tests/unit/EventSubscriberTest.php b/tests/EventSubscriberTest.php similarity index 98% rename from tests/unit/EventSubscriberTest.php rename to tests/EventSubscriberTest.php index f8b8a8c..fbafde5 100644 --- a/tests/unit/EventSubscriberTest.php +++ b/tests/EventSubscriberTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit; +namespace PHPForge\Scaffold\Tests; use Composer\Composer; use Composer\Config; @@ -10,10 +10,10 @@ use Composer\Package\RootPackageInterface; use Composer\Script\Event as ScriptEvent; use Composer\Script\ScriptEvents; +use PHPForge\Scaffold\EventSubscriber; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionClass; -use yii\scaffold\EventSubscriber; /** * Unit tests for {@see EventSubscriber} event registration. diff --git a/tests/functional/ComposerInstallTest.php b/tests/Functional/ComposerInstallTest.php similarity index 98% rename from tests/functional/ComposerInstallTest.php rename to tests/Functional/ComposerInstallTest.php index b108558..2c167a8 100644 --- a/tests/functional/ComposerInstallTest.php +++ b/tests/Functional/ComposerInstallTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\functional; +namespace PHPForge\Scaffold\Tests\Functional; use Composer\IO\BufferIO; +use PHPForge\Scaffold\EventSubscriber; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\EventSubscriber; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; /** * Functional tests for the `post-install-cmd` flow using a real {@see \Composer\Composer} instance. diff --git a/tests/functional/CreateProjectTest.php b/tests/Functional/CreateProjectTest.php similarity index 98% rename from tests/functional/CreateProjectTest.php rename to tests/Functional/CreateProjectTest.php index cddb172..c20aab4 100644 --- a/tests/functional/CreateProjectTest.php +++ b/tests/Functional/CreateProjectTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\functional; +namespace PHPForge\Scaffold\Tests\Functional; use Composer\IO\BufferIO; +use PHPForge\Scaffold\EventSubscriber; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\EventSubscriber; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; /** * Functional tests for the `post-create-project-cmd` flow and its interaction with `post-install-cmd`. diff --git a/tests/functional/MultiLayerCompositionTest.php b/tests/Functional/MultiLayerCompositionTest.php similarity index 95% rename from tests/functional/MultiLayerCompositionTest.php rename to tests/Functional/MultiLayerCompositionTest.php index 198d4f2..0c0f2f2 100644 --- a/tests/functional/MultiLayerCompositionTest.php +++ b/tests/Functional/MultiLayerCompositionTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\functional; +namespace PHPForge\Scaffold\Tests\Functional; use Composer\Composer; use Composer\IO\BufferIO; +use PHPForge\Scaffold\EventSubscriber; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\EventSubscriber; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\{ComposerEventHarness, FakeProjectBuilder, TempDirectoryTrait}; /** * Functional tests for multi-provider composition and deterministic precedence. diff --git a/tests/functional/ScaffolderTest.php b/tests/Functional/ScaffolderTest.php similarity index 81% rename from tests/functional/ScaffolderTest.php rename to tests/Functional/ScaffolderTest.php index 038cff4..456dbb2 100644 --- a/tests/functional/ScaffolderTest.php +++ b/tests/Functional/ScaffolderTest.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace yii\scaffold\tests\functional; +namespace PHPForge\Scaffold\Tests\Functional; use Composer\IO\{BufferIO, IOInterface, NullIO}; use Composer\Package\PackageInterface; +use PHPForge\Scaffold\Manifest\{ManifestExpander, ManifestLoader, ManifestSchema}; +use PHPForge\Scaffold\Scaffold\{Applier, Scaffolder}; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Security\{PackageAllowlist, PathValidator}; +use PHPForge\Scaffold\Tests\Support\{FakeProjectBuilder, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionMethod; -use yii\scaffold\Manifest\{ManifestExpander, ManifestLoader, ManifestSchema}; -use yii\scaffold\Scaffold\{Applier, Scaffolder}; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Security\{PackageAllowlist, PathValidator}; -use yii\scaffold\tests\support\{FakeProjectBuilder, TempDirectoryTrait}; /** * Functional tests for {@see Scaffolder} end-to-end scaffold execution. @@ -29,13 +29,13 @@ public function testAllowedPackageNotInstalledEmitsSkipMessage(): void $builder = new FakeProjectBuilder($this->tempDir); // Root authorizes a provider that was never added to the installed-packages list. - $root = $this->makeRootPackage(['yii2-extensions/missing']); + $root = $this->makeRootPackage(['php-forge/missing']); $io = new BufferIO(); $scaffolder = new Scaffolder( new ManifestLoader(new ManifestSchema(), new ManifestExpander()), new Applier( - new PackageAllowlist(['yii2-extensions/missing']), + new PackageAllowlist(['php-forge/missing']), new PathValidator(), new Hasher(), $io, @@ -47,7 +47,7 @@ public function testAllowedPackageNotInstalledEmitsSkipMessage(): void $scaffolder->scaffold($root, [], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertStringContainsString( - 'Provider "yii2-extensions/missing" is not installed', + 'Provider "php-forge/missing" is not installed', $io->getOutput(), "Allowed providers not installed by Composer must emit a skip message so 'allowed-packages' typos are noticed.", ); @@ -57,11 +57,11 @@ public function testAppendModeIsIdempotentOnFullScaffold(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', '.gitignore', '*.log'); + $builder->createStubFile('php-forge/test', '.gitignore', '*.log'); $builder->createProjectFile('.gitignore', 'vendor/'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['.gitignore'], @@ -69,8 +69,8 @@ public function testAppendModeIsIdempotentOnFullScaffold(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); // First run: full scaffold writes the missing line. $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); @@ -94,42 +94,42 @@ public function testAppendModeRefreshesLockOwnershipWhenNewProviderClaimsExistin $builder = new FakeProjectBuilder($this->tempDir); // Two providers ship the same '.gitignore' content; the destination already matches both stubs identically. - $builder->createStubFile('yii2-extensions/old-provider', '.gitignore', "*.log\n"); - $builder->createStubFile('yii2-extensions/new-provider', '.gitignore', "*.log\n"); + $builder->createStubFile('php-forge/old-provider', '.gitignore', "*.log\n"); + $builder->createStubFile('php-forge/new-provider', '.gitignore', "*.log\n"); $builder->createProjectFile('.gitignore', "*.log\n"); $oldProvider = $this->makeProviderPackage( - 'yii2-extensions/old-provider', + 'php-forge/old-provider', ['scaffold' => ['copy' => ['.gitignore'], 'modes' => ['.gitignore' => 'append']]], ); $newProvider = $this->makeProviderPackage( - 'yii2-extensions/new-provider', + 'php-forge/new-provider', ['scaffold' => ['copy' => ['.gitignore'], 'modes' => ['.gitignore' => 'append']]], ); // First run: only the old provider is allowed; lock records its ownership. - $oldRoot = $this->makeRootPackage(['yii2-extensions/old-provider']); - $oldScaffolder = $this->makeScaffolder(['yii2-extensions/old-provider'], $builder); + $oldRoot = $this->makeRootPackage(['php-forge/old-provider']); + $oldScaffolder = $this->makeScaffolder(['php-forge/old-provider'], $builder); $oldScaffolder->scaffold($oldRoot, [$oldProvider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $oldLock = (new LockFile($builder->getProjectRoot()))->read(); self::assertSame( - 'yii2-extensions/old-provider', + 'php-forge/old-provider', $oldLock['files']['.gitignore']['provider'] ?? null, 'Initial scaffold must record the old provider as the owner.', ); // Second run: only the new provider is allowed. AppendMode finds no missing lines (Skipped) but the // ownership metadata must be refreshed to point to the new provider. - $newRoot = $this->makeRootPackage(['yii2-extensions/new-provider']); - $newScaffolder = $this->makeScaffolder(['yii2-extensions/new-provider'], $builder); + $newRoot = $this->makeRootPackage(['php-forge/new-provider']); + $newScaffolder = $this->makeScaffolder(['php-forge/new-provider'], $builder); $newScaffolder->scaffold($newRoot, [$newProvider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $newLock = (new LockFile($builder->getProjectRoot()))->read(); self::assertSame( - 'yii2-extensions/new-provider', + 'php-forge/new-provider', $newLock['files']['.gitignore']['provider'] ?? null, 'Skipped append must refresh the lock ownership metadata when a different provider claims the file.', ); @@ -139,11 +139,11 @@ public function testAppendModeSkippedOnInstallWhenAlreadyInLock(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', '.gitignore', '*.log'); + $builder->createStubFile('php-forge/test', '.gitignore', '*.log'); $builder->createProjectFile('.gitignore', 'vendor/'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['.gitignore'], @@ -151,8 +151,8 @@ public function testAppendModeSkippedOnInstallWhenAlreadyInLock(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); // First run: full scaffold writes the append and records lock. $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); @@ -174,17 +174,17 @@ public function testApplierExceptionIsLoggedAndScaffoldingContinues(): void $builder = new FakeProjectBuilder($this->tempDir); // Allowlist names a different provider so 'apply()' throws "Package not allowed"; the loop must catch and log it. - $builder->createStubFile('yii2-extensions/test', 'app.php', 'content'); + $builder->createStubFile('php-forge/test', 'app.php', 'content'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['app.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $io = new BufferIO(); @@ -247,11 +247,11 @@ public function testEmptyManifestReturnsEarlyAndDoesNotWriteLockFile(): void $builder = new FakeProjectBuilder($this->tempDir); // Provider has no scaffold extra at all; loader returns an empty mapping list and the lock stays untouched. - $provider = $this->makeProviderPackage('yii2-extensions/empty', []); - $root = $this->makeRootPackage(['yii2-extensions/empty']); + $provider = $this->makeProviderPackage('php-forge/empty', []); + $root = $this->makeRootPackage(['php-forge/empty']); $this - ->makeScaffolder(['yii2-extensions/empty'], $builder) + ->makeScaffolder(['php-forge/empty'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertFalse( @@ -265,18 +265,18 @@ public function testFailedManifestLoadIsLoggedAndSkippedInsteadOfFatal(): void $builder = new FakeProjectBuilder($this->tempDir); $provider = $this->makeProviderPackage( - 'yii2-extensions/bad', + 'php-forge/bad', [ // `manifest: "../escape.json"` triggers a traversal RuntimeException inside the loader. 'scaffold' => ['manifest' => '../escape.json'], ], ); - $root = $this->makeRootPackage(['yii2-extensions/bad']); + $root = $this->makeRootPackage(['php-forge/bad']); $io = new BufferIO(); $scaffolder = new Scaffolder( new ManifestLoader(new ManifestSchema(), new ManifestExpander()), - new Applier(new PackageAllowlist(['yii2-extensions/bad']), new PathValidator(), new Hasher(), $io), + new Applier(new PackageAllowlist(['php-forge/bad']), new PathValidator(), new Hasher(), $io), new LockFile($builder->getProjectRoot()), $io, ); @@ -284,7 +284,7 @@ public function testFailedManifestLoadIsLoggedAndSkippedInsteadOfFatal(): void $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertStringContainsString( - 'Failed to load manifest for "yii2-extensions/bad"', + 'Failed to load manifest for "php-forge/bad"', $io->getOutput(), 'A manifest-loader exception must be caught and reported per-provider rather than aborting the entire run.', ); @@ -294,32 +294,32 @@ public function testFirstScaffoldPersistsProviderPathInLock(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'app.php', 'a'); + $builder->createStubFile('php-forge/test', 'app.php', 'a'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['app.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $lockData = (new LockFile($builder->getProjectRoot()))->read(); self::assertArrayHasKey( - 'yii2-extensions/test', + 'php-forge/test', $lockData['providers'], 'Lock file must persist the provider entry after the first scaffold run.', ); - $providerEntry = $lockData['providers']['yii2-extensions/test'] ?? null; + $providerEntry = $lockData['providers']['php-forge/test'] ?? null; - $expectedPath = str_replace('\\', '/', $builder->getVendorDir() . '/yii2-extensions/test'); + $expectedPath = str_replace('\\', '/', $builder->getVendorDir() . '/php-forge/test'); self::assertSame( ['version' => '2.0.0', 'path' => $expectedPath], @@ -332,36 +332,36 @@ public function testFirstScaffoldRecordsRelativePathWhenProviderLivesInsideProje { $builder = new FakeProjectBuilder($this->tempDir); - $providerRootInsideProject = $builder->getProjectRoot() . '/vendor/yii2-extensions/test'; + $providerRootInsideProject = $builder->getProjectRoot() . '/vendor/php-forge/test'; mkdir($providerRootInsideProject, 0o777, recursive: true); file_put_contents($providerRootInsideProject . '/app.php', 'a'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['app.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold( $root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true, - ['yii2-extensions/test' => $providerRootInsideProject], + ['php-forge/test' => $providerRootInsideProject], ); $lockData = (new LockFile($builder->getProjectRoot()))->read(); self::assertSame( - ['version' => '2.0.0', 'path' => 'vendor/yii2-extensions/test'], - $lockData['providers']['yii2-extensions/test'] ?? null, + ['version' => '2.0.0', 'path' => 'vendor/php-forge/test'], + $lockData['providers']['php-forge/test'] ?? null, 'When the provider install path is inside the project root, the lock must store a project-relative path.', ); } @@ -370,11 +370,11 @@ public function testLastProviderWinsForSameDestination(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/base', 'app.php', 'base content'); - $builder->createStubFile('yii2-extensions/override', 'app.php', 'override content'); + $builder->createStubFile('php-forge/base', 'app.php', 'base content'); + $builder->createStubFile('php-forge/override', 'app.php', 'override content'); $base = $this->makeProviderPackage( - 'yii2-extensions/base', + 'php-forge/base', [ 'scaffold' => [ 'copy' => ['app.php'], @@ -382,16 +382,16 @@ public function testLastProviderWinsForSameDestination(): void ], ); $override = $this->makeProviderPackage( - 'yii2-extensions/override', + 'php-forge/override', [ 'scaffold' => [ 'copy' => ['app.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/base', 'yii2-extensions/override']); + $root = $this->makeRootPackage(['php-forge/base', 'php-forge/override']); $this - ->makeScaffolder(['yii2-extensions/base', 'yii2-extensions/override'], $builder) + ->makeScaffolder(['php-forge/base', 'php-forge/override'], $builder) ->scaffold( $root, [$base, $override], @@ -420,7 +420,7 @@ public function testLastProviderWinsForSameDestination(): void "Lock must contain exactly one entry for 'app.php'.", ); self::assertSame( - 'yii2-extensions/override', + 'php-forge/override', $appEntry['provider'], "Lock entry for 'app.php' must be attributed to the last (winning) provider.", ); @@ -430,19 +430,19 @@ public function testLockFileRecordsCorrectHash(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/app-base-scaffold', 'nginx.conf', 'server {}'); + $builder->createStubFile('php-forge/app-base-scaffold', 'nginx.conf', 'server {}'); $provider = $this->makeProviderPackage( - 'yii2-extensions/app-base-scaffold', + 'php-forge/app-base-scaffold', [ 'scaffold' => [ 'copy' => ['nginx.conf'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/app-base-scaffold']); + $root = $this->makeRootPackage(['php-forge/app-base-scaffold']); $this - ->makeScaffolder(['yii2-extensions/app-base-scaffold'], $builder) + ->makeScaffolder(['php-forge/app-base-scaffold'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $lockFile = new LockFile($builder->getProjectRoot()); @@ -491,15 +491,15 @@ public function testManifestLoadFailureOnEarlierProviderDoesNotHaltLaterProvider { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/good', 'app.php', 'good-content'); + $builder->createStubFile('php-forge/good', 'app.php', 'good-content'); $bad = $this->makeProviderPackage( - 'yii2-extensions/bad', + 'php-forge/bad', // `manifest: "../escape.json"` triggers a traversal RuntimeException inside the loader. ['scaffold' => ['manifest' => '../escape.json']], ); $good = $this->makeProviderPackage( - 'yii2-extensions/good', + 'php-forge/good', [ 'scaffold' => [ 'copy' => ['app.php'], @@ -507,13 +507,13 @@ public function testManifestLoadFailureOnEarlierProviderDoesNotHaltLaterProvider ], ); // 'bad' is listed first so its manifest-load failure triggers the continue-branch before 'good' is processed. - $root = $this->makeRootPackage(['yii2-extensions/bad', 'yii2-extensions/good']); + $root = $this->makeRootPackage(['php-forge/bad', 'php-forge/good']); $bufferIo = new BufferIO(); $scaffolder = new Scaffolder( new ManifestLoader(new ManifestSchema(), new ManifestExpander()), new Applier( - new PackageAllowlist(['yii2-extensions/bad', 'yii2-extensions/good']), + new PackageAllowlist(['php-forge/bad', 'php-forge/good']), new PathValidator(), new Hasher(), $bufferIo, @@ -545,10 +545,10 @@ public function testMissingProviderPackageDoesNotHaltLaterProviders(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/good', 'app.php', 'good-content'); + $builder->createStubFile('php-forge/good', 'app.php', 'good-content'); $good = $this->makeProviderPackage( - 'yii2-extensions/good', + 'php-forge/good', [ 'scaffold' => [ 'copy' => ['app.php'], @@ -556,13 +556,13 @@ public function testMissingProviderPackageDoesNotHaltLaterProviders(): void ], ); // 'missing' is allowed but not installed so its branch triggers the skip-message continue path. - $root = $this->makeRootPackage(['yii2-extensions/missing', 'yii2-extensions/good']); + $root = $this->makeRootPackage(['php-forge/missing', 'php-forge/good']); $bufferIo = new BufferIO(); $scaffolder = new Scaffolder( new ManifestLoader(new ManifestSchema(), new ManifestExpander()), new Applier( - new PackageAllowlist(['yii2-extensions/missing', 'yii2-extensions/good']), + new PackageAllowlist(['php-forge/missing', 'php-forge/good']), new PathValidator(), new Hasher(), $bufferIo, @@ -575,7 +575,7 @@ public function testMissingProviderPackageDoesNotHaltLaterProviders(): void $scaffolder->scaffold($root, [$good], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertStringContainsString( - 'Provider "yii2-extensions/missing" is not installed', + 'Provider "php-forge/missing" is not installed', $bufferIo->getOutput(), 'The uninstalled allowed-package must emit the skip message before the loop continues.', ); @@ -589,11 +589,11 @@ public function testMultipleFilesFromSameProvider(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'a.php', 'a'); - $builder->createStubFile('yii2-extensions/test', 'b.php', 'b'); + $builder->createStubFile('php-forge/test', 'a.php', 'a'); + $builder->createStubFile('php-forge/test', 'b.php', 'b'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => [ @@ -603,9 +603,9 @@ public function testMultipleFilesFromSameProvider(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertFileExists( @@ -633,10 +633,10 @@ public function testNonStringAllowedEntryIsSkippedWithoutHaltingLaterProviders() { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/good', 'app.php', 'good-content'); + $builder->createStubFile('php-forge/good', 'app.php', 'good-content'); $good = $this->makeProviderPackage( - 'yii2-extensions/good', + 'php-forge/good', [ 'scaffold' => [ 'copy' => ['app.php'], @@ -649,7 +649,7 @@ public function testNonStringAllowedEntryIsSkippedWithoutHaltingLaterProviders() $root->method('getExtra')->willReturn( [ 'scaffold' => [ - 'allowed-packages' => [42, 'yii2-extensions/good'], + 'allowed-packages' => [42, 'php-forge/good'], ], ], ); @@ -657,7 +657,7 @@ public function testNonStringAllowedEntryIsSkippedWithoutHaltingLaterProviders() $bufferIo = new BufferIO(); $scaffolder = new Scaffolder( new ManifestLoader(new ManifestSchema(), new ManifestExpander()), - new Applier(new PackageAllowlist(['yii2-extensions/good']), new PathValidator(), new Hasher(), $bufferIo), + new Applier(new PackageAllowlist(['php-forge/good']), new PathValidator(), new Hasher(), $bufferIo), new LockFile($builder->getProjectRoot()), $bufferIo, ); @@ -666,7 +666,7 @@ public function testNonStringAllowedEntryIsSkippedWithoutHaltingLaterProviders() self::assertFileExists( $builder->getProjectRoot() . '/app.php', - "When the first allowed-packages entry is not a string, the loop must 'continue' so 'yii2-extensions/good' runs.", + "When the first allowed-packages entry is not a string, the loop must 'continue' so 'php-forge/good' runs.", ); } @@ -710,11 +710,11 @@ public function testPrependModeSkippedOnPartialRunWhenAlreadyInLock(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'prepend.txt', 'header'); + $builder->createStubFile('php-forge/test', 'prepend.txt', 'header'); $builder->createProjectFile('prepend.txt', 'existing'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['prepend.txt'], @@ -723,8 +723,8 @@ public function testPrependModeSkippedOnPartialRunWhenAlreadyInLock(): void ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); // First run records a lock entry for the prepend mapping. $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); @@ -745,11 +745,11 @@ public function testPreserveDoesNotOverwriteAlreadyTrackedLockEntry(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'config.php', 'stub'); + $builder->createStubFile('php-forge/test', 'config.php', 'stub'); $builder->createProjectFile('config.php', 'user-content'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['config.php'], @@ -757,8 +757,8 @@ public function testPreserveDoesNotOverwriteAlreadyTrackedLockEntry(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); // First run records the current hash in the lock. $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); @@ -781,11 +781,11 @@ public function testPreserveFileIsNotOverwritten(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'config/params.php', 'stub content'); + $builder->createStubFile('php-forge/test', 'config/params.php', 'stub content'); $builder->createProjectFile('config/params.php', 'user content'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['config/params.php'], @@ -794,9 +794,9 @@ public function testPreserveFileIsNotOverwritten(): void ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertSame( @@ -824,11 +824,11 @@ public function testPreserveRecordsExistingUntrackedFileInLock(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'config.php', 'stub'); + $builder->createStubFile('php-forge/test', 'config.php', 'stub'); $builder->createProjectFile('config.php', 'user-content'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['config.php'], @@ -836,9 +836,9 @@ public function testPreserveRecordsExistingUntrackedFileInLock(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertFileExists( @@ -871,19 +871,19 @@ public function testReplaceFileIsWrittenAndLockCreated(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/app-base-scaffold', 'config/params.php', 'createStubFile('php-forge/app-base-scaffold', 'config/params.php', 'makeProviderPackage( - 'yii2-extensions/app-base-scaffold', + 'php-forge/app-base-scaffold', [ 'scaffold' => [ 'copy' => ['config/params.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/app-base-scaffold']); + $root = $this->makeRootPackage(['php-forge/app-base-scaffold']); $this - ->makeScaffolder(['yii2-extensions/app-base-scaffold'], $builder) + ->makeScaffolder(['php-forge/app-base-scaffold'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); self::assertFileExists( @@ -900,25 +900,25 @@ public function testReplaceOverwritesLockEntryForPreviouslyTrackedDestination(): { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'app.php', 'v1'); + $builder->createStubFile('php-forge/test', 'app.php', 'v1'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['app.php'], ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $firstHash = (new LockFile($builder->getProjectRoot()))->getHashAtScaffold('app.php'); // Change the stub so the second run writes different content. - $builder->createStubFile('yii2-extensions/test', 'app.php', 'v2'); + $builder->createStubFile('php-forge/test', 'app.php', 'v2'); $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $secondHash = (new LockFile($builder->getProjectRoot()))->getHashAtScaffold('app.php'); @@ -939,7 +939,7 @@ public function testScaffoldPersistsUpdatedProviderPathWhenOnlyProviderChanged() { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'config.php', 'stub'); + $builder->createStubFile('php-forge/test', 'config.php', 'stub'); $builder->createProjectFile('config.php', 'user-content'); $userHash = (new Hasher())->hash($builder->getProjectRoot() . '/config.php'); @@ -948,12 +948,12 @@ public function testScaffoldPersistsUpdatedProviderPathWhenOnlyProviderChanged() (new LockFile($builder->getProjectRoot()))->write( [ 'providers' => [ - 'yii2-extensions/test' => ['path' => '/obsolete/path'], + 'php-forge/test' => ['path' => '/obsolete/path'], ], 'files' => [ 'config.php' => [ 'hash' => $userHash, - 'provider' => 'yii2-extensions/test', + 'provider' => 'php-forge/test', 'source' => 'config.php', 'mode' => 'preserve', ], @@ -962,7 +962,7 @@ public function testScaffoldPersistsUpdatedProviderPathWhenOnlyProviderChanged() ); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => ['config.php'], @@ -970,16 +970,16 @@ public function testScaffoldPersistsUpdatedProviderPathWhenOnlyProviderChanged() ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); + $root = $this->makeRootPackage(['php-forge/test']); $this - ->makeScaffolder(['yii2-extensions/test'], $builder) + ->makeScaffolder(['php-forge/test'], $builder) ->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); $lockData = (new LockFile($builder->getProjectRoot()))->read(); - $providerEntry = $lockData['providers']['yii2-extensions/test'] ?? null; + $providerEntry = $lockData['providers']['php-forge/test'] ?? null; - $expectedPath = str_replace('\\', '/', $builder->getVendorDir() . '/yii2-extensions/test'); + $expectedPath = str_replace('\\', '/', $builder->getVendorDir() . '/php-forge/test'); self::assertSame( ['version' => '2.0.0', 'path' => $expectedPath], @@ -992,12 +992,12 @@ public function testSubsequentFileAppliedAfterFirstEntryIsSkipped(): void { $builder = new FakeProjectBuilder($this->tempDir); - $builder->createStubFile('yii2-extensions/test', 'append.txt', 'appended'); - $builder->createStubFile('yii2-extensions/test', 'fresh.txt', 'fresh content'); + $builder->createStubFile('php-forge/test', 'append.txt', 'appended'); + $builder->createStubFile('php-forge/test', 'fresh.txt', 'fresh content'); $builder->createProjectFile('append.txt', 'existing'); $provider = $this->makeProviderPackage( - 'yii2-extensions/test', + 'php-forge/test', [ 'scaffold' => [ 'copy' => [ @@ -1008,8 +1008,8 @@ public function testSubsequentFileAppliedAfterFirstEntryIsSkipped(): void ], ], ); - $root = $this->makeRootPackage(['yii2-extensions/test']); - $scaffolder = $this->makeScaffolder(['yii2-extensions/test'], $builder); + $root = $this->makeRootPackage(['php-forge/test']); + $scaffolder = $this->makeScaffolder(['php-forge/test'], $builder); // First full run records both entries in the lock. $scaffolder->scaffold($root, [$provider], $builder->getProjectRoot(), $builder->getVendorDir(), true); diff --git a/tests/unit/Manifest/DefaultExcludesTest.php b/tests/Manifest/DefaultExcludesTest.php similarity index 93% rename from tests/unit/Manifest/DefaultExcludesTest.php rename to tests/Manifest/DefaultExcludesTest.php index 3f61a6a..ac791b9 100644 --- a/tests/unit/Manifest/DefaultExcludesTest.php +++ b/tests/Manifest/DefaultExcludesTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; +use PHPForge\Scaffold\Manifest\DefaultExcludes; +use PHPForge\Scaffold\Tests\Provider\DefaultExcludesProvider; use PHPUnit\Framework\Attributes\DataProviderExternal; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Manifest\DefaultExcludes; -use yii\scaffold\tests\providers\DefaultExcludesProvider; /** * Unit tests for {@see DefaultExcludes} built-in exclusion patterns. diff --git a/tests/unit/Manifest/FileMappingTest.php b/tests/Manifest/FileMappingTest.php similarity index 90% rename from tests/unit/Manifest/FileMappingTest.php rename to tests/Manifest/FileMappingTest.php index bb97ea2..936ff66 100644 --- a/tests/unit/Manifest/FileMappingTest.php +++ b/tests/Manifest/FileMappingTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; use Error; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionProperty; -use yii\scaffold\Manifest\{FileMapping, FileMode}; /** * Unit tests for {@see FileMapping} value object construction and property access. @@ -57,12 +57,12 @@ public function testConstructorAssignsProviderName(): void 'config/params.php', 'stubs/params.php', FileMode::Preserve, - 'yii2-extensions/nginx-scaffold', + 'php-forge/nginx-scaffold', '/path', ); self::assertSame( - 'yii2-extensions/nginx-scaffold', + 'php-forge/nginx-scaffold', $mapping->providerName, 'Constructor should assign the providerName property correctly.', ); @@ -75,11 +75,11 @@ public function testConstructorAssignsProviderPath(): void 'stubs/params.php', FileMode::Preserve, 'vendor/pkg', - '/vendor/yii2-extensions/nginx-scaffold', + '/vendor/php-forge/nginx-scaffold', ); self::assertSame( - '/vendor/yii2-extensions/nginx-scaffold', + '/vendor/php-forge/nginx-scaffold', $mapping->providerPath, 'Constructor should assign the providerPath property correctly.', ); diff --git a/tests/unit/Manifest/GlobTest.php b/tests/Manifest/GlobTest.php similarity index 97% rename from tests/unit/Manifest/GlobTest.php rename to tests/Manifest/GlobTest.php index 1609ec9..a2e8a77 100644 --- a/tests/unit/Manifest/GlobTest.php +++ b/tests/Manifest/GlobTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; +use PHPForge\Scaffold\Manifest\Glob; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Manifest\Glob; /** * Unit tests for {@see Glob} pattern-to-regex conversion and matching semantics. diff --git a/tests/unit/Manifest/ManifestExpanderTest.php b/tests/Manifest/ManifestExpanderTest.php similarity index 99% rename from tests/unit/Manifest/ManifestExpanderTest.php rename to tests/Manifest/ManifestExpanderTest.php index bdf07c2..1f88f1d 100644 --- a/tests/unit/Manifest/ManifestExpanderTest.php +++ b/tests/Manifest/ManifestExpanderTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode, ManifestExpander}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; -use yii\scaffold\Manifest\{FileMapping, FileMode, ManifestExpander}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function chmod; use function file_put_contents; diff --git a/tests/unit/Manifest/ManifestLoaderTest.php b/tests/Manifest/ManifestLoaderTest.php similarity index 98% rename from tests/unit/Manifest/ManifestLoaderTest.php rename to tests/Manifest/ManifestLoaderTest.php index 61918f1..42cac86 100644 --- a/tests/unit/Manifest/ManifestLoaderTest.php +++ b/tests/Manifest/ManifestLoaderTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; use Composer\Package\PackageInterface; use JsonException; +use PHPForge\Scaffold\Manifest\{FileMode, ManifestExpander, ManifestLoader, ManifestSchema}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Manifest\{FileMode, ManifestExpander, ManifestLoader, ManifestSchema}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function file_put_contents; use function json_encode; @@ -204,7 +204,7 @@ public function testLoadThrowsWhenExternalManifestCannotBeRead(): void file_put_contents($manifestPath, '{}'); MockerState::addCondition( - 'yii\\scaffold\\Manifest', + 'PHPForge\\Scaffold\\Manifest', 'file_get_contents', [$manifestPath, false, null, 0, null], false, diff --git a/tests/unit/Manifest/ManifestSchemaTest.php b/tests/Manifest/ManifestSchemaTest.php similarity index 99% rename from tests/unit/Manifest/ManifestSchemaTest.php rename to tests/Manifest/ManifestSchemaTest.php index 10a9a1d..eafb2aa 100644 --- a/tests/unit/Manifest/ManifestSchemaTest.php +++ b/tests/Manifest/ManifestSchemaTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Manifest; +namespace PHPForge\Scaffold\Tests\Manifest; +use PHPForge\Scaffold\Manifest\{FileMode, ManifestSchema}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; -use yii\scaffold\Manifest\{FileMode, ManifestSchema}; /** * Unit tests for {@see ManifestSchema} validation of the `copy` / `exclude` / `modes` shape. diff --git a/tests/unit/PluginTest.php b/tests/PluginTest.php similarity index 97% rename from tests/unit/PluginTest.php rename to tests/PluginTest.php index 37c3c38..8a4c437 100644 --- a/tests/unit/PluginTest.php +++ b/tests/PluginTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit; +namespace PHPForge\Scaffold\Tests; use Composer\Composer; use Composer\EventDispatcher\EventDispatcher; use Composer\IO\NullIO; use Composer\Plugin\{Capable, PluginInterface}; +use PHPForge\Scaffold\{EventSubscriber, Plugin}; use PHPUnit\Framework\Attributes\{DoesNotPerformAssertions, Group}; use PHPUnit\Framework\TestCase; -use yii\scaffold\{EventSubscriber, Plugin}; /** * Unit tests for {@see Plugin} interface implementations and capabilities. diff --git a/tests/providers/DefaultExcludesProvider.php b/tests/Provider/DefaultExcludesProvider.php similarity index 96% rename from tests/providers/DefaultExcludesProvider.php rename to tests/Provider/DefaultExcludesProvider.php index 29f6d58..164dbed 100644 --- a/tests/providers/DefaultExcludesProvider.php +++ b/tests/Provider/DefaultExcludesProvider.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace yii\scaffold\tests\providers; +namespace PHPForge\Scaffold\Tests\Provider; /** - * Data provider for {@see \yii\scaffold\tests\unit\Manifest\DefaultExcludesTest} test cases. + * Data provider for {@see \PHPForge\Scaffold\Tests\Manifest\DefaultExcludesTest} test cases. */ final class DefaultExcludesProvider { diff --git a/tests/unit/Scaffold/ApplierTest.php b/tests/Scaffold/ApplierTest.php similarity index 89% rename from tests/unit/Scaffold/ApplierTest.php rename to tests/Scaffold/ApplierTest.php index 157f06b..39ea3a3 100644 --- a/tests/unit/Scaffold/ApplierTest.php +++ b/tests/Scaffold/ApplierTest.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold; +namespace PHPForge\Scaffold\Tests\Scaffold; use Composer\IO\IOInterface; use Composer\IO\NullIO; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; +use PHPForge\Scaffold\Scaffold\Applier; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{ApplyOutcome, PreserveMode, ReplaceMode}; +use PHPForge\Scaffold\Security\{PackageAllowlist, PathValidator}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\TestCase; use RuntimeException; -use yii\scaffold\Manifest\{FileMapping, FileMode}; -use yii\scaffold\Scaffold\Applier; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{ApplyOutcome, PreserveMode, ReplaceMode}; -use yii\scaffold\Security\{PackageAllowlist, PathValidator}; -use yii\scaffold\tests\support\TempDirectoryTrait; use function is_string; @@ -51,7 +51,7 @@ public function testNoWarningWrittenForSkippedPreserveFile(): void $io->expects(self::never())->method('writeError'); $applier = new Applier( - new PackageAllowlist(['yii2-extensions/test']), + new PackageAllowlist(['php-forge/test']), new PathValidator(), new Hasher(), $io, @@ -109,10 +109,10 @@ public function testSourceTraversalThrows(): void public function testUnauthorizedProviderThrows(): void { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('yii2-extensions/unauthorized'); + $this->expectExceptionMessage('php-forge/unauthorized'); $this->makeApplier([])->apply( - $this->makeMapping(providerName: 'yii2-extensions/unauthorized'), + $this->makeMapping(providerName: 'php-forge/unauthorized'), "{$this->tempDir}/project", new ReplaceMode(), null, @@ -140,7 +140,7 @@ public function testUserModifiedFileForwardsWarningToIo(): void ); $applier = new Applier( - new PackageAllowlist(['yii2-extensions/test']), + new PackageAllowlist(['php-forge/test']), new PathValidator(), new Hasher(), $io, @@ -199,11 +199,11 @@ protected function tearDown(): void * Creates an instance of Applier with a specified allowlist for testing. * * @param list $allowedPackages List of allowed package names for the Applier's PackageAllowlist; defaults - * to ['yii2-extensions/test']. + * to ['php-forge/test']. * * @return Applier Configured Applier instance for testing, with the specified allowlist and a NullIO for output. */ - private function makeApplier(array $allowedPackages = ['yii2-extensions/test']): Applier + private function makeApplier(array $allowedPackages = ['php-forge/test']): Applier { return new Applier( new PackageAllowlist($allowedPackages), @@ -225,7 +225,7 @@ private function makeApplier(array $allowedPackages = ['yii2-extensions/test']): private function makeMapping( string $destination = 'output.txt', string $source = 'stubs/source.txt', - string $providerName = 'yii2-extensions/test', + string $providerName = 'php-forge/test', ): FileMapping { return new FileMapping( destination: $destination, diff --git a/tests/unit/Scaffold/Lock/HasherTest.php b/tests/Scaffold/Lock/HasherTest.php similarity index 94% rename from tests/unit/Scaffold/Lock/HasherTest.php rename to tests/Scaffold/Lock/HasherTest.php index 8676bc3..72a44f8 100644 --- a/tests/unit/Scaffold/Lock/HasherTest.php +++ b/tests/Scaffold/Lock/HasherTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Lock; +namespace PHPForge\Scaffold\Tests\Scaffold\Lock; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\tests\support\TempDirectoryTrait; use function strlen; @@ -116,7 +116,7 @@ public function testHashThrowsWhenFileExistsButIsUnreadable(): void // Force `is_readable()` inside the Lock namespace to report false while the file still exists. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'is_readable', [$file], false, @@ -136,7 +136,7 @@ public function testHashThrowsWhenHashFileReturnsFalse(): void // Real file is readable; force `hash_file()` itself to report false to hit the post-read failure branch. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'hash_file', [ 'sha256', diff --git a/tests/unit/Scaffold/Lock/LockFileTest.php b/tests/Scaffold/Lock/LockFileTest.php similarity index 97% rename from tests/unit/Scaffold/Lock/LockFileTest.php rename to tests/Scaffold/Lock/LockFileTest.php index 9b47ef4..6713d97 100644 --- a/tests/unit/Scaffold/Lock/LockFileTest.php +++ b/tests/Scaffold/Lock/LockFileTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Lock; +namespace PHPForge\Scaffold\Tests\Scaffold\Lock; use JsonException; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see LockFile} read/write operations and hash lookup. @@ -208,7 +208,7 @@ public function testReadThrowsWhenFileGetContentsFails(): void file_put_contents($path, '{"providers":{},"files":{}}'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'file_get_contents', [$path, false, null, 0, null], false, @@ -304,7 +304,7 @@ public function testWriteThrowsWhenPersistenceFails(): void // Simulate `file_put_contents` succeeding but `rename` failing, exercising the cleanup + throw branch. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'rename', [ $tmp, @@ -329,7 +329,7 @@ public function testWriteUnlinksOrphanTmpFileAfterPersistenceFailure(): void $tmp = "{$path}.tmp"; MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'rename', [ $tmp, diff --git a/tests/unit/Scaffold/Modes/AppendModeTest.php b/tests/Scaffold/Modes/AppendModeTest.php similarity index 98% rename from tests/unit/Scaffold/Modes/AppendModeTest.php rename to tests/Scaffold/Modes/AppendModeTest.php index 8440da3..6fe2761 100644 --- a/tests/unit/Scaffold/Modes/AppendModeTest.php +++ b/tests/Scaffold/Modes/AppendModeTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Modes; +namespace PHPForge\Scaffold\Tests\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{AppendMode, ApplyOutcome}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Manifest\{FileMapping, FileMode}; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{AppendMode, ApplyOutcome}; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see AppendMode} scaffold file application strategy. @@ -711,7 +711,7 @@ public function testRewritesDestinationWithMergedContentWhenLinesAreMissing(): v $capturedFlag = null; MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_put_contents', [ $projectDir . DIRECTORY_SEPARATOR . 'output.txt', @@ -751,7 +751,7 @@ public function testThrowsWhenAppendWriteFails(): void $this->makeSourceFile("missing\n"); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_put_contents', [], false, @@ -780,7 +780,7 @@ public function testThrowsWhenDestinationReadFails(): void // Mock the destination read by exact path to fail; the source read (different path) is unaffected. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_get_contents', [$projectDir . DIRECTORY_SEPARATOR . 'output.txt', false, null, 0, null], false, @@ -803,7 +803,7 @@ public function testThrowsWhenSourceReadFails(): void // 'default: true' fails every 'file_get_contents' in the Modes namespace, independent of how paths are assembled. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_get_contents', [], false, @@ -826,7 +826,7 @@ public function testThrowsWhenWriteFails(): void $this->makeSourceFile('data'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_put_contents', [], false, @@ -853,7 +853,7 @@ public function testUsesZeroFlagWhenDestinationDoesNotExist(): void $capturedFlag = null; MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_put_contents', [ $projectDir . DIRECTORY_SEPARATOR . 'output.txt', diff --git a/tests/unit/Scaffold/Modes/PrependModeTest.php b/tests/Scaffold/Modes/PrependModeTest.php similarity index 95% rename from tests/unit/Scaffold/Modes/PrependModeTest.php rename to tests/Scaffold/Modes/PrependModeTest.php index d156d68..8bc8c7f 100644 --- a/tests/unit/Scaffold/Modes/PrependModeTest.php +++ b/tests/Scaffold/Modes/PrependModeTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Modes; +namespace PHPForge\Scaffold\Tests\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{ApplyOutcome, PrependMode}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Manifest\{FileMapping, FileMode}; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{ApplyOutcome, PrependMode}; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see PrependMode} scaffold file application strategy. @@ -152,7 +152,7 @@ public function testThrowsWhenDestinationReadFails(): void $destBasename = 'output.txt'; MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_get_contents', [ /** @@ -180,7 +180,7 @@ public function testThrowsWhenSourceReadFails(): void $this->makeSourceFile('x'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_get_contents', [], false, @@ -203,7 +203,7 @@ public function testThrowsWhenWriteFails(): void $this->makeSourceFile('source'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'file_put_contents', [], false, diff --git a/tests/unit/Scaffold/Modes/PreserveModeTest.php b/tests/Scaffold/Modes/PreserveModeTest.php similarity index 95% rename from tests/unit/Scaffold/Modes/PreserveModeTest.php rename to tests/Scaffold/Modes/PreserveModeTest.php index b391393..d180862 100644 --- a/tests/unit/Scaffold/Modes/PreserveModeTest.php +++ b/tests/Scaffold/Modes/PreserveModeTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Modes; +namespace PHPForge\Scaffold\Tests\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{ApplyOutcome, PreserveMode}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Manifest\{FileMapping, FileMode}; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{ApplyOutcome, PreserveMode}; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see PreserveMode} scaffold file application strategy. @@ -167,7 +167,7 @@ public function testThrowsWhenCopyFails(): void $this->makeSourceFile('content'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'copy', [], false, diff --git a/tests/unit/Scaffold/Modes/ReplaceModeTest.php b/tests/Scaffold/Modes/ReplaceModeTest.php similarity index 96% rename from tests/unit/Scaffold/Modes/ReplaceModeTest.php rename to tests/Scaffold/Modes/ReplaceModeTest.php index 6fe7301..543901e 100644 --- a/tests/unit/Scaffold/Modes/ReplaceModeTest.php +++ b/tests/Scaffold/Modes/ReplaceModeTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold\Modes; +namespace PHPForge\Scaffold\Tests\Scaffold\Modes; +use PHPForge\Scaffold\Manifest\{FileMapping, FileMode}; +use PHPForge\Scaffold\Scaffold\Lock\Hasher; +use PHPForge\Scaffold\Scaffold\Modes\{ApplyOutcome, ReplaceMode}; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Manifest\{FileMapping, FileMode}; -use yii\scaffold\Scaffold\Lock\Hasher; -use yii\scaffold\Scaffold\Modes\{ApplyOutcome, ReplaceMode}; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see ReplaceMode} scaffold file application strategy. @@ -179,7 +179,7 @@ public function testThrowsWhenCopyFails(): void $this->makeSourceFile('content'); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Modes', + 'PHPForge\\Scaffold\\Scaffold\\Modes', 'copy', [], false, diff --git a/tests/unit/Scaffold/PathResolverTest.php b/tests/Scaffold/PathResolverTest.php similarity index 98% rename from tests/unit/Scaffold/PathResolverTest.php rename to tests/Scaffold/PathResolverTest.php index 9f592f7..4034e92 100644 --- a/tests/unit/Scaffold/PathResolverTest.php +++ b/tests/Scaffold/PathResolverTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold; +namespace PHPForge\Scaffold\Tests\Scaffold; +use PHPForge\Scaffold\Scaffold\PathResolver; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\PathResolver; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see PathResolver} path joining, directory creation, and provider-root resolution. @@ -85,7 +85,7 @@ public function testEnsureDirectoryIsNoopWhenRaceCreatesDirectoryAfterMkdirFails $isDirCalls = 0; MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'is_dir', [$dir], static function () use (&$isDirCalls): bool { @@ -97,7 +97,7 @@ static function () use (&$isDirCalls): bool { }, ); MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'mkdir', [$dir, 0o777, true, null], false, @@ -116,13 +116,13 @@ public function testEnsureDirectoryThrowsWhenMkdirFailsAndDirectoryStillAbsent() $dir = "{$this->tempDir}/unwritable"; MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'is_dir', [$dir], false, ); MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'mkdir', [$dir, 0o777, true, null], false, diff --git a/tests/unit/Scaffold/ScaffolderToProjectRelativeTest.php b/tests/Scaffold/ScaffolderToProjectRelativeTest.php similarity index 98% rename from tests/unit/Scaffold/ScaffolderToProjectRelativeTest.php rename to tests/Scaffold/ScaffolderToProjectRelativeTest.php index bf48a8b..d96385e 100644 --- a/tests/unit/Scaffold/ScaffolderToProjectRelativeTest.php +++ b/tests/Scaffold/ScaffolderToProjectRelativeTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Scaffold; +namespace PHPForge\Scaffold\Tests\Scaffold; +use PHPForge\Scaffold\Scaffold\Scaffolder; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use ReflectionMethod; -use yii\scaffold\Scaffold\Scaffolder; /** * Unit tests for the private `Scaffolder::toProjectRelative` path-normalization helper. diff --git a/tests/unit/Security/PackageAllowlistTest.php b/tests/Security/PackageAllowlistTest.php similarity index 60% rename from tests/unit/Security/PackageAllowlistTest.php rename to tests/Security/PackageAllowlistTest.php index 29fd6fb..ba6b6e7 100644 --- a/tests/unit/Security/PackageAllowlistTest.php +++ b/tests/Security/PackageAllowlistTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Security; +namespace PHPForge\Scaffold\Tests\Security; +use PHPForge\Scaffold\Security\PackageAllowlist; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; -use yii\scaffold\Security\PackageAllowlist; /** * Unit tests for {@see PackageAllowlist} authorization enforcement. @@ -20,9 +20,9 @@ public function testAssertAllowedPassesSilentlyForAuthorizedPackage(): void { $this->expectNotToPerformAssertions(); - $list = new PackageAllowlist(['yii2-extensions/nginx-scaffold']); + $list = new PackageAllowlist(['php-forge/nginx-scaffold']); - $list->assertAllowed('yii2-extensions/nginx-scaffold'); + $list->assertAllowed('php-forge/nginx-scaffold'); } public function testAssertAllowedThrowsForEmptyAllowlist(): void @@ -37,12 +37,12 @@ public function testAssertAllowedThrowsForEmptyAllowlist(): void public function testAssertAllowedThrowsForUnauthorizedPackage(): void { - $list = new PackageAllowlist(['yii2-extensions/app-base-scaffold']); + $list = new PackageAllowlist(['php-forge/app-base-scaffold']); $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('yii2-extensions/nginx-scaffold'); + $this->expectExceptionMessage('php-forge/nginx-scaffold'); - $list->assertAllowed('yii2-extensions/nginx-scaffold'); + $list->assertAllowed('php-forge/nginx-scaffold'); } public function testEmptyAllowlistRejectsEveryPackage(): void @@ -50,21 +50,21 @@ public function testEmptyAllowlistRejectsEveryPackage(): void $list = new PackageAllowlist([]); self::assertFalse( - $list->isAllowed('yii2-extensions/anything'), + $list->isAllowed('php-forge/anything'), 'Empty allowlist should reject all packages.', ); } public function testIsAllowedUsesStrictStringComparison(): void { - $list = new PackageAllowlist(['yii2-extensions/nginx-scaffold']); + $list = new PackageAllowlist(['php-forge/nginx-scaffold']); self::assertFalse( - $list->isAllowed('yii2-extensions/apache-scaffold'), + $list->isAllowed('php-forge/apache-scaffold'), 'Package not in allowlist should not be allowed.', ); self::assertTrue( - $list->isAllowed('yii2-extensions/nginx-scaffold'), + $list->isAllowed('php-forge/nginx-scaffold'), 'Package in allowlist should be allowed.', ); } @@ -72,45 +72,45 @@ public function testIsAllowedUsesStrictStringComparison(): void public function testMultiplePackagesInAllowlist(): void { $list = new PackageAllowlist([ - 'yii2-extensions/app-base-scaffold', - 'yii2-extensions/nginx-scaffold', - 'yii2-extensions/inertia-vue-scaffold', + 'php-forge/app-base-scaffold', + 'php-forge/nginx-scaffold', + 'php-forge/inertia-vue-scaffold', ]); self::assertTrue( - $list->isAllowed('yii2-extensions/app-base-scaffold'), + $list->isAllowed('php-forge/app-base-scaffold'), 'First package in allowlist should be allowed.', ); self::assertTrue( - $list->isAllowed('yii2-extensions/nginx-scaffold'), + $list->isAllowed('php-forge/nginx-scaffold'), 'Second package in allowlist should be allowed.', ); self::assertTrue( - $list->isAllowed('yii2-extensions/inertia-vue-scaffold'), + $list->isAllowed('php-forge/inertia-vue-scaffold'), 'Third package in allowlist should be allowed.', ); self::assertFalse( - $list->isAllowed('yii2-extensions/apache-scaffold'), + $list->isAllowed('php-forge/apache-scaffold'), 'Package not in allowlist should not be allowed.', ); } public function testPackageInAllowlistIsAllowed(): void { - $list = new PackageAllowlist(['yii2-extensions/app-base-scaffold', 'yii2-extensions/nginx-scaffold']); + $list = new PackageAllowlist(['php-forge/app-base-scaffold', 'php-forge/nginx-scaffold']); self::assertTrue( - $list->isAllowed('yii2-extensions/app-base-scaffold'), + $list->isAllowed('php-forge/app-base-scaffold'), 'Package in allowlist should be allowed.', ); } public function testPackageNotInAllowlistIsNotAllowed(): void { - $list = new PackageAllowlist(['yii2-extensions/app-base-scaffold']); + $list = new PackageAllowlist(['php-forge/app-base-scaffold']); self::assertFalse( - $list->isAllowed('yii2-extensions/nginx-scaffold'), + $list->isAllowed('php-forge/nginx-scaffold'), 'Package not in allowlist should not be allowed.', ); } diff --git a/tests/unit/Security/PathValidatorTest.php b/tests/Security/PathValidatorTest.php similarity index 98% rename from tests/unit/Security/PathValidatorTest.php rename to tests/Security/PathValidatorTest.php index 722a336..cbae95e 100644 --- a/tests/unit/Security/PathValidatorTest.php +++ b/tests/Security/PathValidatorTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Security; +namespace PHPForge\Scaffold\Tests\Security; +use PHPForge\Scaffold\Security\PathValidator; +use PHPForge\Scaffold\Tests\Support\TempDirectoryTrait; use PHPUnit\Framework\Attributes\{Group, RequiresOperatingSystemFamily}; use PHPUnit\Framework\TestCase; use ReflectionMethod; use RuntimeException; -use yii\scaffold\Security\PathValidator; -use yii\scaffold\tests\support\TempDirectoryTrait; /** * Unit tests for {@see PathValidator} path traversal and absolute path detection. diff --git a/tests/unit/Services/DiffServiceTest.php b/tests/Services/DiffServiceTest.php similarity index 98% rename from tests/unit/Services/DiffServiceTest.php rename to tests/Services/DiffServiceTest.php index 178291c..34b1e27 100644 --- a/tests/unit/Services/DiffServiceTest.php +++ b/tests/Services/DiffServiceTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Services; +namespace PHPForge\Scaffold\Tests\Services; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Services\DiffService; +use PHPForge\Scaffold\Tests\Support\{BufferedOutputWriter, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Services\DiffService; -use yii\scaffold\tests\support\{BufferedOutputWriter, TempDirectoryTrait}; /** * Unit tests for {@see DiffService} covering diff computation and error handling for unsafe / missing inputs. @@ -270,7 +270,7 @@ public function testRunEndsCurrentFileReadErrorWithSinglePhpEolSuffixOnStderr(): ); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_get_contents', [], false, @@ -434,7 +434,7 @@ public function testRunReturnsErrorWhenCurrentFileReadFails(): void ); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_get_contents', [], false, diff --git a/tests/unit/Services/EjectServiceTest.php b/tests/Services/EjectServiceTest.php similarity index 96% rename from tests/unit/Services/EjectServiceTest.php rename to tests/Services/EjectServiceTest.php index 88b749b..1bb33f8 100644 --- a/tests/unit/Services/EjectServiceTest.php +++ b/tests/Services/EjectServiceTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Services; +namespace PHPForge\Scaffold\Tests\Services; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Services\EjectService; +use PHPForge\Scaffold\Tests\Support\{BufferedOutputWriter, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\Services\EjectService; -use yii\scaffold\tests\support\{BufferedOutputWriter, TempDirectoryTrait}; /** * Unit tests for {@see EjectService} covering dry-run, confirmed removal, and untracked-file error paths. diff --git a/tests/unit/Services/ProvidersServiceTest.php b/tests/Services/ProvidersServiceTest.php similarity index 97% rename from tests/unit/Services/ProvidersServiceTest.php rename to tests/Services/ProvidersServiceTest.php index a565325..83b0df6 100644 --- a/tests/unit/Services/ProvidersServiceTest.php +++ b/tests/Services/ProvidersServiceTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Services; +namespace PHPForge\Scaffold\Tests\Services; +use PHPForge\Scaffold\Scaffold\Lock\LockFile; +use PHPForge\Scaffold\Services\ProvidersService; +use PHPForge\Scaffold\Tests\Support\{BufferedOutputWriter, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -use yii\scaffold\Scaffold\Lock\LockFile; -use yii\scaffold\Services\ProvidersService; -use yii\scaffold\tests\support\{BufferedOutputWriter, TempDirectoryTrait}; /** * Unit tests for {@see ProvidersService} covering file-count aggregation and empty-state output. diff --git a/tests/unit/Services/ReapplyServiceTest.php b/tests/Services/ReapplyServiceTest.php similarity index 98% rename from tests/unit/Services/ReapplyServiceTest.php rename to tests/Services/ReapplyServiceTest.php index fd63bbb..2d91b6e 100644 --- a/tests/unit/Services/ReapplyServiceTest.php +++ b/tests/Services/ReapplyServiceTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Services; +namespace PHPForge\Scaffold\Tests\Services; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Scaffold\PathResolver; +use PHPForge\Scaffold\Services\ReapplyService; +use PHPForge\Scaffold\Tests\Support\{BufferedOutputWriter, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Scaffold\PathResolver; -use yii\scaffold\Services\ReapplyService; -use yii\scaffold\tests\support\{BufferedOutputWriter, TempDirectoryTrait}; /** * Unit tests for {@see ReapplyService} covering single-file, provider-filter, force, and error-path branches. @@ -172,14 +172,14 @@ public function testEnsureDirectoryFailureIsReportedAsError(): void $this->seedTracked('deep/config/params.php', "stub\n", "current\n", lockHashOf: "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'mkdir', [], false, default: true, ); MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'is_dir', [], false, @@ -214,7 +214,7 @@ public function testEnsureDirectoryFailureSkipContinuesIterationToNextReapplicab rmdir(dirname($deepDestination)); MockerState::addCondition( - 'yii\\scaffold\\Scaffold', + 'PHPForge\\Scaffold\\Scaffold', 'mkdir', [], false, @@ -315,7 +315,7 @@ public function testHashFailureBeforeWriteIsReported(): void $this->seedTracked('config/params.php', "stub\n", "user-edited\n", lockHashOf: "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'hash_file', [], false, @@ -346,7 +346,7 @@ public function testHashFailureSkipContinuesIterationToNextReapplicableEntry(): // Target the first destination exclusively so the mock does not leak into the second iteration's hash calls. MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'hash_file', ['sha256', PathResolver::destination($this->tempDir, 'first.txt'), false, []], false, @@ -464,7 +464,7 @@ public function testPostWriteHashFailureSkipContinuesIterationToNextReapplicable $this->seedTracked('second.txt', "new-stub\n", "user-edited\n", lockHashOf: "user-edited\n"); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'hash_file', [], false, @@ -512,7 +512,7 @@ public function testPostWriteHashFailureSkipsLockUpdate(): void ); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'hash_file', [], false, @@ -995,7 +995,7 @@ public function testStubReadFailureIsReportedAsError(): void $this->seedTracked('config/params.php', "stub\n", "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_get_contents', [], false, @@ -1025,7 +1025,7 @@ public function testStubReadFailureSkipContinuesIterationToNextReapplicableEntry $this->seedTracked('second.txt', "stub\n", "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_get_contents', [], false, @@ -1210,7 +1210,7 @@ public function testWriteFailureIsReportedAsError(): void $this->seedTracked('config/params.php', "stub\n", "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_put_contents', [], false, @@ -1240,7 +1240,7 @@ public function testWriteFailureSkipContinuesIterationToNextReapplicableEntry(): $this->seedTracked('second.txt', "stub\n", "stub\n"); MockerState::addCondition( - 'yii\\scaffold\\Services', + 'PHPForge\\Scaffold\\Services', 'file_put_contents', [], false, diff --git a/tests/unit/Services/StatusServiceTest.php b/tests/Services/StatusServiceTest.php similarity index 98% rename from tests/unit/Services/StatusServiceTest.php rename to tests/Services/StatusServiceTest.php index 4ce37d0..d915d3a 100644 --- a/tests/unit/Services/StatusServiceTest.php +++ b/tests/Services/StatusServiceTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace yii\scaffold\tests\unit\Services; +namespace PHPForge\Scaffold\Tests\Services; +use PHPForge\Scaffold\Scaffold\Lock\{Hasher, LockFile}; +use PHPForge\Scaffold\Services\StatusService; +use PHPForge\Scaffold\Tests\Support\{BufferedOutputWriter, TempDirectoryTrait}; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Xepozz\InternalMocker\MockerState; -use yii\scaffold\Scaffold\Lock\{Hasher, LockFile}; -use yii\scaffold\Services\StatusService; -use yii\scaffold\tests\support\{BufferedOutputWriter, TempDirectoryTrait}; /** * Unit tests for {@see StatusService} covering the status-computation branches and rendered output. @@ -113,7 +113,7 @@ public function testGetStatusesMarksEntryAsErrorWhenHashThrows(): void ], ); MockerState::addCondition( - 'yii\\scaffold\\Scaffold\\Lock', + 'PHPForge\\Scaffold\\Scaffold\\Lock', 'is_readable', [], false, diff --git a/tests/support/BufferedOutputWriter.php b/tests/Support/BufferedOutputWriter.php similarity index 91% rename from tests/support/BufferedOutputWriter.php rename to tests/Support/BufferedOutputWriter.php index 925f4b6..0c37db7 100644 --- a/tests/support/BufferedOutputWriter.php +++ b/tests/Support/BufferedOutputWriter.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace yii\scaffold\tests\support; +namespace PHPForge\Scaffold\Tests\Support; -use yii\scaffold\Console\OutputWriter; +use PHPForge\Scaffold\Console\OutputWriter; /** * In-memory {@see OutputWriter} implementation that buffers stdout / stderr writes into public strings for assertion. diff --git a/tests/support/ComposerEventHarness.php b/tests/Support/ComposerEventHarness.php similarity index 90% rename from tests/support/ComposerEventHarness.php rename to tests/Support/ComposerEventHarness.php index 8b93275..19aa91e 100644 --- a/tests/support/ComposerEventHarness.php +++ b/tests/Support/ComposerEventHarness.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\tests\support; +namespace PHPForge\Scaffold\Tests\Support; use Composer\Composer; use Composer\Factory; @@ -10,9 +10,9 @@ use Composer\Package\{CompletePackage, PackageInterface}; use Composer\Script\Event as ScriptEvent; use Composer\Script\ScriptEvents; +use PHPForge\Scaffold\EventSubscriber; use ReflectionClass; use RuntimeException; -use yii\scaffold\EventSubscriber; use function sprintf; @@ -23,9 +23,9 @@ * repository with mock provider packages, and (3) building {@see ScriptEvent} instances for the three lifecycle events * the scaffold plugin subscribes to. * - * Tests dispatch events directly against a {@see \yii\scaffold\EventSubscriber} instance, bypassing the full Composer - * installation pipeline. This exercises the same code path the plugin runs in production without the cost and - * brittleness of shelling out to `composer install`. + * Tests dispatch events directly against a {@see \PHPForge\Scaffold\EventSubscriber} instance, bypassing the full + * Composer installation pipeline. This exercises the same code path the plugin runs in production without the cost + * and brittleness of shelling out to `composer install`. */ trait ComposerEventHarness { @@ -48,7 +48,7 @@ protected function addMockProvider( ): PackageInterface { $package = new CompletePackage($name, "{$version}.0", $version); - $package->setType('yii2-scaffold'); + $package->setType('library'); $package->setExtra(['scaffold' => $scaffoldManifest]); $composer->getRepositoryManager()->getLocalRepository()->addPackage($package); @@ -58,8 +58,8 @@ protected function addMockProvider( /** * Creates a {@see Composer} instance for a fake project using {@see Factory::create()}. * - * Plugins are disabled because tests manually instantiate {@see \yii\scaffold\EventSubscriber} and dispatch events - * against it, so the plugin manager does not need to auto-load this package. + * Plugins are disabled because tests manually instantiate {@see \PHPForge\Scaffold\EventSubscriber} and dispatch + * events against it, so the plugin manager does not need to auto-load this package. * * @param string $projectRoot Absolute path to the fake project directory containing `composer.json`. * @param IOInterface|null $io Optional IO; a {@see BufferIO} is created when omitted so callers can inspect output. diff --git a/tests/support/FakeProjectBuilder.php b/tests/Support/FakeProjectBuilder.php similarity index 97% rename from tests/support/FakeProjectBuilder.php rename to tests/Support/FakeProjectBuilder.php index b4cd6b7..7129045 100644 --- a/tests/support/FakeProjectBuilder.php +++ b/tests/Support/FakeProjectBuilder.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\tests\support; +namespace PHPForge\Scaffold\Tests\Support; use RuntimeException; @@ -77,7 +77,7 @@ public function createProjectFile(string $relPath, string $content): void /** * Creates a stub file for a provider package inside the fake vendor directory. * - * @param string $providerName Composer package name (for example, `yii2-extensions/app-base-scaffold`). + * @param string $providerName Composer package name (for example, `php-forge/app-base-scaffold`). * @param string $relPath Path relative to the provider root (for example, `stubs/config/params.php`). * @param string $content File content to write. */ diff --git a/tests/support/MockerExtension.php b/tests/Support/MockerExtension.php similarity index 73% rename from tests/support/MockerExtension.php rename to tests/Support/MockerExtension.php index c534376..2ee4dff 100644 --- a/tests/support/MockerExtension.php +++ b/tests/Support/MockerExtension.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\tests\support; +namespace PHPForge\Scaffold\Tests\Support; use PHPUnit\Event\Test\{Finished, FinishedSubscriber, PreparationStarted, PreparationStartedSubscriber}; use PHPUnit\Event\TestSuite\{Started, StartedSubscriber}; @@ -55,20 +55,20 @@ public function notify(Finished $event): void public static function load(): void { $mocks = [ - ['namespace' => 'yii\\scaffold\\Scaffold\\Lock', 'name' => 'is_readable'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Lock', 'name' => 'file_get_contents'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Lock', 'name' => 'file_put_contents'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Lock', 'name' => 'rename'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Lock', 'name' => 'hash_file'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Modes', 'name' => 'file_put_contents'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Modes', 'name' => 'file_get_contents'], - ['namespace' => 'yii\\scaffold\\Scaffold\\Modes', 'name' => 'copy'], - ['namespace' => 'yii\\scaffold\\Scaffold', 'name' => 'mkdir'], - ['namespace' => 'yii\\scaffold\\Scaffold', 'name' => 'is_dir'], - ['namespace' => 'yii\\scaffold\\Manifest', 'name' => 'file_get_contents'], - ['namespace' => 'yii\\scaffold\\Services', 'name' => 'file_get_contents'], - ['namespace' => 'yii\\scaffold\\Services', 'name' => 'file_put_contents'], - ['namespace' => 'yii\\scaffold\\Console\\Command', 'name' => 'getcwd'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Lock', 'name' => 'is_readable'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Lock', 'name' => 'file_get_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Lock', 'name' => 'file_put_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Lock', 'name' => 'rename'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Lock', 'name' => 'hash_file'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Modes', 'name' => 'file_put_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Modes', 'name' => 'file_get_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold\\Modes', 'name' => 'copy'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold', 'name' => 'mkdir'], + ['namespace' => 'PHPForge\\Scaffold\\Scaffold', 'name' => 'is_dir'], + ['namespace' => 'PHPForge\\Scaffold\\Manifest', 'name' => 'file_get_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Services', 'name' => 'file_get_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Services', 'name' => 'file_put_contents'], + ['namespace' => 'PHPForge\\Scaffold\\Console\\Command', 'name' => 'getcwd'], ]; $mocksPath = __DIR__ . '/../../runtime/.phpunit.cache/internal-mocker/mocks.php'; diff --git a/tests/support/TempDirectoryTrait.php b/tests/Support/TempDirectoryTrait.php similarity index 98% rename from tests/support/TempDirectoryTrait.php rename to tests/Support/TempDirectoryTrait.php index 52c7657..85ecce3 100644 --- a/tests/support/TempDirectoryTrait.php +++ b/tests/Support/TempDirectoryTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace yii\scaffold\tests\support; +namespace PHPForge\Scaffold\Tests\Support; use FilesystemIterator; use RecursiveDirectoryIterator; diff --git a/tests/support/bootstrap.php b/tests/Support/bootstrap.php similarity index 100% rename from tests/support/bootstrap.php rename to tests/Support/bootstrap.php diff --git a/tests/support/internal-mocker-stubs.php b/tests/Support/internal-mocker-stubs.php similarity index 100% rename from tests/support/internal-mocker-stubs.php rename to tests/Support/internal-mocker-stubs.php diff --git a/tests/fixtures/providers/invalid-traversal/scaffold.json b/tests/fixtures/providers/invalid-traversal/scaffold.json deleted file mode 100644 index 143641b..0000000 --- a/tests/fixtures/providers/invalid-traversal/scaffold.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "file-mapping": { - "../../../etc/passwd": { - "source": "stubs/params.php" - } - } -} diff --git a/tests/fixtures/providers/malformed-manifest/scaffold.json b/tests/fixtures/providers/malformed-manifest/scaffold.json deleted file mode 100644 index d49e321..0000000 --- a/tests/fixtures/providers/malformed-manifest/scaffold.json +++ /dev/null @@ -1 +0,0 @@ -{ this is not valid json at all diff --git a/tests/fixtures/providers/valid-external/composer.json b/tests/fixtures/providers/valid-external/composer.json deleted file mode 100644 index 9a81809..0000000 --- a/tests/fixtures/providers/valid-external/composer.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "yii2-extensions/inertia-vue-scaffold", - "type": "yii2-scaffold", - "description": "Inertia.js + Vue 3 scaffold provider", - "extra": { - "scaffold": { - "manifest": "scaffold.json" - } - } -} diff --git a/tests/fixtures/providers/valid-external/scaffold.json b/tests/fixtures/providers/valid-external/scaffold.json deleted file mode 100644 index 86d62c7..0000000 --- a/tests/fixtures/providers/valid-external/scaffold.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "file-mapping": { - "resources/js/app.js": { - "source": "stubs/resources/js/app.js", - "mode": "preserve" - }, - "vite.config.js": { - "source": "stubs/vite.config.js", - "mode": "replace" - } - } -} diff --git a/tests/fixtures/providers/valid-external/stubs/resources/js/app.js b/tests/fixtures/providers/valid-external/stubs/resources/js/app.js deleted file mode 100644 index ff30bbd..0000000 --- a/tests/fixtures/providers/valid-external/stubs/resources/js/app.js +++ /dev/null @@ -1,14 +0,0 @@ -import { createApp, h } from "vue"; -import { createInertiaApp } from "@inertiajs/vue3"; - -createInertiaApp({ - resolve: (name) => { - const pages = import.meta.glob("./Pages/**/*.vue", { eager: true }); - return pages[`./Pages/${name}.vue`]; - }, - setup({ el, App, props, plugin }) { - createApp({ render: () => h(App, props) }) - .use(plugin) - .mount(el); - }, -}); diff --git a/tests/fixtures/providers/valid-inline/composer.json b/tests/fixtures/providers/valid-inline/composer.json deleted file mode 100644 index 1719b6e..0000000 --- a/tests/fixtures/providers/valid-inline/composer.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "yii2-extensions/apache-scaffold", - "type": "yii2-scaffold", - "description": "Apache scaffold provider", - "extra": { - "scaffold": { - "file-mapping": { - "public/.htaccess": { - "source": "stubs/public/.htaccess", - "mode": "preserve" - }, - ".htaccess": { - "source": "stubs/.htaccess", - "mode": "replace" - } - } - } - } -}