From e40ae3649d62a933211e81d8ac773fdd86ff1dfb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 20:54:29 +0900 Subject: test(cli): add end-to-end integration tests for CLI commands Add 23 integration tests using assert_cmd and predicates covering about, validate, show, licenses, install, config, init, and dump-autoload commands with shared test helpers and fixture projects. Co-Authored-By: Claude Opus 4.6 --- .../tests/fixtures/invalid_json/composer.json | 1 + crates/mozart/tests/fixtures/minimal/composer.json | 8 +++ .../tests/fixtures/with_dev_deps/composer.json | 12 ++++ .../tests/fixtures/with_dev_deps/composer.lock | 80 ++++++++++++++++++++++ .../with_dev_deps/vendor/composer/installed.json | 32 +++++++++ .../tests/fixtures/with_installed/composer.json | 9 +++ .../tests/fixtures/with_installed/composer.lock | 56 +++++++++++++++ .../with_installed/vendor/composer/installed.json | 18 +++++ .../mozart/tests/fixtures/with_lock/composer.json | 9 +++ .../mozart/tests/fixtures/with_lock/composer.lock | 56 +++++++++++++++ 10 files changed, 281 insertions(+) create mode 100644 crates/mozart/tests/fixtures/invalid_json/composer.json create mode 100644 crates/mozart/tests/fixtures/minimal/composer.json create mode 100644 crates/mozart/tests/fixtures/with_dev_deps/composer.json create mode 100644 crates/mozart/tests/fixtures/with_dev_deps/composer.lock create mode 100644 crates/mozart/tests/fixtures/with_dev_deps/vendor/composer/installed.json create mode 100644 crates/mozart/tests/fixtures/with_installed/composer.json create mode 100644 crates/mozart/tests/fixtures/with_installed/composer.lock create mode 100644 crates/mozart/tests/fixtures/with_installed/vendor/composer/installed.json create mode 100644 crates/mozart/tests/fixtures/with_lock/composer.json create mode 100644 crates/mozart/tests/fixtures/with_lock/composer.lock (limited to 'crates/mozart/tests/fixtures') diff --git a/crates/mozart/tests/fixtures/invalid_json/composer.json b/crates/mozart/tests/fixtures/invalid_json/composer.json new file mode 100644 index 0000000..e367425 --- /dev/null +++ b/crates/mozart/tests/fixtures/invalid_json/composer.json @@ -0,0 +1 @@ +{this is not valid json diff --git a/crates/mozart/tests/fixtures/minimal/composer.json b/crates/mozart/tests/fixtures/minimal/composer.json new file mode 100644 index 0000000..a84ee9f --- /dev/null +++ b/crates/mozart/tests/fixtures/minimal/composer.json @@ -0,0 +1,8 @@ +{ + "name": "test/minimal-project", + "description": "A minimal test project", + "license": "MIT", + "require": { + "php": ">=8.1" + } +} diff --git a/crates/mozart/tests/fixtures/with_dev_deps/composer.json b/crates/mozart/tests/fixtures/with_dev_deps/composer.json new file mode 100644 index 0000000..09126f2 --- /dev/null +++ b/crates/mozart/tests/fixtures/with_dev_deps/composer.json @@ -0,0 +1,12 @@ +{ + "name": "test/dev-project", + "description": "A project with dev dependencies", + "license": "MIT", + "require": { + "php": ">=8.1", + "psr/log": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + } +} diff --git a/crates/mozart/tests/fixtures/with_dev_deps/composer.lock b/crates/mozart/tests/fixtures/with_dev_deps/composer.lock new file mode 100644 index 0000000..d01e341 --- /dev/null +++ b/crates/mozart/tests/fixtures/with_dev_deps/composer.lock @@ -0,0 +1,80 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ed17fac2f30232d69c31587151006a2f", + "packages": [ + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "license": [ + "MIT" + ], + "description": "Common interface for logging libraries", + "time": "2024-09-11T13:17:53+00:00" + } + ], + "packages-dev": [ + { + "name": "phpunit/phpunit", + "version": "11.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "fake000000000000000000000000000000000001" + }, + "dist": { + "type": "zip", + "url": "https://fake.example.com/phpunit-11.0.0.zip", + "reference": "fake000000000000000000000000000000000001", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPUnit\\": "src/" + } + }, + "license": [ + "BSD-3-Clause" + ], + "description": "The PHP Unit Testing framework", + "time": "2024-02-02T06:38:00+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.1" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/crates/mozart/tests/fixtures/with_dev_deps/vendor/composer/installed.json b/crates/mozart/tests/fixtures/with_dev_deps/vendor/composer/installed.json new file mode 100644 index 0000000..efa3905 --- /dev/null +++ b/crates/mozart/tests/fixtures/with_dev_deps/vendor/composer/installed.json @@ -0,0 +1,32 @@ +{ + "packages": [ + { + "name": "phpunit/phpunit", + "version": "11.0.0", + "version_normalized": "11.0.0.0", + "type": "library", + "install-path": "../phpunit/phpunit", + "autoload": { + "psr-4": { + "PHPUnit\\": "src/" + } + } + }, + { + "name": "psr/log", + "version": "3.0.2", + "version_normalized": "3.0.2.0", + "type": "library", + "install-path": "../psr/log", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + } + } + ], + "dev-package-names": [ + "phpunit/phpunit" + ], + "dev": true +} diff --git a/crates/mozart/tests/fixtures/with_installed/composer.json b/crates/mozart/tests/fixtures/with_installed/composer.json new file mode 100644 index 0000000..1653318 --- /dev/null +++ b/crates/mozart/tests/fixtures/with_installed/composer.json @@ -0,0 +1,9 @@ +{ + "name": "test/locked-project", + "description": "A project with a lock file", + "license": "MIT", + "require": { + "php": ">=8.1", + "psr/log": "^3.0" + } +} diff --git a/crates/mozart/tests/fixtures/with_installed/composer.lock b/crates/mozart/tests/fixtures/with_installed/composer.lock new file mode 100644 index 0000000..0e4f7aa --- /dev/null +++ b/crates/mozart/tests/fixtures/with_installed/composer.lock @@ -0,0 +1,56 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ca27a8c1835db5af5fd5efe936f402b4", + "packages": [ + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "license": [ + "MIT" + ], + "description": "Common interface for logging libraries", + "homepage": "https://www.php-fig.org/", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2024-09-11T13:17:53+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.1" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/crates/mozart/tests/fixtures/with_installed/vendor/composer/installed.json b/crates/mozart/tests/fixtures/with_installed/vendor/composer/installed.json new file mode 100644 index 0000000..bbbe53c --- /dev/null +++ b/crates/mozart/tests/fixtures/with_installed/vendor/composer/installed.json @@ -0,0 +1,18 @@ +{ + "packages": [ + { + "name": "psr/log", + "version": "3.0.2", + "version_normalized": "3.0.2.0", + "type": "library", + "install-path": "../psr/log", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + } + } + ], + "dev-package-names": [], + "dev": true +} diff --git a/crates/mozart/tests/fixtures/with_lock/composer.json b/crates/mozart/tests/fixtures/with_lock/composer.json new file mode 100644 index 0000000..1653318 --- /dev/null +++ b/crates/mozart/tests/fixtures/with_lock/composer.json @@ -0,0 +1,9 @@ +{ + "name": "test/locked-project", + "description": "A project with a lock file", + "license": "MIT", + "require": { + "php": ">=8.1", + "psr/log": "^3.0" + } +} diff --git a/crates/mozart/tests/fixtures/with_lock/composer.lock b/crates/mozart/tests/fixtures/with_lock/composer.lock new file mode 100644 index 0000000..0e4f7aa --- /dev/null +++ b/crates/mozart/tests/fixtures/with_lock/composer.lock @@ -0,0 +1,56 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ca27a8c1835db5af5fd5efe936f402b4", + "packages": [ + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "license": [ + "MIT" + ], + "description": "Common interface for logging libraries", + "homepage": "https://www.php-fig.org/", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2024-09-11T13:17:53+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.1" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} -- cgit v1.3.1